Repository navigation
fix(llm): skip legacy thinking block for claude-opus-4-8 - #3440
Closed
juanmichelini wants to merge 1 commit into
Closed
juanmichelini wants to merge 1 commit into
juanmichelini wants to merge 1 commit into
Conversation
Opus 4.8 was added to EXTENDED_THINKING_MODELS in #3427 so it would inherit that path's stripping of `temperature` / `top_p`, which Anthropic now rejects for reasoning models. As a side effect, the same path also emits the legacy thinking: {"type": "enabled", "budget_tokens": N} block (plus the `anthropic-beta: interleaved-thinking-2025-05-14` header). Anthropic's API for claude-opus-4-8 now refuses that schema: invalid_request_error: "thinking.type.enabled" is not supported for this model. Use "thinking.type.adaptive" and "output_config.effort" to control thinking behavior. Observed in production via SWE-bench eval runs against `litellm_proxy/anthropic/claude-opus-4-8`: every conversation errored with `LLMBadRequestError` after 4 retries, leaving `output.jsonl` empty and all instances in `output_errors.jsonl` (e.g. eval run 26641824100, request_id `req_011CbX18CQeQxYJ99w7nUorj`). Until the SDK builds the new adaptive schema (`thinking.type=adaptive` + `output_config.effort`), the minimal fix is to omit the legacy block for opus-4-8 while keeping the temp/top_p stripping that's the real reason it's in EXTENDED_THINKING_MODELS. Other extended-thinking models (sonnet-4-5/4-6, haiku-4-5) are unaffected and still get the legacy block, which is what they expect. The opt-out is expressed as a small allow-list (`_MODELS_WITHOUT_LEGACY_THINKING_BLOCK`) in chat_options.py so future Anthropic reasoning models that ship with the same constraint can be added in one line. Tests: - `test_claude_opus_4_8_skips_legacy_thinking_block` pins that opus-4-8 omits the thinking block and beta header even when `extended_thinking_budget` is set, while sonnet-4-5 in the same call still gets both. - Existing `test_claude_opus_4_8_strips_temp_and_top_p` and the thinking-budget clamp tests continue to pass. Co-authored-by: openhands <openhands@all-hands.dev>
Contributor
Python API breakage checks — ✅ PASSEDResult: ✅ PASSED |
Contributor
REST API breakage checks (OpenAPI) — ✅ PASSEDResult: ✅ PASSED |
Collaborator
Author
|
Closing per @juanmichelini — the allow-list approach is more complex than warranted. Replacing with a smaller PR that reverts #3427 and instead drops temperature/top_p via the reasoning-model check that already covers opus-4-7 / opus-4-5. |
Contributor
This was referenced May 29, 2026
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.
Problem
Anthropic's API for
claude-opus-4-8no longer accepts the legacythinking.type=enabled+budget_tokensblock that the SDK emits for every model inEXTENDED_THINKING_MODELS. Every call againstlitellm_proxy/anthropic/claude-opus-4-8errors with:Observed in production via SWE‑bench eval runs:
26608744731(smoke)26618647016(smoke, post‑proxy‑upgrade)litellm.UnsupportedParamsErrorupfront26641824100(smoke, after reverting OpenHands/benchmarks#729)thinking.type.enabledAll instances landed in
output_errors.jsonlwithpatch_len=0, which the eval-monitor dashboard reports as "0% Critic 1 acceptance" — the critic never actually evaluated anything; the LLM call itself failed.Root cause
claude-opus-4-8was added toEXTENDED_THINKING_MODELSin #3427 so it would inherit that branch's stripping oftemperature/top_p(which Anthropic now rejects for reasoning models). The intended payload was the side effect of being in that list; the unintended side effect was that the same code path also emits:That block is correct for
claude-sonnet-4-5/4-6andclaude-haiku-4-5. It is not correct forclaude-opus-4-8, which is a newer reasoning model expecting the adaptive schema (thinking.type=adaptive+output_config.effort).Fix
Minimal: in
chat_options.py, omit the legacy thinking block (and the interleaved‑thinking beta header) for any model in a new small allow‑list:The
temperature/top_pstripping that follows in the same branch — the original reason opus‑4‑8 was added toEXTENDED_THINKING_MODELS— is preserved. Other extended‑thinking models are untouched.Future Anthropic reasoning models that ship with the same constraint can be added to that list in one line. When the SDK is updated to build the new adaptive schema, opus‑4‑8 should be moved off this allow‑list and onto that new path.
Tests
test_claude_opus_4_8_skips_legacy_thinking_block:extended_thinking_budget=4096,max_output_tokens=8192→ nothinkingkey, noanthropic-betaheader,temperatureandtop_pstill stripped.thinking == {"type": "enabled", "budget_tokens": 4096}andanthropic-beta == "interleaved-thinking-2025-05-14", locking in that the opus‑4‑8 skip does not regress other extended‑thinking models.test_claude_opus_4_8_strips_temp_and_top_pand the thinking‑budget‑clamp tests continue to pass (167 passedlocally ontests/sdk/llm/test_chat_options.py+tests/sdk/llm/test_model_features.py).Caveats / follow‑ups
chat_options.pyto build Anthropic's new adaptive schema (thinking: {"type": "adaptive"}+output_config: {"effort": llm.reasoning_effort}) for reasoning models, and route opus‑4‑8 through that. Tracking that as a follow‑up rather than expanding this PR's scope.reasoning_effort/thinkingbefore Anthropic ever sees the request).output.jsonl == 0andoutput_errors.jsonl > 0, the dashboard should surface "all completed instances errored" rather than "0% critic acceptance" — the current label sent us down the wrong rabbit hole during this investigation.This PR was opened by an AI agent (OpenHands) on behalf of @juanmichelini.
@juanmichelini can click here to continue refining the PR
Agent Server images for this PR
• GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server
Variants & Base Images
eclipse-temurin:17-jdknikolaik/python-nodejs:python3.13-nodejs22-slimgolang:1.21-bookwormPull (multi-arch manifest)
# Each variant is a multi-arch manifest supporting both amd64 and arm64 docker pull ghcr.io/openhands/agent-server:828144c-pythonRun
All tags pushed for this build
About Multi-Architecture Support
828144c-python) is a multi-arch manifest supporting both amd64 and arm64828144c-python-amd64) are also available if needed