Skip to content

fix(openai): fix Responses API 400 errors for reasoning, tool calls, and ID handling#11785

Merged
RomneyDa merged 3 commits intomainfrom
dallin/openai-issues
Mar 25, 2026
Merged

fix(openai): fix Responses API 400 errors for reasoning, tool calls, and ID handling#11785
RomneyDa merged 3 commits intomainfrom
dallin/openai-issues

Conversation

@RomneyDa
Copy link
Collaborator

@RomneyDa RomneyDa commented Mar 24, 2026

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

Test plan

  • 22 unit tests covering all three fix categories
  • Manual testing with GPT-5/o4-mini in agent mode with tool use
  • Manual testing with saved/resumed sessions containing reasoning
  • Manual testing with parallel tool calls

@RomneyDa RomneyDa requested a review from a team as a code owner March 24, 2026 21:59
@RomneyDa RomneyDa requested review from Patrick-Erichsen and removed request for a team March 24, 2026 21:59
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Mar 24, 2026
@continue
Copy link
Contributor

continue bot commented Mar 24, 2026

Documentation Review

No documentation updates are needed for this PR.

Rationale: This PR contains internal bug fixes in core/llm/openaiTypeConverters.ts that resolve OpenAI Responses API 400 errors. The changes:

  • Fix internal type conversion logic for tool calls, reasoning items, and ID handling
  • Operate transparently to users without requiring any configuration changes
  • Don't introduce new user-facing options, settings, or behaviors

Users will automatically benefit from these fixes when using OpenAI models with tool calling and reasoning capabilities—no documentation changes required.

@RomneyDa RomneyDa force-pushed the dallin/openai-issues branch from 43f9931 to 690d98f Compare March 24, 2026 22:03
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

@RomneyDa RomneyDa force-pushed the dallin/openai-issues branch from 690d98f to 588d81a Compare March 24, 2026 22:11
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Mar 24, 2026
@gdkgloballlc
Copy link

gdkgloballlc commented Mar 24, 2026

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.

…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>
… 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.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these 2 files were changed because recent community PR CICD didn't run tests on openai adapters and some failures got through

@github-project-automation github-project-automation bot moved this from Todo to In Progress in Issues and PRs Mar 25, 2026
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Mar 25, 2026
@RomneyDa RomneyDa merged commit 02525d1 into main Mar 25, 2026
104 of 110 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in Issues and PRs Mar 25, 2026
@RomneyDa RomneyDa deleted the dallin/openai-issues branch March 25, 2026 01:55
@github-actions github-actions bot locked and limited conversation to collaborators Mar 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

lgtm This PR has been approved by a maintainer size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants