Skip to content

fix(openai): bridge gpt-5.6+ with tools to /v1/responses even without reasoning_effort - #33237

Closed
unfitcoder101 wants to merge 3 commits into
BerriAI:litellm_internal_stagingfrom
unfitcoder101:fix/gpt56-tools-responses-bridge
Closed

fix(openai): bridge gpt-5.6+ with tools to /v1/responses even without reasoning_effort#33237
unfitcoder101 wants to merge 3 commits into
BerriAI:litellm_internal_stagingfrom
unfitcoder101:fix/gpt56-tools-responses-bridge

Conversation

@unfitcoder101

Copy link
Copy Markdown

Problem

gpt-5.6 family models (gpt-5.6-sol, gpt-5.6-luna, gpt-5.6-terra) fail with:

Function tools with reasoning_effort are not supported for gpt-5.6-sol in /v1/chat/completions

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_check in main.py only bridged to /v1/responses when reasoning_effort is not None. For gpt-5.4+ models with tools, the bridge should fire unconditionally since the model family requires /v1/responses for tool calls regardless of whether the caller sets reasoning_effort.

Fix

Removed the reasoning_effort is not None gate from the gpt-5.4+ + tools path. The condition now bridges when:

  • reasoning_effort + reasoning_summary are both explicitly set (original behavior for older models), OR
  • model is gpt-5.4+ AND tools are present (new, unconditional for this family)

Test

Added tests/test_litellm/test_gpt56_bridge.py covering all four gpt-5.6 variants.

Fixes #33221

… 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-apps

greptile-apps Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR modifies responses_api_bridge_check in main.py to route gpt-5.6 family models with tools to /v1/responses even when reasoning_effort is not explicitly set, fixing a server-side rejection error for that model family. A new unit test covering the four gpt-5.6 variants is added.

  • The condition change removes reasoning_effort is not None from the gpt-5.4+ tools branch, so any gpt-5.4+ model called with tools but without reasoning_effort now routes to the responses API — this widens the scope beyond gpt-5.6 and may silently reroute existing gpt-5.4/5.5 callers.
  • The inline comment above the condition still describes the pre-fix logic and should be updated.
  • Test coverage is limited to gpt-5.6 with no negative cases or gpt-5.4/5.5 assertions.

Confidence Score: 3/5

The 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 is_model_gpt_5_4_plus_model covers gpt-5.4 and gpt-5.5 as well, and there is no confirmation that those versions share the same restriction. A user relying on gpt-5.4 with tools on chat completions today would find their calls silently rerouted without any opt-out.

litellm/main.py — specifically the widened is_model_gpt_5_4_plus_model gate and the now-stale comment block above it.

Important Files Changed

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)

  1. litellm/main.py, line 1005-1011 (link)

    P2 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 of reasoning_effort.

Reviews (1): Last reviewed commit: "fix(openai): bridge gpt-5.6+ with tools ..." | Re-trigger Greptile

Comment thread litellm/main.py
Comment on lines +1017 to +1020
and (
(reasoning_effort is not None and reasoning_summary is not None)
or (OpenAIGPT5Config.is_model_gpt_5_4_plus_model(model) and tools)
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 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)

Comment on lines +5 to +9
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"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 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

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@unfitcoder101

Copy link
Copy Markdown
Author

@greptile-apps Thanks for the review.

On the gpt-5.4/5.5 scope concern: the original issue (#23156)
confirms this same restriction applies to gpt-5.4 — function tools

  • reasoning_effort on /v1/chat/completions was already broken there.
    gpt-5.5 follows the same model family pattern. The existing comment
    above the condition already documents this ("gpt-5.4+: tools +
    reasoning_effort") — the bug was that the guard required the caller
    to explicitly pass reasoning_effort even though OpenAI applies it
    server-side.

Will update the inline comment and add negative-case tests
(gpt-5.1 with tools should NOT bridge) in the next commit.

@greptile-apps

greptile-apps Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Thanks for the context. The explanation makes sense — if OpenAI applies reasoning_effort server-side for this model family, requiring callers to set it explicitly was a bug in the bridge guard.

Two things remain before this is ready:

  1. The logic change tightened the first branch unintentionally. Before:

    reasoning_effort is not None
    and (reasoning_summary is not None or (is_gpt_5_4_plus and tools))
    

    After:

    (reasoning_effort is not None and reasoning_summary is not None)
    or (is_gpt_5_4_plus and tools)
    

    Now both reasoning_effort AND reasoning_summary must be set for non-gpt-5.4+ models to bridge. If a user passes only reasoning_effort (no reasoning_summary) on a gpt-5.0/5.1 model, they'll silently stop bridging. Was that intentional?

  2. Test coverage is still only the happy path. The promised negative-case test (gpt-5.1 with tools should NOT bridge) is still needed to guard against future regressions that accidentally widen the scope.

Tip: You can customize Greptile's behavior for this repo with .greptile/rules.md and .greptile/config.json.

@unfitcoder101

Copy link
Copy Markdown
Author

@greptile-apps Thanks for the review.

On the gpt-5.4/5.5 scope concern: the original issue (#23156) confirms
this same restriction applies to gpt-5.4 — function tools + reasoning_effort
on /v1/chat/completions was already broken there. gpt-5.5 follows the same
model family pattern. The bug was that the guard required the caller to
explicitly pass reasoning_effort even though OpenAI applies it server-side.

Updated in latest commit:

  • Fixed the inline comment to reflect the new behaviour
  • Added negative-case test confirming gpt-5, gpt-5.1, gpt-5.3 with tools
    do NOT bridge without reasoning_effort

@greptile-apps

greptile-apps Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

The logic change is sound and the developer's explanation holds up. The boolean restructuring is correct:

  • Old: reasoning_effort is not None AND (reasoning_summary is not None OR (is_5_4_plus AND tools))
  • New: (reasoning_effort is not None AND reasoning_summary is not None) OR (is_5_4_plus AND tools)

The negative-case test covering gpt-5, gpt-5.1, gpt-5.3 is the right addition. That addresses the scope concern.

One minor issue — the updated comment has a formatting artifact:

# - # - gpt-5.4+: tools alone (OpenAI applies reasoning_effort server-side, making

The # - # - double-prefix looks like a copy-paste error from the old comment. Should be:

    # - gpt-5.4+: tools alone (OpenAI applies reasoning_effort server-side, making

Logic and tests look good otherwise.

@codspeed-hq

codspeed-hq Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing unfitcoder101:fix/gpt56-tools-responses-bridge (d646b9b) with litellm_internal_staging (93b5ca9)

Open in CodSpeed

@unfitcoder101

Copy link
Copy Markdown
Author

@mvrodrig thanks for following up and testing.

The fix is in PR #33237 — conflict was resolved and all checks
pass. The PR has been waiting on maintainer review since submission.

@krrish-berri-2 / @ishaan-jaff — any chance this can get a
review pass? The reporter has confirmed it still reproduces on
v1.93.0 and is ready to test the fix.

@devin-ai-integration

Copy link
Copy Markdown
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Function tools fail with reasoning_effort error for OpenAI gpt-5.6 family models (gpt-5.6-sol/luna/terra) on /chat/completions

1 participant