Skip to content

Drop temperature when LiteLLM rejects it for newer Anthropic models - #80

Merged
lezama merged 2 commits into
trunkfrom
fix/litellm-temperature-noise
Oct 25, 2026
Merged

lezama merged 2 commits into
trunkfrom
fix/litellm-temperature-noise

Conversation

@lezama

@lezama lezama commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

What

Runs against the newest Anthropic models (claude-opus-5-5, claude-sonnet-5-5, claude-fable-5-1) fail on every test. The same happens with gpt-5 and o-series models, which LiteLLM rejects with slightly different wording ("don't support temperature="). LiteLLM 1.96 rejects temperature=0 for these models before the request goes out, with an UnsupportedParamsError: "does not support temperature=0. Only temperature=1 is supported."

wp-bench already drops temperature and retries when Anthropic answers "temperature is deprecated". This error has different text, so the fallback never ran and the error was re-raised. The console fills with LiteLLM's "Give Feedback / Get Help" banner, one per failed test.

Fix

  • Treat both messages as "this model does not take temperature", then drop it and call again.
  • Remember that per model, so later calls skip temperature instead of failing first every time. Records still carry temperature_fallback: true.

Out of scope

  • top_p: LiteLLM rejects it on the same models when set, but the default is unset, so default configs are not affected.
  • Run-level visibility: the result's model block still shows the configured temperature. The per-record temperature_fallback flag is the signal; the frozen-benchmark work in feat: define one public benchmark release contract #78 already excludes those records.

How to test

  • pytest python -q: two new tests in test_models.py. One uses the real LiteLLM exception and checks that only the first call sends temperature. The other checks that an unrelated bad request is still raised.
  • Manually: run any Anthropic model above. Before this change, it fails with UnsupportedParamsError. After it, it runs, and the banner appears once at most.

Workaround until this lands: set temperature: 1 on those models in the config.

🤖 Generated with Claude Code

LiteLLM 1.96 rejects temperature=0 client-side for claude-opus-5-5,
claude-sonnet-5-5 and claude-fable-5-1 with an UnsupportedParamsError
("does not support temperature=0"). The existing fallback only matched
Anthropic's "`temperature` is deprecated" message, so every Anthropic
test failed with a BadRequestError. Match both messages, and remember
the fallback per model so later calls skip the doomed first request.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lezama
lezama requested a review from a team as a code owner October 25, 2026 11:27
@lezama
lezama requested a review from JasonTheAdams October 25, 2026 11:27
@github-actions

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: lezama <migueluy@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

LiteLLM words the same client-side rejection as "don't support
temperature=" for gpt-5 and o-series models. Match both wordings,
document what temperature_fallback now means, and tidy the tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lezama
lezama merged commit 24ce243 into trunk Oct 25, 2026
5 checks passed
@lezama
lezama deleted the fix/litellm-temperature-noise branch October 25, 2026 16:37
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.

1 participant