Repository navigation
fix(ai): replay responses history independently of storage - #45050
Merged
Merged
Conversation
3 of 6 tasks
jinhuang712
pushed a commit
to jinhuang712/opencode
that referenced
this pull request
Sep 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
storestrictly as provider persistence policy instead of changing conversation-history lowering or reasoning lifecycleweb_search_call,file_search_call,code_interpreter_call, andmcp_call; reject malformed known payloads and unknown tool discriminators*_callvalues in the shared baselineitem_referencegenerationSupersedes 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_callremains valid only through xAI protocol composition; OpenAIcomputer_callremains valid only through OpenAI protocol composition; unknown or malformed items fall back to portable message content. Generated images remain portableinput_imagecontent 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
store: falsebun 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-failuresRECORDED_PREFIX=pdf RECORDED_PROVIDER=xai bun test test/provider/pdf.recorded.test.ts --timeout 30000 --only-failuresbun typecheckfrompackages/ai