fix(models): thinking config for gateway model IDs + new model generations - #302
Merged
Merged
Conversation
…del generations - thinking.py now normalizes model IDs to their claude- core, so Bedrock (anthropic.claude-..., us.anthropic....-v1:0), LiteLLM (anthropic/claude-...), and Vertex (claude-...@Date) IDs classify like bare IDs instead of falling into the budget_tokens path (400 on >=4.7 generation models). - Inverted classification: adaptive thinking is the default; only the frozen legacy budget_tokens families (2.x/3.x, Haiku 4.5, Sonnet 4/4.5, Opus 4/4.1/4.5) keep the integer budget, so unknown future Claude models work by default. - New accepts_sampling_params() / supports_disabled_thinking() helpers; AndroidAgent act defaults now use make_non_thinking_settings(), which drops temperature on models that reject sampling params (Opus 4.7+, Sonnet 5, Fable 5) and omits thinking "disabled" on always-on models (Fable 5 / Mythos 5). - EffortLevel gains "xhigh" (supported from the Opus 4.7 generation on). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Why
uses_adaptive_thinking()classifies models by exactclaude-prefix match. That breaks in two ways:anthropic.claude-opus-4-8,us.anthropic.claude-...-v1:0), LiteLLM (anthropic/claude-...), and Vertex (claude-...@date) IDs don't match, fall into thebudget_tokenspath, and get a 400 on every ≥4.7-generation model (budget_tokensis removed there).Additionally,
AndroidAgenthardcodesthinking={"type": "disabled"}+temperature=0.0, both rejected on newer generations (sampling params removed from Opus 4.7 / Sonnet 5 / Fable 5; explicitdisabledrejected on Fable 5).What
claude-...core, so gateway wrappers classify like bare IDs.budget_tokensfamilies (2.x/3.x, Haiku 4.5, Sonnet 4/4.1/4.5, Opus 4/4.1/4.5) keep the integer budget. Unknown future models work by default.accepts_sampling_params()(False from Opus 4.7 / Sonnet 5 / Fable 5 onward) andsupports_disabled_thinking()(False on Fable 5 / Mythos 5), plusmake_non_thinking_settings()used byAndroidAgent— same behavior as before on older models, valid requests on newer ones.EffortLevelgains"xhigh"(supported from the Opus 4.7 generation onward; recommended for agentic use).Notes
The C# SDK carries a port of this module; the mirroring fix is askui/csharp-sdk#16 — the two should land in step to keep parity.
Test plan
pytest tests/unit/models/test_thinking.py— 54 passed, including new matrices for Bedrock/LiteLLM/Vertex ID shapes, sampling/disabled-thinking classification,make_non_thinking_settings()per generation, andxhighruff check/ruff format --checkclean on changed filesaskui.android_agentimports cleanly🤖 Generated with Claude Code