Contents

Adaptive Thinking and Tiered Model Routing

First-generation LLM routing was one-dimensional: send simple prompts to a small model, send hard prompts to a flagship model, or guess a static budget_tokens cap for reasoning. By late 2026—with Anthropic’s Claude Haiku 5.5 and Claude Fable 5.2 supporting Adaptive Thinking plus output_config.effort, and Google’s Gemini 4 Neon exposing four explicit thinking depths—production routing has become a two-dimensional policy: model tier × reasoning effort.

Output pricing now spans 80x from Claude Haiku 5.5’s short-prompt tier ($0.50/MTok for prompts ≤ 100,000 input tokens) to Claude Fable 5.2 ($40.00/MTok)—and 16x once Haiku 5.5 crosses into its long-prompt tier ($2.50/MTok for > 100,000 input tokens). Because internal reasoning tokens generated during adaptive thinking bill as output tokens, an unbounded retry loop or an accidental jump past 100K input tokens can quickly distort monthly spend.

From Static budget_tokens to Adaptive Thinking

Hardcoding a fixed budget_tokens value always forced a bad trade-off: too low truncates hard debugging mid-thought; too high burns seconds on trivial formatting. Newer model families replace rigid budgets with per-turn adaptive reasoning guided by an effort dial, though constraints differ sharply across models:

  • Anthropic Claude 5.5 / 5.2 (Thinking Guide, Effort Guide): Pass thinking: { type: "adaptive" } and guide depth via output_config.effort (low, medium, high, xhigh, max). Disable rules vary by model:
    • claude-opus-5-5 and claude-fable-5-2: adaptive thinking is always on; passing disabled returns HTTP 400.
    • claude-sonnet-5-5: also rejects disabled; supports between_tools at low, medium, and high.
    • claude-haiku-5-5: accepts disabled only at high and below.
  • Google Gemini 4 Neon (Google Cloud Model Guide): Direct API calls expose a 1,048,576 shared input+output context window and four thinking levels—note that GenerateContent expects uppercase enum values in thinkingConfig.thinkingLevel, whereas the Interactions API expects lowercase values (inside the Antigravity workspace, Neon’s published limit is 512K).
  • DeepSeek-V4.1-Flash: Multi-step web search and page reading trigger only when deep thinking is enabled and search tools are explicitly declared (see DeepSeek Web Tools Guide and DeepSeek Application API Suite and V4.1-Flash).

Late-2026 Tier and Pricing Matrix

All four Anthropic 5.5/5.2 models provide a 1M-token context window and up to 128K output tokens (Haiku 5.5, Fable 5.2, Official Pricing):

Tier Representative Models Standard API Price (Input / Output per MTok) Default Thinking Behavior Best-Fit Workloads
L0 Fast (Short Prompt) claude-haiku-5-5 (≤ 100,000 input tokens) $0.10 / $0.50 Default medium (skips thinking on simple turns) Classification, extraction, pre-routing, light edits
L0 Fast (Long Prompt) claude-haiku-5-5 (> 100,000 input tokens) $0.50 / $2.50 Same; threshold includes cache reads/writes and applies to the full request Long-context triage and bulk extraction
L1 Balanced Daily Driver claude-sonnet-5-5 / gemini-4-neon Sonnet 5.5: $2.00 / $10.00 Default high Everyday coding, PR reviews, standard multi-step agents
L2 Deep Reasoning claude-opus-5-5 $4.00 / $20.00 Default medium (rejects disabled) Long-running refactors, cross-file diagnosis
L3 Heavy Fallback claude-fable-5-2 / Gemini 4 Carbon Fable 5.2: $8.00 / $40.00 Fable 5.2 default high (rejects disabled) Escalations after L1/L2 fail, security and architecture reviews

Watch Haiku 5.5’s 100,000-token threshold closely: cache reads and writes count toward it, and crossing the line bumps both input and output rates 5x for the entire request. Pair tiering with the Batch API (50% discount) for asynchronous jobs and prefix-stable Prompt Caching (see AI Context Management Guide).

Two-Dimensional Routing: Unified Verification and Circuit Breaking

Replace brittle LLM routers with deterministic policy selection, unified verification, and explicit circuit breaking (see Optimizing for Cost and Intelligence):

flowchart LR Req["Incoming Task / Agent Step"] --> Policy["Deterministic Policy (Profile + Budget + Deadline)"] Policy --> L0["L0: Haiku 5.5"] Policy --> L1["L1: Sonnet 5.5 / Gemini 4 Neon"] Policy --> L2["L2/L3: Opus 5.5 / Fable 5.2 / Carbon"] L0 --> Verify["Unified Deterministic Checks (Schema / Lint / Tests)"] L1 --> Verify L2 --> Verify Verify -->|"Pass"| Out["Return Result"] Verify -->|"Fail"| Gate{"Next Rung Available Within Budget & Deadline?"} Gate -->|"Yes"| Next["Step Up Effort or Model Tier"] Next --> Policy Gate -->|"No (Trip Circuit)"| Abort["Terminate Explicitly / Hand Off to Human"]

