feat(ai): model + thinking currency — Opus 4.8 default, adaptive thinking (AGENT-1)#140
Merged
Merged
Conversation
Retire the stale claude-sonnet-4-6 default across the Anthropic engine, pricing table, settings/agent UI, and docs; the agent now defaults to claude-opus-4-8 while staying user-configurable (opus-4-8 / sonnet-5 / haiku-4-5). - providers.ts: DEFAULT_MODEL -> claude-opus-4-8; raise the max_tokens fallback 1024 -> 4096; send the interleaved-thinking-2025-05-14 beta header when thinking is active so the model can reason between tool calls (thinking config + tools array already ride the same request). - effort.ts: raise thinking budgets 256/1024/4096 -> 2048/8192/16384 and maxTokens 600/900/1400 -> 4000/8000/16000; every tier now clears the >=1024 gate so thinking scales with effort instead of switching off. - usage.ts: retarget the $3/$15 sonnet pricing row to claude-sonnet-5. - UI/SDK: AiSettings placeholder + AgentPanel preset + i18n hint + sdk doc example refreshed; ai.spec placeholder matcher updated. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KFk2T9k3p7ghCjdzMfkA5w
The AGENT-1 default (Opus 4.8) can't take the legacy extended-thinking
shape: `thinking:{type:'enabled',budget_tokens}`, `temperature`, and the
`interleaved-thinking-2025-05-14` beta header all return HTTP 400 on
Opus 4.7+. Choose the request shape by target model instead.
- usesAdaptiveThinking(model): current-gen (opus-4-7/4-8, sonnet-5,
haiku-4-5, fable/mythos-5) and unknown ids → adaptive; only known
budget_tokens families (claude-3*, opus-4-0..4-6, sonnet-4-*) → legacy.
- Adaptive path: `thinking:{type:'adaptive'}` + `output_config.effort`
(low/med/high → low/medium/high); no budget_tokens, no temperature/
top_p/top_k, no interleaved beta header (interleave is automatic). This
also fixes the quick-call paths (e.g. tasks()) that sent temperature.
- Legacy path unchanged: enabled+budget_tokens (≥1024 gate) + interleaved
beta + explicit temperature — back-compat for older pinned models.
- Tests: assert both request bodies (Opus 4.8 → adaptive, Sonnet 4.5 →
enabled) + the classifier. Tool-execution loop untouched.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KFk2T9k3p7ghCjdzMfkA5w
Haiku 4.5 uses the legacy extended-thinking shape (budget_tokens, and
temperature is allowed) but REJECTS output_config.effort ("This model
does not support the effort parameter") — so the adaptive fall-through
would 400 it. Add a `/^claude-haiku-4-/` legacy rule so Haiku 4.x takes
the enabled+budget_tokens path (Haiku 3.x is already caught by claude-3*).
Also documents the intentional residual near the predicate: Opus 4.5/4.6
and Sonnet 4.6 accept effort but we route them legacy and send
budget_tokens without effort (never 400s; just forgoes the effort
optimization on those older ids). Adds a Haiku-4.5 legacy body-shape test.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KFk2T9k3p7ghCjdzMfkA5w
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Review nits on the AGENT-1 stack: - Anchor the Opus legacy regex with (?![0-9]) so only single-digit minor versions 0-6 match — a hypothetical claude-opus-4-10..4-16 must not be dragged legacy by a leading digit. Opus 4.0's ids (the claude-opus-4-0 alias and dated claude-opus-4-20250514 snapshot) no longer fit that pattern, so classify them explicitly. - Add the highest-fidelity adaptive test: the real agent path passes a temperature from the effort profile alongside thinkingBudget>=1024 on Opus 4.8; assert the adaptive+thinking-on branch drops temperature/ top_p/top_k/budget_tokens and keeps output_config.effort. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KFk2T9k3p7ghCjdzMfkA5w
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.
What
Modernizes the AI agent loop's model + thinking config. Board: AGENT-1 (Epic: Agent-first-class). Three commits:
feat(ai)— default modelclaude-sonnet-4-6→claude-opus-4-8; raise thinking + max-token budgets (effort.ts); sweep stale model ids inAiSettings/AgentPanel/i18n/ai.spec.ts; add Sonnet 5 to the usage/pricing table.fix(ai)— model-aware request shape (the important one): Opus 4.7/4.8 (and current-gen) use adaptive thinking; older models keep the legacy shape.fix(ai)— classify Haiku 4.5 as legacy.Why the shape change (verified against live Anthropic docs)
The originally-implemented
thinking:{type:'enabled', budget_tokens}+interleaved-thinking-2025-05-14beta header +temperatureshape returns HTTP 400 on Opus 4.8 — server tests mock the transport, so it was false-green. Confirmed against docs: on Opus 4.7+/4.8,budget_tokens400s (usethinking:{type:'adaptive'}+output_config:{effort}),temperature/top_p/top_k400, and interleaved thinking is automatic (no beta header). Haiku 4.5 / Sonnet 4.5 are legacybudget_tokensand 400 onoutput_config.effort.usesAdaptiveThinking(model)— request shape by modelAdaptive (
thinking:{type:'adaptive'}+output_config.effort, no sampling params, no beta header): Opus 4.7/4.8, Sonnet 5, Fable/Mythos 5, and unknown ids.Legacy (
thinking:{type:'enabled', budget_tokens}, temperature allowed, interleaved header):claude-3*, Opus 4.0–4.6, Sonnet 4.x, Haiku 4.x.Documented residual (comment in code): Opus 4.5/4.6 + Sonnet 4.6 do accept
output_config.effortbut we route them legacy without effort — never 400s, just forgoes that optimization on those specific older ids.Bonus: the non-agent quick paths (
tasks()senttemperature:0.4,complete(), streaming route) were also 400-prone on Opus 4.8 — the adaptive path drops sampling params for current models, fixing those too.Tests
pnpm verifyforeground green: sdk 188, ui 981, server 658/658 (incl. new body-shape tests asserting current→adaptive body and legacy(incl. Haiku 4.5)→enabled+budget_tokens body), server+mcp e2e 40/40.grepconfirmsbudget_tokens/interleaved-thinkingonly appear on the legacy path.Note
CI shard 2/4 (
database-timeline.spec.ts) is red for an unrelated pre-existing date time-bomb being fixed separately (green-main issue); goes green on re-run once that lands. No agent-path change here touches timeline.