fix(openai): route reasoning tool calls to Responses API - #38860
Open
Mason Daugherty (mdrxy) wants to merge 2 commits into
Open
fix(openai): route reasoning tool calls to Responses API#38860Mason Daugherty (mdrxy) wants to merge 2 commits into
Mason Daugherty (mdrxy) wants to merge 2 commits into
Conversation
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.
ChatOpenAInow automatically routes GPT-5.6 function-tool requests, and GPT-5.4 or GPT-5.5 function-tool requests with reasoning enabled, through the Responses API to avoid unsupported Chat Completions payloads. Setuse_responses_api=Falseto continue forcing Chat Completions.User story
A developer wants to build a small weather assistant with GPT-5.6 Luna and an ordinary function tool:
Before
Because
use_responses_apiwas not set and ordinary function tools did not trigger Responses API inference, LangChain sent the request to/v1/chat/completions. GPT-5.6 uses a non-nonereasoning effort by default, so OpenAI rejected the request:The developer had to add
use_responses_api=Trueeven though the model and payload already determine which endpoint is valid.After
The same code automatically uses
/v1/responsesand the function tool works without an endpoint-routing flag. A developer can still setuse_responses_api=Falseto force Chat Completions, for example when also settingreasoning_effort="none".OpenAI supports GPT-5.6 models on both Chat Completions and Responses, so the model is not treated as Responses-only. Instead, endpoint inference accounts for the model, function tools, and reasoning effort together: GPT-5.6 function-tool requests use Responses unless
reasoning_effort="none"; GPT-5.4 and GPT-5.5 do so only when a non-noneeffort is explicitly configured. Other models and payloads keep their existing route, and explicituse_responses_api=TrueorFalsestill wins. Sync and async streaming use the same complete request defaults when selecting the endpoint.The routing matrix was verified against the live OpenAI API and is covered for affected and unaffected model families, payload shapes, explicit overrides, and streaming dispatch.