fix(providers/openai): emit item_reference for reasoning items when store=true#7
Closed
ibetitsmike wants to merge 6 commits intocoder:cj/go1.25from
Closed
Conversation
Remove kronk provider and examples (every published version requires go 1.26). Downgrade kaptinlin deps to Go 1.25-compatible versions.
coder/coder and coder/aibridge use the SasSwart perf fork of openai-go/v3 (deferred body serialization, appendCompact skip). This fork had a bug where WithJSONSet modifications (used by NewStreaming to inject "stream": true) were clobbered by the deferred body serialization. kylecarbs/openai-go includes the fix from kylecarbs/openai-go#2. Also adjusts two .OfString accesses since the fork's ResponseOutputItemUnion.Arguments is a plain string rather than the upstream union type.
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).
Cherry-picked from #4. - Reasoning items: Always skip during replay (store=true has them persisted; store=false IDs are ephemeral). - Provider-executed tool calls: Gate item_reference behind the store flag; skip when store=false.
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 an OpenAI reasoning model (e.g. o4-mini) produces both reasoning output and a provider-executed
web_search_callin the same response, the follow-up turn fails because:web_search_callis replayed viaitem_reference(toolCallID)whenstore=trueFix: When
store=true, emititem_referencefor reasoning items using the persistedItemIDfrom metadata, instead of skipping them. This keeps reasoning and web_search items correctly paired during replay.store=falsebehavior is unchanged — reasoning items are still skipped since ephemeral IDs can't be referenced.Changes
providers/openai/responses_language_model.go: Updated reasoning replay case to emititem_referencewhenstore=trueproviders/openai/openai_test.go: Updated existing reasoning replay test + added combined reasoning + web_search testTesting
TestResponsesToPrompt_ReasoningWithStore— updated, passingTestResponsesToPrompt_ReasoningWithWebSearchCombined— new, passing./providers/openai/suite — passing