Skip to content

fix(openai): route reasoning tool calls to Responses API - #38860

Open
Mason Daugherty (mdrxy) wants to merge 2 commits into
masterfrom
mdrxy/openai-route-reasoning-function-tools
Open

fix(openai): route reasoning tool calls to Responses API#38860
Mason Daugherty (mdrxy) wants to merge 2 commits into
masterfrom
mdrxy/openai-route-reasoning-function-tools

Conversation

@mdrxy

@mdrxy Mason Daugherty (mdrxy) commented Jul 15, 2026

Copy link
Copy Markdown
Member

ChatOpenAI now 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. Set use_responses_api=False to 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:

from langchain_openai import ChatOpenAI


def get_weather(city: str) -> str:
    """Get the current weather for a city."""
    return "sunny"


model = ChatOpenAI(model="gpt-5.6-luna")
model_with_tools = model.bind_tools([get_weather])
model_with_tools.invoke("What is the weather in San Francisco?")

Before

Because use_responses_api was 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-none reasoning effort by default, so OpenAI rejected the request:

Function tools with reasoning_effort are not supported for gpt-5.6-luna
in /v1/chat/completions. To use function tools, use /v1/responses or set
reasoning_effort to 'none'.

The developer had to add use_responses_api=True even though the model and payload already determine which endpoint is valid.

After

The same code automatically uses /v1/responses and the function tool works without an endpoint-routing flag. A developer can still set use_responses_api=False to force Chat Completions, for example when also setting reasoning_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-none effort is explicitly configured. Other models and payloads keep their existing route, and explicit use_responses_api=True or False still 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.

@github-actions github-actions Bot added fix For PRs that implement a fix integration PR made that is related to a provider partner package integration internal openai `langchain-openai` package issues & PRs size: M 200-499 LOC labels Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix For PRs that implement a fix integration PR made that is related to a provider partner package integration internal openai `langchain-openai` package issues & PRs size: M 200-499 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant