Skip to content

fix(ai): replay responses history independently of storage - #45050

Merged
rekram1-node merged 3 commits into
v2from
responses-history
Aug 25, 2026
Merged

rekram1-node merged 3 commits into
v2from
responses-history

Conversation

@rekram1-node

@rekram1-node rekram1-node commented Aug 25, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • treat Responses store strictly as provider persistence policy instead of changing conversation-history lowering or reasoning lifecycle
  • model shared hosted items with explicit schemas for web_search_call, file_search_call, code_interpreter_call, and mcp_call; reject malformed known payloads and unknown tool discriminators
  • compose OpenAI-only computer/preview/image items and xAI-only X-search/image items in their respective protocol request schemas instead of accepting arbitrary *_call values in the shared baseline
  • replay same-provider JSON hosted results through schema-backed provider extensions while preserving generated images, hosted errors, malformed items, and foreign-provider results as portable content
  • always replay complete reasoning items and preserve encrypted reasoning metadata independently of storage; remove synthetic item_reference generation
  • refresh the hosted image-generation/edit cassette against the live OpenAI API

Supersedes the narrower native hosted-tool replay in #45038.

Before and after

Previously the shared Responses schema accepted essentially any object whose type ended in _call, including provider-private or invented tool types, and replay checked the suffix manually. Stored reasoning and hosted results were also rewritten into references:

[
  { "type": "item_reference", "id": "rs_1" },
  { "type": "item_reference", "id": "ws_1" }
]

Now the provider-neutral schema accepts only its explicitly modeled hosted items, OpenAI and xAI compose their own private extensions, and both storage modes preserve valid provider-native history:

[
  {
    "type": "reasoning",
    "id": "rs_1",
    "summary": [{ "type": "summary_text", "text": "Checked the previous diff." }],
    "encrypted_content": "encrypted-state"
  },
  { "type": "web_search_call", "id": "ws_1", "status": "completed" }
]

An xAI x_search_call remains valid only through xAI protocol composition; OpenAI computer_call remains valid only through OpenAI protocol composition; unknown or malformed items fall back to portable message content. Generated images remain portable input_image content regardless of storage. Live OpenAI requests confirmed that native stateless web-search replay succeeds, while native image-item replay fails because hosted images are not persisted.

Verification

  • Live OpenAI hosted web-search native replay with store: false
  • Focused live recording of the OpenAI hosted image-generation/edit scenario
  • bun test test/partial-json.test.ts test/tool-stream.test.ts test/provider/openai-responses.test.ts test/provider/openai-compatible-responses.test.ts test/provider/openai-responses-images.recorded.test.ts test/provider/openai-responses-websocket.recorded.test.ts test/provider/openai-chat.test.ts test/provider/anthropic-messages.test.ts test/provider/bedrock-converse.test.ts test/provider/xai-responses.test.ts test/response.test.ts test/tool-runtime.test.ts --timeout 30000 --only-failures (373 passing)
  • RECORDED_PREFIX=openai-responses bun test test/provider/golden.recorded.test.ts --timeout 30000 --only-failures
  • RECORDED_PREFIX=pdf RECORDED_PROVIDER=xai bun test test/provider/pdf.recorded.test.ts --timeout 30000 --only-failures
  • bun typecheck from packages/ai

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant