fix(openai): bridge gpt-5.6+ with tools to /v1/responses even without reasoning_effort - #33237
Conversation
… reasoning_effort gpt-5.6 family models fail on /v1/chat/completions when function tools are present because OpenAI applies a default reasoning_effort server-side. Bridge to /v1/responses unconditionally for is_model_gpt_5_4_plus_model with tools. Fixes: BerriAI#33221
Greptile SummaryThis PR modifies
Confidence Score: 3/5The fix is correct for gpt-5.6 but the widened condition affects all gpt-5.4+ models — any existing callers using gpt-5.4/5.5 with tools and without reasoning_effort will be silently rerouted to the responses API without evidence they were broken on chat completions. The core logic change is intentional and the test confirms the gpt-5.6 case works. The concern is that litellm/main.py — specifically the widened
|
| Filename | Overview |
|---|---|
| litellm/main.py | Removes reasoning_effort != None guard from the gpt-5.4+ tools path; fixes gpt-5.6 but silently reroutes gpt-5.4/5.5 tool calls from chat completions to responses API without evidence that the same restriction applies to those models. |
| tests/test_litellm/test_gpt56_bridge.py | New mock-only unit test looping over four gpt-5.6 variants; correct use of the existing bridge-check helper, no network calls, but lacks negative cases and coverage for gpt-5.4/5.5. |
Comments Outside Diff (1)
-
litellm/main.py, line 1005-1011 (link)The inline comment above the condition still describes the old behaviour (tools required
reasoning_effort), but the new logic bridges gpt-5.4+ to responses API whenever tools are present, regardless ofreasoning_effort.
Reviews (1): Last reviewed commit: "fix(openai): bridge gpt-5.6+ with tools ..." | Re-trigger Greptile
| and ( | ||
| (reasoning_effort is not None and reasoning_summary is not None) | ||
| or (OpenAIGPT5Config.is_model_gpt_5_4_plus_model(model) and tools) | ||
| ) |
There was a problem hiding this comment.
Bridge silently reroutes gpt-5.4 and gpt-5.5 models with tools
is_model_gpt_5_4_plus_model returns True for all gpt-5.4, 5.5, and 5.6+ models. Before this change, those same models required reasoning_effort != None before tools triggered the bridge; any user already calling gpt-5.4 or gpt-5.5 with tools but without reasoning_effort was successfully landing on chat completions. After this change, all those calls are silently rerouted to the responses API, which may have different parameter semantics or reject fields that chat completions accepted. The PR description only confirms the failure on gpt-5.6; if the same /v1/chat/completions restriction doesn't apply to gpt-5.4 and gpt-5.5, this is a backwards-incompatible change for those users.
Rule Used: What: avoid backwards-incompatible changes without... (source)
| def test_gpt56_tools_bridged_to_responses_without_reasoning_effort(): | ||
| tools = [{"type": "function", "function": {"name": "get_weather", "description": "Get weather", "parameters": {"type": "object", "properties": {"location": {"type": "string"}}, "required": ["location"]}}}] | ||
| for model in ["gpt-5.6-sol", "gpt-5.6-luna", "gpt-5.6-terra", "gpt-5.6"]: | ||
| model_info, _ = responses_api_bridge_check(model=model, custom_llm_provider="openai", tools=tools, reasoning_effort=None) | ||
| assert model_info.get("mode") == "responses", f"{model} with tools should bridge to responses even without reasoning_effort" |
There was a problem hiding this comment.
Missing negative-case and gpt-5.4/5.5 coverage
The single test only asserts that gpt-5.6 variants are bridged. There are no tests for: (a) gpt-5.4 / gpt-5.5 models with tools and no reasoning_effort — these are now also bridged by the changed condition; (b) a negative case confirming that older gpt-5 models (e.g. gpt-5, gpt-5.1) with tools but without reasoning_effort are NOT bridged; (c) gpt-5.6 with reasoning_effort and reasoning_summary still being bridged (regression check for the explicit-effort path).
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
@greptile-apps Thanks for the review. On the gpt-5.4/5.5 scope concern: the original issue (#23156)
Will update the inline comment and add negative-case tests |
|
Thanks for the context. The explanation makes sense — if OpenAI applies Two things remain before this is ready:
Tip: You can customize Greptile's behavior for this repo with |
|
@greptile-apps Thanks for the review. On the gpt-5.4/5.5 scope concern: the original issue (#23156) confirms Updated in latest commit:
|
|
The logic change is sound and the developer's explanation holds up. The boolean restructuring is correct:
The negative-case test covering One minor issue — the updated comment has a formatting artifact: The Logic and tests look good otherwise. |
|
@mvrodrig thanks for following up and testing. The fix is in PR #33237 — conflict was resolved and all checks @krrish-berri-2 / @ishaan-jaff — any chance this can get a |
|
Closing in favor of #34043. Same fix for #33221 but scoped to gpt-5.6+ only: staging pins gpt-5.4/5.5 tools-only on Chat Completions (test_responses_api_bridge_check_gpt_5_4_tools_without_reasoning_stays_chat), which this PR's gpt-5.4+ widening regressed. #34043 adds is_model_gpt_5_6_plus_model and keeps 5.4/5.5 on chat. Thanks for the report and the fix here. |
Problem
gpt-5.6 family models (gpt-5.6-sol, gpt-5.6-luna, gpt-5.6-terra) fail with:
when function tools are passed without explicitly setting
reasoning_effort. OpenAI applies a default reasoning_effort server-side for this model family, which makes tools incompatible with/v1/chat/completions.Root cause
responses_api_bridge_checkinmain.pyonly bridged to/v1/responseswhenreasoning_effort is not None. For gpt-5.4+ models with tools, the bridge should fire unconditionally since the model family requires/v1/responsesfor tool calls regardless of whether the caller setsreasoning_effort.Fix
Removed the
reasoning_effort is not Nonegate from the gpt-5.4+ + tools path. The condition now bridges when:reasoning_effort+reasoning_summaryare both explicitly set (original behavior for older models), ORTest
Added
tests/test_litellm/test_gpt56_bridge.pycovering all four gpt-5.6 variants.Fixes #33221