Repository navigation
fix(llm): strip temperature/top_p for claude-opus-4-8 - #3427
Conversation
Anthropic's claude-opus-4-8 is a reasoning-only model that rejects
requests carrying `temperature` (and `top_p`) with:
AnthropicException - {"type":"error","error":{
"type":"invalid_request_error",
"message":"`temperature` is deprecated for this model."
}}
The model isn't yet flagged as supporting `reasoning_effort` by
litellm's `get_supported_openai_params`, so the reasoning-effort branch
in `select_chat_options` doesn't strip those params. Benchmark configs
(e.g. SWE-bench) that explicitly set `temperature=0.0` therefore fail
with a 400 on every call.
Add `claude-opus-4-8` to `EXTENDED_THINKING_MODELS` so it goes
through the extended-thinking path, which already strips temperature/top_p
and enables the thinking-budget header — consistent with how
claude-sonnet-4-6 and claude-haiku-4-5 are handled.
Co-authored-by: openhands <openhands@all-hands.dev>
Python API breakage checks — ✅ PASSEDResult: ✅ PASSED |
REST API breakage checks (OpenAPI) — ✅ PASSEDResult: ✅ PASSED |
|
✅ Review complete. This review was performed through OpenHands Cloud Automation. You can log in and view the conversation here. |
all-hands-bot
left a comment
There was a problem hiding this comment.
Review: fix(llm): strip temperature/top_p for claude-opus-4-8
Clean, well-scoped fix. The approach — routing claude-opus-4-8 through the EXTENDED_THINKING_MODELS path — is the right lever to strip temperature/top_p before the Anthropic API sees them, and it is consistent with how other extended-thinking models are handled in this codebase.
What's well done:
- Comment in
EXTENDED_THINKING_MODELSclearly distinguishes the reason for includingclaude-opus-4-8(API constraint: Anthropic rejects these params) from the reason other models appear here (performance). Future maintainers will not be confused about why this model is on the list. test_claude_opus_4_8_strips_temp_and_top_pvalidates the actual end-to-end behavior (select_chat_optionsoutput) with the realisticlitellm_proxy/anthropic/claude-opus-4-8identifier used by SWE-bench runs.test_extended_thinking_supportadditions cover three model-name variants (bare,anthropic/-prefixed,litellm_proxy/anthropic/-prefixed) and explicitly addclaude-opus-4-7as a negative case — a good regression guard.
Minor follow-up (out of scope for this PR): claude-opus-4-8 was already added to PROMPT_CACHE_MODELS before this change, but test_prompt_cache_support has no case for it. A follow-up test row there would close that coverage gap.
Overall, the change is minimal, well-documented, and well-tested. ✅
This review was generated by an AI agent (OpenHands) on behalf of the user through OpenHands Automation. View conversation
all-hands-bot
left a comment
There was a problem hiding this comment.
✅ QA Report: PASS
The SDK now removes temperature and top_p from real LLM.completion() requests for litellm_proxy/anthropic/claude-opus-4-8.
Does this PR achieve its stated goal?
Yes. I reproduced the pre-PR behavior by running an actual SDK LLM.completion() call against a local capture endpoint: the outgoing chat-completions payload included temperature: 0.0 and top_p: 1.0. After applying the PR head, the same call succeeded and the captured payload contained only messages and model, so the deprecated Anthropic sampling fields are no longer forwarded for the target model.
| Phase | Result |
|---|---|
| Environment Setup | ✅ make build completed successfully and installed the repo environment. |
| CI Status | cleanup-on-approval failed and a qa-changes run still in progress/cancelled. |
| Functional Verification | ✅ Real SDK completion path exercised with before/after payload capture. |
Functional Verification
Test 1: Claude Opus 4.8 no longer forwards deprecated sampling parameters
Step 1 — Reproduce / establish baseline without the fix:
Checked out the PR base commit e65a8abd1f86726b4ea11714311d20b879ed42cb, started a local HTTP capture server, and ran an actual SDK completion configured like the reported SWE-bench path:
git switch --detach e65a8abd1f86726b4ea11714311d20b879ed42cb
OPENHANDS_SUPPRESS_BANNER=1 uv run python <capture LLM.completion script>Observed output:
completion_return_type= LLMResponse
{"git_ref": "e65a8abd (pre-PR)", "has_temperature": true, "has_thinking": false, "has_top_p": true, "request_keys": ["messages", "model", "temperature", "top_p"], "request_path": "/chat/completions", "temperature": 0.0, "thinking": null, "top_p": 1.0}This confirms the bug boundary: the SDK forwarded temperature and top_p for litellm_proxy/anthropic/claude-opus-4-8, matching the Anthropic rejection described in the PR.
Step 2 — Apply the PR's changes:
Checked out PR head f6e465fa490b1f7eb752fcad3b29232ad65d4f39.
Step 3 — Re-run with the fix in place:
Ran the same SDK completion capture command:
git switch --detach f6e465fa490b1f7eb752fcad3b29232ad65d4f39
OPENHANDS_SUPPRESS_BANNER=1 uv run python <same capture LLM.completion script>Observed output:
completion_return_type= LLMResponse
{"git_ref": "f6e465fa (PR head)", "has_temperature": false, "has_thinking": false, "has_top_p": false, "request_keys": ["messages", "model"], "request_path": "/chat/completions", "temperature": null, "thinking": null, "top_p": null}This shows the fix works for the reported user path: the same real SDK completion call no longer sends the deprecated parameters.
Test 2: Stripping also occurs when no thinking budget is configured
On PR head, I repeated the completion capture with temperature=0.0 and top_p=1.0 but without extended_thinking_budget:
{"has_temperature": false, "has_top_p": false, "request_keys": ["messages", "model"]}This confirms the model-specific stripping applies even outside the benchmark-specific thinking-budget configuration.
Issues Found
None.
This review was created by an AI agent (OpenHands) on behalf of the user.
|
anthropic/claude-opus-4-8 is an "adaptive thinking" model (all Claude 4.6+) that require So this PR basically broke the support for anthropic/claude-opus-4-8 |
|
I have tested it, it does not work:
|
#3441) Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: openhands <openhands@all-hands.dev>
…nds#3427)" (OpenHands#3441) Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: openhands <openhands@all-hands.dev>
…nds#3427)" (OpenHands#3441) Co-authored-by: openhands <openhands@all-hands.dev>
Problem
Anthropic's
claude-opus-4-8is a reasoning-only model that rejects requests carryingtemperature(ortop_p) with:This breaks SWE-bench evaluation runs against the model — every conversation fails with
LLMBadRequestError. Example:swebench/litellm_proxy-anthropic-claude-opus-4-8/26604804421— all 3 critic attempts × all retries produced the same 400 from Anthropic.Why the existing logic doesn't catch it
select_chat_optionsalready stripstemperature/top_pin two places:The reasoning-effort path — gated on
_supports_reasoning_effort(), which delegates to litellm'sget_supported_openai_params. Today litellm reportsreasoning_effort: Falseforclaude-opus-4-8(and eventemperature: Truefor theanthropic/...form), so this branch doesn't fire:The extended-thinking path — gated on
EXTENDED_THINKING_MODELS, butclaude-opus-4-8wasn't on the list.Result: benchmark configs that explicitly set
temperature=0.0(e.g. SWE-benchlitellm_extra_body) get the value forwarded and Anthropic rejects it.The SDK integration tests in run
26599152082didn't surface the issue because they leaveLLM.temperatureat its defaultNone— so nothing was ever sent.Fix
Add
claude-opus-4-8toEXTENDED_THINKING_MODELS. That routes it through the path already used forclaude-sonnet-4-6/claude-haiku-4-5, which:temperatureandtop_pfrom the outgoing request, andextended_thinking_budgetis configured (which the SWE-bench config already does:extended_thinking_budget=200000).Changes
openhands-sdk/openhands/sdk/llm/utils/model_features.py— one entry added toEXTENDED_THINKING_MODELSwith an explanatory comment.tests/sdk/llm/test_model_features.py— extend the parametrizedtest_extended_thinking_supportto cover bare,anthropic/andlitellm_proxy/anthropic/forms ofclaude-opus-4-8, plus a negative forclaude-opus-4-7.tests/sdk/llm/test_chat_options.py— newtest_claude_opus_4_8_strips_temp_and_top_pmirroring the existing sonnet-4-6 regression test.Validation
Targeted tests pass locally:
(Other failures observed in the broader
tests/sdk/llm/run are pre-existing environment issues — missingpytest-asyncioetc. — unrelated to this change.)Follow-ups (not in this PR)
temperature/top_pwheneverreasoning_effortorextended_thinking_budgetis configured on an Anthropic model, so future reasoning-only Anthropic releases don't need a one-off entry here. Happy to do that as a separate PR if maintainers want it.This PR was created by an AI agent (OpenHands) on behalf of the user.
@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:f6e465f-pythonRun
All tags pushed for this build
About Multi-Architecture Support
f6e465f-python) is a multi-arch manifest supporting both amd64 and arm64f6e465f-python-amd64) are also available if needed