fix(openai): fix Responses API 400 errors for reasoning, tool calls, and ID handling#11785
fix(openai): fix Responses API 400 errors for reasoning, tool calls, and ID handling#11785
Conversation
Documentation ReviewNo documentation updates are needed for this PR. Rationale: This PR contains internal bug fixes in
Users will automatically benefit from these fixes when using OpenAI models with tool calling and reasoning capabilities—no documentation changes required. |
43f9931 to
690d98f
Compare
690d98f to
588d81a
Compare
|
Outstanding contribution on this PR. The level of detail, clarity in implementation, and overall impact make this truly exceptional work. Kudos to @xxsLuna in #11722, @Quazistax in #8935, and @pallaprolus in #9362 for driving this forward—this is a great example of high-quality engineering and meaningful contribution to the project. |
588d81a to
1bb3c22
Compare
621ad1f to
ecd69b0
Compare
…and ID handling Three categories of OpenAI Responses API 400 errors are addressed: 1. "No tool call found for function call output with call_id" — function_call items are now always emitted when tool calls exist (even without fc_ IDs), and orphaned function_call_output items are removed in post-processing. 2. "Item provided without its required 'reasoning' item" — reasoning items without encrypted_content (e.g. from saved sessions) are removed, and the id is stripped from subsequent function_call items so the API doesn't reject them for referencing a missing reasoning item. Trailing reasoning items not followed by a valid successor are also removed. 3. "Expected an ID that begins with 'fc'" — responsesOutputItemIds (which accumulates both msg_ and fc_ IDs during streaming) is now filtered to only fc_-prefixed IDs for function_call items, preventing msg_ IDs from being used where fc_ IDs are required. Co-authored-by: Luna <20552038+xxsLuna@users.noreply.github.com> Co-authored-by: Robert Benko <10097827+Quazistax@users.noreply.github.com> Co-authored-by: pallaprolus <162944051+pallaprolus@users.noreply.github.com>
ecd69b0 to
d71d270
Compare
… converter The tool-call event was re-emitting the full arguments that were already streamed via tool-input-start/delta, causing JSON.parse failures in consumers. Now tool-call only emits extra_content when a Gemini thoughtSignature is present, and returns null otherwise.
There was a problem hiding this comment.
these 2 files were changed because recent community PR CICD didn't run tests on openai adapters and some failures got through
Summary
Fixes three categories of OpenAI Responses API 400 errors (~100+ open issues) in
toResponsesInput(). This is a consolidated implementation of the work done by @xxsLuna in #11722, @Quazistax in #8935, and @pallaprolus in #9362 — credit to them for diagnosing the root causes and proposing the core fixes.What's fixed
function_callitems when tool calls exist, and strip orphanedfunction_call_outputitems in post-processing.encrypted_content(stale sessions), stripidfrom their subsequentfunction_callitems, and remove trailing reasoning without a valid successor.responsesOutputItemIdsto onlyfc_-prefixed IDs, preventingmsg_IDs from leaking intofunction_callitems.Test plan