Every tier—including L2 and L3—passes through the same deterministic verification gate. Actual pass and escalation rates vary heavily by workload; measure them on your own team’s eval suite rather than assuming fixed percentages.

TypeScript Circuit-Breaking Escalation Router

This policy router separates Anthropic’s full effort enum from the locally permitted subset, validates attempt and profile at runtime, and returns an explicit termination outcome once the ladder, budget, or deadline is exhausted:

export type TaskProfile =
  | "extract_or_classify"
  | "standard_coding"
  | "complex_debugging"
  | "security_or_architecture";

/** Full Anthropic effort enum */
export type ClaudeEffort = "low" | "medium" | "high" | "xhigh" | "max";
/** Locally permitted subset (blocks automatic escalation to max) */
export type AllowedEffort = Exclude<ClaudeEffort, "max">;

export interface RouteDecision {
  model: string;
  effort: AllowedEffort;
  maxTokens: number;
}

export interface BudgetContext {
  spentUsd: number;
  maxBudgetUsd: number;
  deadlineMs: number;
  nowMs?: number;
}

export type RouteOutcome =
  | { ok: true; decision: RouteDecision }
  | {
      ok: false;
      reason: "ladder_exhausted" | "budget_exceeded" | "deadline_exceeded";
    };

const ROUTE_TABLE: Record<TaskProfile, readonly RouteDecision[]> = {
  extract_or_classify: [
    { model: "claude-haiku-5-5", effort: "low", maxTokens: 1024 },
    { model: "claude-haiku-5-5", effort: "medium", maxTokens: 2048 },
  ],
  standard_coding: [
    { model: "claude-sonnet-5-5", effort: "medium", maxTokens: 8192 },
    { model: "claude-sonnet-5-5", effort: "high", maxTokens: 16384 },
  ],
  complex_debugging: [
    { model: "claude-opus-5-5", effort: "medium", maxTokens: 16384 },
    { model: "claude-fable-5-2", effort: "high", maxTokens: 32768 },
  ],
  security_or_architecture: [
    { model: "claude-fable-5-2", effort: "high", maxTokens: 32768 },
  ],
};

export function selectRoute(
  profile: TaskProfile,
  attempt: number,
  budget: BudgetContext,
): RouteOutcome {
  if (!Number.isInteger(attempt) || attempt < 0) {
    throw new RangeError(`attempt must be a non-negative integer, got ${attempt}`);
  }
  if (!Object.prototype.hasOwnProperty.call(ROUTE_TABLE, profile)) {
    throw new RangeError(`unknown task profile: ${String(profile)}`);
  }

  const now = budget.nowMs ?? Date.now();
  if (now >= budget.deadlineMs) {
    return { ok: false, reason: "deadline_exceeded" };
  }
  if (budget.spentUsd >= budget.maxBudgetUsd) {
    return { ok: false, reason: "budget_exceeded" };
  }

  const ladder = ROUTE_TABLE[profile];
  if (attempt >= ladder.length) {
    return { ok: false, reason: "ladder_exhausted" };
  }
  return { ok: true, decision: ladder[attempt] };
}

export function buildClaudeRequestBody(
  decision: RouteDecision,
  userPrompt: string,
) {
  return {
    model: decision.model,
    max_tokens: decision.maxTokens,
    thinking: { type: "adaptive" as const },
    output_config: { effort: decision.effort },
    messages: [{ role: "user" as const, content: userPrompt }],
  };
}

When routing across Anthropic and Google Gemini 4, place vendor translation inside dedicated provider adapters rather than just adding a provider label, since output_config.effort and Gemini’s thinkingConfig.thinkingLevel (uppercase on GenerateContent, lowercase on Interactions) differ in both structure and valid values.

Billing and Observability Guardrails

  1. Do not double-bill thinking tokens: In the Claude Messages API, read usage.output_tokens_details.thinking_tokens for observability dashboards (see LLM Observability Guide), but remember those tokens are already included inside usage.output_tokens—never sum them for cost accounting.
  2. Never blindly pass disabled across tiers: Sonnet 5.5, Opus 5.5, and Fable 5.2 reject thinking: { type: "disabled" }; drop to Haiku 5.5 (where disabled is supported at high and below) or reduce effort.
  3. Monitor the 100K prompt boundary: Uncompacted conversation history or bloated system prompts pushing Haiku 5.5 past 100,000 tokens (including cache reads/writes) jump both input and output prices 5x.
  4. Trim context noise before upgrading tiers: Many failures that appear to need a heavier model are caused by noisy logs burying the real error—cleaning the context window is faster and cheaper than escalating.

References