fix(openai): skip reasoning items in Responses API replay#181
Merged
andreynering merged 1 commit intocharmbracelet:mainfrom Mar 19, 2026
Merged
Conversation
When Store is enabled, replaying reasoning items (OfReasoning) in the Responses API input causes a validation error: Item 'rs_xxx' of type 'reasoning' was provided without its required following item. The API stores reasoning server-side and cannot pair a reconstructed reasoning item with the output item that originally followed it. The fix skips reasoning parts during replay, letting the conversation continue with visible assistant content (text / tool calls).
bb0359a to
b71e757
Compare
kylecarbs
added a commit
to coder/coder
that referenced
this pull request
Mar 19, 2026
…#23297) ## Problem When `Store: true` is set for OpenAI Responses API calls (the new default), multi-turn conversations with reasoning models fail on the second message: ``` stream response: bad request: Item 'rs_xxx' of type 'reasoning' was provided without its required following item. ``` The fantasy library was reconstructing full `OfReasoning` input items (with encrypted content and summary) when replaying assistant messages. The API cannot pair these reconstructed reasoning items with the output items that originally followed them because the output items are sent as plain `OfMessage` without server-side IDs. ## Fix Updates the fantasy dependency (`kylecarbs/fantasy@cj/go1.25`) to skip reasoning parts during conversation replay in `toResponsesPrompt`. With `Store` enabled, the API already has the reasoning persisted server-side — it doesn't need to be replayed in the input. Fantasy PR: charmbracelet/fantasy#181 ## Testing Adds `TestOpenAIReasoningRoundTrip` integration test that: 1. Sends a query to `o4-mini` (reasoning model with `Store: true`) 2. Verifies reasoning content is persisted 3. Sends a follow-up message — this was the failing step 4. Verifies the follow-up completes successfully Requires `OPENAI_API_KEY` env var to run.
meowgorithm
approved these changes
Mar 19, 2026
andreynering
approved these changes
Mar 19, 2026
Member
andreynering
left a comment
There was a problem hiding this comment.
Thank you again @kylecarbs!
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.
When Store is enabled, replaying reasoning items (OfReasoning) in the Responses API input causes a validation error:
Item 'rs_xxx' of type 'reasoning' was provided without its
required following item.
The API stores reasoning server-side and cannot pair a reconstructed reasoning item with the output item that originally followed it. The fix skips reasoning parts during replay, letting the conversation continue with visible assistant content (text / tool calls).
CONTRIBUTING.md.