Skip to content

feat(ai): model + thinking currency — Opus 4.8 default, adaptive thinking (AGENT-1)#140

Merged
eliotlim merged 4 commits into
mainfrom
feat/agent-1-model-thinking-currency
Jul 13, 2026
Merged

feat(ai): model + thinking currency — Opus 4.8 default, adaptive thinking (AGENT-1)#140
eliotlim merged 4 commits into
mainfrom
feat/agent-1-model-thinking-currency

Conversation

@eliotlim

Copy link
Copy Markdown
Owner

What

Modernizes the AI agent loop's model + thinking config. Board: AGENT-1 (Epic: Agent-first-class). Three commits:

  1. feat(ai) — default model claude-sonnet-4-6claude-opus-4-8; raise thinking + max-token budgets (effort.ts); sweep stale model ids in AiSettings/AgentPanel/i18n/ai.spec.ts; add Sonnet 5 to the usage/pricing table.
  2. 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.
  3. 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-14 beta header + temperature shape 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_tokens 400s (use thinking:{type:'adaptive'} + output_config:{effort}), temperature/top_p/top_k 400, and interleaved thinking is automatic (no beta header). Haiku 4.5 / Sonnet 4.5 are legacy budget_tokens and 400 on output_config.effort.

usesAdaptiveThinking(model) — request shape by model

Adaptive (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.effort but we route them legacy without effort — never 400s, just forgoes that optimization on those specific older ids.

Bonus: the non-agent quick paths (tasks() sent temperature: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 verify foreground 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. grep confirms budget_tokens/interleaved-thinking only 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.

eliotlim and others added 3 commits July 13, 2026 09:30
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
@vercel

vercel Bot commented Jul 13, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
app.book.pub Ready Ready Preview, Comment Jul 13, 2026 2:26am

Request Review

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
@eliotlim eliotlim merged commit 0a8d87f into main Jul 13, 2026
10 checks passed
@eliotlim eliotlim deleted the feat/agent-1-model-thinking-currency branch July 13, 2026 02:41
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