Skip to content

fix(models): thinking config for gateway model IDs + new model generations - #302

Merged
philipph-askui merged 1 commit into
mainfrom
fix/thinking-model-id-matching
Jul 31, 2026
Merged

fix(models): thinking config for gateway model IDs + new model generations#302
philipph-askui merged 1 commit into
mainfrom
fix/thinking-model-id-matching

Conversation

@philipph-askui

Copy link
Copy Markdown
Contributor

Why

uses_adaptive_thinking() classifies models by exact claude- prefix match. That breaks in two ways:

  1. Gateway model IDs — Bedrock (anthropic.claude-opus-4-8, us.anthropic.claude-...-v1:0), LiteLLM (anthropic/claude-...), and Vertex (claude-...@date) IDs don't match, fall into the budget_tokens path, and get a 400 on every ≥4.7-generation model (budget_tokens is removed there).
  2. Future models — the adaptive list is an allowlist, so every new Claude release 400s until the list is updated.

Additionally, AndroidAgent hardcodes thinking={"type": "disabled"} + temperature=0.0, both rejected on newer generations (sampling params removed from Opus 4.7 / Sonnet 5 / Fable 5; explicit disabled rejected on Fable 5).

What

  • Normalize before matching: model IDs are reduced to their claude-... core, so gateway wrappers classify like bare IDs.
  • Inverted classification: adaptive is the default; only the frozen legacy budget_tokens families (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.
  • New helpers accepts_sampling_params() (False from Opus 4.7 / Sonnet 5 / Fable 5 onward) and supports_disabled_thinking() (False on Fable 5 / Mythos 5), plus make_non_thinking_settings() used by AndroidAgent — same behavior as before on older models, valid requests on newer ones.
  • EffortLevel gains "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, and xhigh
  • ruff check / ruff format --check clean on changed files
  • askui.android_agent imports cleanly

🤖 Generated with Claude Code

…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>
@philipph-askui
philipph-askui merged commit d422162 into main Jul 31, 2026
1 check passed
@philipph-askui
philipph-askui deleted the fix/thinking-model-id-matching branch July 31, 2026 09:39
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