Skip to content
Jordan Hudgens
Isometric studio still-life of four stepped warm brass balance weights, two translucent teal glass gates, and a matte terracotta stop block along a cream limestone channel on dark basalt stone.AI-generated illustration
Guide 27AdvancedOperations and observabilityAgents and tool useEvaluation and testing

Steer Thinking, Effort, and Budgets Across Tool-Using Turns

Resolve thinking by model capability, keep signed blocks intact, shift effort without cache misses, and stop runs with host budgets and ten-decimal ledgers.

Reading
9 min
Workshop
180 min
Stack
TS 7.0, Node 22, Claude 5.5 (Haiku 5.5 + Sonnet 5.5), Anthropic SDK 1.16, Zod 4
Version
1.0.0
Last verified
Dec 3, 2026

What you will build and be able to do

Each outcome has an observable criterion. The lab and the assessment check exactly these, nothing more and nothing less.

  1. OBJ-001

    Resolve thinking policy from model capabilities and reject removed parameters

    Read each model's supported thinking modes before building a request, choose adaptive, between_tools, or disabled per model, and reject budget_tokens, sampling parameters, unsupported forced tool_choice, and reasoning-extraction schemas locally.

  2. OBJ-002

    Keep signed thinking intact across open tool loops and prune only at turn boundaries

    Return thinking and redacted_thinking blocks byte for byte in their original order, freeze prefix digests while signed blocks remain, and prune only after a completed end_turn without emptying a message.

  3. OBJ-003

    Shift effort per message without losing the prompt cache

    Pin top-level effort, append a mid-conversation system message with the new effort, hold the beta header stable from turn 1, and check cache reads and diagnostics against the static prefix.

  4. OBJ-004

    Enforce pre-dispatch token, tool, and dollar budgets

    Hold task budgets at or above the 20,000-token floor, omit remaining on full-history hops, reserve thinking headroom and worst-case 5-minute cache-write cost, and halt oversized tool batches before any tool runs.

  5. OBJ-005

    Reconcile ten-decimal spend and fail closed on truncated or refused turns

    Bill exact integer units without double-counting thinking tokens, apply each model's cache-read and tier rules, halt on max_tokens and refusal stop reasons, and grade outcomes against independent projection data.

Offline clean-room setup (Node 22 + pnpm 12, $0.00)

  • TypeScript, the Node.js test runner, and the Anthropic Messages API tool-use loop
  • Outcome-graded evaluations that run repeated trials and read independent ground truthRead Dev Guide 02
  • Choosing a model tier per job class, which this guide refines inside one chosen model's loopRead Dev Guide 07
  • Prompt-cache prefix order and turn-boundary compaction for long conversationsRead Dev Guide 08
  • Cost, latency, and quality ledgers that compare options with evidenceRead Dev Guide 17
terminalbash
# Synthetic data. Runs 100% offline with zero API keys.unzip -q thinking-budget-labs.zip && cd thinking-budget-labs/starterpnpm install --frozen-lockfilenode src/cli.ts preflightcontract: thinking-budget-contract/1, node: v22.23.5, network_calls: none (offline)
Download Thinking Budget Labs (ZIP, MIT, $0 offline TypeScript) · ZIP · tested at v1.0.0

Five deterministic host gates around a Claude 5.5 tool loop

Synthetic data. Simulated services. Example Sedgevarn Cloud Incident and Dependency Triage Workbench (sedgevarn-triage.example-ops.test).
Five horizontal gate cards G1 through G5 above three containment outcome cards and a wire check bar.
Extended description

Gate G1 reads model capabilities, blocks removed parameters, and scans tool and output schemas for reasoning extraction before any network call.

Gate G2 keeps signed thinking blocks and prefix digests intact during open tool_use turns and prunes only after end_turn.

Gate G3 pins top-level fields and shifts effort through mid-conversation system messages so cached prefixes stay warm.

Gate G4 enforces the task budget floor, max_tokens headroom, worst-case cache-write reservation, and atomic tool batch caps.

Gate G5 bills ten-decimal integer units and fails closed on truncated or refused turns, proven across 36/36 Haiku held-out trials, 11/12 Sonnet trials, 16/16 fault probes, and 12/12 killed mutants.

Why static effort and ad hoc budgets fail in tool loops

Synthetic data. Simulated services. Example Sedgevarn Cloud Incident and Dependency Triage Workbench (sedgevarn-triage.example-ops.test). Every incident, service, log line, mitigation projection, receipt, and replay in this guide belongs to a simulated triage workbench that runs offline with zero outside network calls. The Anthropic API calls and their costs are real, billed, and reconciled to ten decimal places.

Teams moving an older agent onto Claude 5.5 usually make one of two mistakes. The first group leaves adaptive thinking on high effort for every routine lookup, edits top-level effort in the middle of a conversation, and watches latency and cache misses climb. The second group tries to save money by sending legacy budget_tokens, forcing tool_choice, or dropping assistant thinking blocks before the next tool_result, and meets HTTP 400 errors on the wire.

A better loop reads capability flags before building a call, returns signed thinking blocks untouched during an open tool turn, changes effort through messages that keep the cached prefix warm, pairs advisory task budgets with hard host breakers, and checks spend from the API usage counters. Live wire checks (17 validated probes, $0.0501) confirmed each rule on claude-haiku-5-5 and claude-sonnet-5-5 before any code was written.

Gate G1 capability policy and schema hygiene

Gate G1 turns capability facts into a deterministic check before any request leaves the host. The models endpoint reported different supported thinking modes for the two sibling models on the verification date, so hardcoding one mode by habit fails on one of them.

Synthetic data. Simulated services. Example Sedgevarn Cloud Incident and Dependency Triage Workbench (sedgevarn-triage.example-ops.test). Request rules verified across Claude 5.5 tiers on 2026-12-03.
Request fieldclaude-haiku-5-5claude-sonnet-5-5claude-opus-5-5
Adaptive thinking (low..max)SupportedSupportedSupported
disabled thinkingSupported at low..high onlyRejected with HTTP 400Rejected with HTTP 400
between_tools thinkingRejected with HTTP 400Supported at low..high onlyRejected with HTTP 400
Forced tool_choice (any or tool)Accepted, skips thinkingRejected with HTTP 400Rejected with HTTP 400
budget_tokens, temperature, top_p, top_kRejected under API 2026-10-21Rejected under API 2026-10-21Rejected under API 2026-10-21

On Claude 5.5 adaptive turns, thinking.display defaults to omitted so the stream omits the model-generated thinking summary while the encrypted signature stays attached. Switching to summarized emits a model-generated summary (never raw private chain-of-thought) when a human needs an audit trail. Omitted display trims streamed bytes but not the bill, because every reasoning token generated is still charged.

Synthetic data. Simulated services. Example Sedgevarn Cloud Incident and Dependency Triage Workbench (sedgevarn-triage.example-ops.test). Five gates, their host checks, and the codes they return.
GateWhat the host checksReject or halt codes
G1 Policy and SchemaCapability flags, removed parameters, forced tool_choice, and reasoning-extraction schemasREJECTED_LEGACY_BUDGET_TOKENS, REJECTED_REASONING_EXTRACTION_SCHEMA
G2 Signed ContinuitySigned blocks and prefix digests across open tool turns, pruning only after end_turnREJECTED_THINKING_BLOCK_MUTATION, REJECTED_PRUNE_DURING_OPEN_TOOL_LOOP
G3 Cache-Safe EffortPinned top-level fields and mid-conversation effort messagesREJECTED_TOP_LEVEL_EFFORT_MUTATION, REJECTED_PINNED_FIELD_MUTATION
G4 Budgets and HeadroomTask budget floor, max_tokens headroom, 5-minute write reservation, atomic tool batchesHALTED_INSUFFICIENT_MAX_TOKENS_HEADROOM, HALTED_BUDGET_CIRCUIT_BREAKER
G5 Ledger and OutcomesTen-decimal billing, stop reasons, and outcome checks against projectionsHALTED_MAX_TOKENS_TRUNCATION, HALTED_MODEL_REFUSAL

Gate G2 signed continuity and Gate G3 cache-safe effort

Claude signs each thinking block so the server can verify that it came from the same conversation prefix. Three bugs cause almost every multi-turn 400 error in thinking-enabled tool loops. Middleware drops thinking blocks whose text is empty, which is exactly what omitted display returns. Code edits system, tools, or an earlier message after a signed block exists. Compaction prunes thinking blocks while a tool_use turn is still open.

Three-column flow diagram showing open tool-use signed blocks and mid-conversation effort shifts passing through Gates G2 and G3 into warm prompt-cache hits.
Synthetic data. Simulated services. Example Sedgevarn Cloud Incident and Dependency Triage Workbench (sedgevarn-triage.example-ops.test). Signed blocks round-trip unmodified and effort shifts ride in mid-conversation messages.
Extended description

The left column shows an open tool loop with an empty-text signed thinking block, a pinned top-level effort with an appended low-effort system message, and the wire and cache mutations the gates must reject.

The middle column shows signed-turn preservation, completed-turn pruning, and the cache-safe request builder.

The right column shows zero signature or prefix errors, a warm cache prefix, and mutations killed offline.

prune-completed-turn.tstypescript
if (lastStopReason !== 'end_turn') {  return { ok: false, code: 'REJECTED_PRUNE_BEFORE_END_TURN' };}const kept = content.filter((b) => b?.type !== 'thinking' && b?.type !== 'redacted_thinking');if (kept.length === 0) return structuredClone(message); // never leave an empty assistant message

Changing top-level output_config.effort invalidates cached message blocks. In the live wire check, that edit re-wrote 3,131 tokens instead of reading the 2,759-token conversation prefix. Keeping top-level effort pinned and appending a mid-conversation system message with the new effort kept all 2,759 earlier tokens cached on claude-haiku-5-5. The host pins the beta header on turn 1 whenever a shift is planned, adds cache_control once the prefix reaches 512 tokens, and sends the previous message ID on every turn so cache misses carry a reason.

cache-safe-effort.tstypescript
if (proposed.top_level_effort !== pinned.top_level_effort) {  return { ok: false, code: 'REJECTED_TOP_LEVEL_EFFORT_MUTATION' };}if (needsShift) messages.push({ role: 'system', content: [], output_config: { effort: target } });
Synthetic data. Simulated services. Example Sedgevarn Cloud Incident and Dependency Triage Workbench (sedgevarn-triage.example-ops.test). Silent 6-second loop showing effort shifts keeping the cache warm while dropped signatures and top-level mutations are rejected. Silent loop, 6 seconds.
Extended description

The left cards show an effort shift, an omitted empty block, and a top-level mutation routing into Gates G2 and G3.

The resolution shows 2,759 cached tokens on the second turn and 435,149 cache reads across the locked live runs with zero dropped blocks.

Gate G4 budgets and Gate G5 ten-decimal ledger

Task budgets let Claude pace itself, but the host owns the hard limits. The task_budget field is advisory above a 20,000-token floor and returns HTTP 400 below it. When a request resends full message history, the host omits remaining so the API counts prior turns itself, and sets remaining only after a compacted reset.

Side-by-side comparison contrasting a broken starter relying on advisory task_budget and float math against Gates G4 and G5 pre-dispatch reservations and ten-decimal integer billing.
Synthetic data. Simulated services. Example Sedgevarn Cloud Incident and Dependency Triage Workbench (sedgevarn-triage.example-ops.test). Advisory pacing sits beside hard pre-dispatch reservations and exact billing.
Extended description

The left panel lists starter flaws: a budget below the floor, a starved max_tokens value, parallel tool overruns, and double-counted thinking tokens.

The right panel shows the budget and ledger gates reaching 55/56 locked live runs with zero S1 breaches and zero ten-decimal drift.

reserve-worst-case.tstypescript
const worstInputUnits = BigInt(p.estimated_prompt_tokens) * rates.write_5m_units;const usdRoom = p.envelope.max_run_usd_units - p.spent.usd_units - worstInputUnits;const affordable = usdRoom <= 0n ? 0 : Number(usdRoom / rates.out_units);const effective = Math.min(base, p.caps.max_tokens, remainingOutput, remainingThinking, affordable);

Thinking tokens come out of max_tokens, so a 512-token cap on an xhigh turn starves the tool call. Gate G4 requires the effective cap to cover thinking headroom plus a minimum reply, prices the synthetic fixture's estimated input at the 5-minute cache-write rate (use the token-counting endpoint plus conservative tier selection for arbitrary production inputs), and clamps the cap to what the remaining dollar envelope can pay for. It also counts every tool_use block in a batch and halts the whole batch before any tool runs when the ceiling would be crossed.

Synthetic data. Simulated services. Example Sedgevarn Cloud Incident and Dependency Triage Workbench (sedgevarn-triage.example-ops.test). Silent 6-second loop contrasting advisory pacing with hard pre-dispatch breakers and exact billing. Silent loop, 6 seconds.
Extended description

Inputs feed a bounded turn dispatch and a fail-closed circuit breaker halt covering starved max_tokens, a batch cap of one, and max_tokens or refusal stops.

The paths converge on the 15.88 second offline gate and the 55/56 locked live verdict.

Gate G5 closes the loop with exact integer units where 1 USD equals 10,000,000,000 units. Output tokens already include thinking tokens, so the ledger splits non-thinking output for observability and bills output once. In one live check claude-haiku-5-5 returned an empty thinking string while usage reported 1,096 billed thinking tokens inside 1,223 output tokens. Sonnet reads cache at 0.05 times base input and Haiku at 0.10 times, and Haiku moves to higher rates when input, cache-write, and cache-read tokens together exceed 100,000.

A max_tokens stop is a truncation, and a refusal carries a stop category, so neither counts as a finished triage result. The outcome check also grades approval_required against the independent mitigation projection instead of trusting prose, and flags an S1 breach if an irreversible or invented action claims no approval is needed.

Post-remediation held-out live regression and cost ledger

Before any held-out evaluation, the Stage 3 manifest was sealed with SHA-256 prefix ac01856cda0fc89e across 8 frozen artifacts: 8 development scenarios, 16 fault cases, 12 held-out scenarios, their oracles, and 12 mutants. An archived first Haiku held-out pass scored 26 of 36 trials (7/12 pass^3, 0 S1 breaches, $0.0229) before scrubbing echoed chain-of-thought bait in untrusted webhook logs and clarifying the literal STATUS token in the prompt and parser. All 13 executable files were then hash-locked (955f80333bdc512c) before 48 post-remediation held-out regression trials (188 API message turns: 144 Haiku and 44 Sonnet) on the same unmodified Stage 3 scenarios.

Eight-row containment matrix mapping Gates G1 through G5 to 16 fault probes and 12 killed code mutants.
Synthetic data. Simulated services. Example Sedgevarn Cloud Incident and Dependency Triage Workbench (sedgevarn-triage.example-ops.test). Verified offline inside unshare -rn: 16/16 fault probes blocked, 12/12 mutants killed, 24/24 unit tests passing.
Extended description

Eight rows map Gates G1 through G5 to fault probes E-01 through E-16 and single-guard mutants M01 through M12.

Every row states the host mechanism and the offline result, which ran in 15.88 seconds at $0.00.

Scorecard showing 8/8 Haiku development calibration, 36/36 Haiku post-remediation held-out trials with 12/12 pass^3 (Run 1: 26/36), 11/12 Sonnet portability, 16/16 fault probes, 12/12 killed mutants, 0 S1 breaches, and $0.2424 recorded receipt spend.
Synthetic data. Simulated services. Example Sedgevarn Cloud Incident and Dependency Triage Workbench (sedgevarn-triage.example-ops.test). 55 of 56 Run-2 live trials passed with 0 S1 breaches and $0.0000000000 receipt-arithmetic drift.
Extended description

The left column shows 8/8 Haiku development calibration and the offline defense check.

The center and right columns show claude-haiku-5-5 passing 36/36 post-remediation held-out trials (12/12 pass^3, Run 1 26/36, SHIP) and claude-sonnet-5-5 passing 11/12 (SHIP), with recorded receipt spend of $0.2424 (all-in ceiling $0.2589).

Synthetic data. Simulated services. Example Sedgevarn Cloud Incident and Dependency Triage Workbench (sedgevarn-triage.example-ops.test). Live evaluation and recorded receipt USD spend (4 decimals here, 10 decimals in the spend reconciliation), 2026-12-03. Tokens are input / cache read / output (thinking).
Suite and modelTrials and pass^kS1 breachesTokensUSDVerdict
Wire spike, both models17/17 validated probes0n/a$0.0501VERIFIED
Dev calibration, claude-haiku-5-58/8, k=1082 / 52,066 / 5,960 (2,178)$0.0065CALIBRATED
Held-out primary, claude-haiku-5-536/36, 12/12 pass^30651 / 309,267 / 26,382 (10,495)$0.0230SHIP
Held-out portability, claude-sonnet-5-511/12, k=10209 / 73,816 / 4,412 (351)$0.1329SHIP
Offline faults and mutants16/16 faults, 12/12 mutants00$0.0000SHIP

Across the 56 Run-2 trials, prompt caching served 435,149 cache-read tokens against 109,672 cache-creation tokens and 942 uncached input tokens. Capability-driven policy chose disabled thinking on Haiku and between_tools on Sonnet for the same incident with zero 400 errors, and both models halted at one executed tool call when the second was proposed. On H-10, Sonnet produced the exact core incident diagnosis and approval classification in 5 turns with zero thinking blocks, so only the secondary boundary_pruning check went unexercised while the Haiku trials all emitted thinking blocks.

Run-2 Stage 4 suites recorded $0.1624, archived Run-1 suites recorded $0.0300, and the 17 validated Stage 2 probes recorded $0.0501, totaling $0.2424 in recorded Anthropic receipt spend with $0.0000000000 receipt-arithmetic drift (conservative all-in Anthropic ceiling $0.2589 including up to $0.0165 from uncaptured pre-fix Stage 2 smoke probes).

Lab 1: Gate G1 capability policy and Gate G2 signed continuity

Repair resolveThinkingPolicy(), preserveSignedThinkingTurn(), and pruneCompletedTurnThinking() so each model gets a supported mode, removed parameters are rejected, signed blocks round-trip, and pruning waits for end_turn.

Acceptance checks

  • Haiku resolves disabled and Sonnet resolves between_tools for fast turns, with no display field on either
  • temperature, top_p, top_k, budget_tokens, unsupported forced tool_choice, and reasoning-extraction schemas are rejected
  • Empty-text signed thinking blocks and redacted_thinking data return byte for byte, and any edit is rejected
  • pnpm test:lab1 reports 8/8 tests passing offline
  1. Check thinking policy across M-01 through M-04 on both models

    $ node src/cli.ts policy-check

    Initial: Initial (starter-baseline)

    { "policy_rows": [ { "model": "claude-haiku-5-5", "scenario_id": "M-01", "thinking": "adaptive", "expected_mode": "adaptive", "match": true }, { "model": "claude-haiku-5-5", "scenario_id": "M-02", "thinking": "adaptive", "expected_mode": "disabled", "match": false }, { "model": "claude-haiku-5-5", "scenario_id": "M-03", "thinking": "adaptive", "expected_mode": "adaptive", "match": true }, { "model": "claude-haiku-5-5", "scenario_id": "M-04", "thinking": "adaptive", "expected_mode": "adaptive", "match": true }, { "model": "claude-sonnet-5-5", "scenario_id": "M-01", "thinking": "adaptive", "expected_mode": "adaptive", "match": true }, { "model": "claude-sonnet-5-5", "scenario_id": "M-02", "thinking": "adaptive", "expected_mode": "between_tools", "match": false }, { "model": "claude-sonnet-5-5", "scenario_id": "M-03", "thinking": "adaptive", "expected_mode": "adaptive", "match": true }, { "model": "claude-sonnet-5-5", "scenario_id": "M-04", "thinking": "adaptive", "expected_mode": "adaptive", "match": true } ] }

    Final: Final (checkpoint-a, Gates G1 and G2)

    { "policy_rows": [ { "model": "claude-haiku-5-5", "scenario_id": "M-01", "thinking": "adaptive", "expected_mode": "adaptive", "match": true }, { "model": "claude-haiku-5-5", "scenario_id": "M-02", "thinking": "disabled", "expected_mode": "disabled", "match": true }, { "model": "claude-haiku-5-5", "scenario_id": "M-03", "thinking": "adaptive", "expected_mode": "adaptive", "match": true }, { "model": "claude-haiku-5-5", "scenario_id": "M-04", "thinking": "adaptive", "expected_mode": "adaptive", "match": true }, { "model": "claude-sonnet-5-5", "scenario_id": "M-01", "thinking": "adaptive", "expected_mode": "adaptive", "match": true }, { "model": "claude-sonnet-5-5", "scenario_id": "M-02", "thinking": "between_tools", "expected_mode": "between_tools", "match": true }, { "model": "claude-sonnet-5-5", "scenario_id": "M-03", "thinking": "adaptive", "expected_mode": "adaptive", "match": true }, { "model": "claude-sonnet-5-5", "scenario_id": "M-04", "thinking": "adaptive", "expected_mode": "adaptive", "match": true } ] }
  2. Show the solution discussion

    Apply checkpoint-a with node ../apply-checkpoint.mjs checkpoint-a .

    Run pnpm test:lab1 and confirm 8/8 tests pass offline.

More labs in this guide

  • Lab 2: Gate G3 cache-safe effort and Gate G4 budget ceilings

    Repair buildCacheSafeTurnRequest(), allocateTurnAndTaskBudgets(), and preflightToolBatchInvocations() so effort shifts ride in mid-conversation messages, reservations are conservative, and oversized tool batches halt atomically.

  • Lab 3: Gate G5 ten-decimal ledger and fail-closed outcomes

    Repair reconcileTurnLedger(), verifyScenarioOutcome(), and scrubIds() so spend is exact, truncated and refused turns halt, outcomes are graded against projections, and provider IDs stay synthetic.

Ten ways this breaks, and how you will know

Every failure here is reproducible in the lab with a flag. Learn the symptom first; it is what you will actually see.

  • F-01Reproducible

    Sending legacy budget_tokens or sampling parameters

    Symptom
    The API returns HTTP 400 on Claude 5.5 under API 2026-10-21.
    Diagnosis
    Old enabled-thinking or temperature fields were hardcoded from earlier snippets.
    Fix
    Reject budget_tokens, temperature, top_p, and top_k locally in Gate G1 before dispatch.
    Verify
    pnpm test:lab1
  • F-02Reproducible

    Forcing tool_choice without checking the model

    Symptom
    Sonnet 5.5 returns HTTP 400, or Haiku skips adaptive thinking on a diagnosis turn.
    Diagnosis
    The request passed tool_choice any or tool without reading capabilities.
    Fix
    Pair tool_choice auto with strict tool schemas and allow forced choice only on fast extraction turns where it is supported.
    Verify
    pnpm test:lab1
  • F-03Reproducible

    Crossing disabled and between_tools

    Symptom
    Sonnet returns HTTP 400 on disabled, or Haiku returns HTTP 400 on between_tools.
    Diagnosis
    The mode was chosen by habit instead of from the models endpoint thinking flags.
    Fix
    Resolve the fast mode from each model's supported thinking types.
    Verify
    pnpm test:lab1
  • F-04Reproducible

    Asking for or echoing raw reasoning

    Symptom
    The guardrail returns stop_reason refusal with the reasoning_extraction category.
    Diagnosis
    A schema asked for chain-of-thought, or an untrusted log line echoed bait asking for it.
    Fix
    Scan tool and output schemas in Gate G1 and scrub untrusted log fields before they reach the model.
    Verify
    node src/cli.ts fault-check
  • F-05Reproducible

    Dropping an omitted thinking block

    Symptom
    Interleaved continuity breaks when a thinking block with empty text disappears from history.
    Diagnosis
    A helper filtered blocks by text length instead of keeping signed blocks by type.
    Fix
    Hash each signed block when it arrives and require every one to return in order before a tool_result is sent.
    Verify
    pnpm test:lab1
  • F-06Reproducible

    Editing signed history or pruning mid-loop

    Symptom
    The API returns HTTP 400 on an altered block, a changed prefix, or an open-loop prune.
    Diagnosis
    History was edited before end_turn, or system, tools, or earlier messages changed after signing.
    Fix
    Freeze prefix digests while signed blocks remain and prune only after a completed end_turn.
    Verify
    pnpm test:lab1
  • F-07Reproducible

    Mutating top-level effort mid-conversation

    Symptom
    Cached turns are re-written and latency climbs after an effort change.
    Diagnosis
    Top-level output_config.effort changed instead of an appended system message.
    Fix
    Pin top-level effort and append a mid-conversation system message under a beta header held stable from turn 1.
    Verify
    pnpm test:lab2
  • F-08Reproducible

    Breaking task budget rules

    Symptom
    A total below 20,000 returns HTTP 400, or remaining fights the server count on full history.
    Diagnosis
    The floor was skipped or remaining was sent with a full-history resend.
    Fix
    Enforce the floor and omit remaining on full-history hops.
    Verify
    pnpm test:lab2
  • F-09Reproducible

    Starving max_tokens or overrunning a batch

    Symptom
    Thinking consumes the reply, spend exceeds the envelope, or parallel tools slip past the cap.
    Diagnosis
    Headroom, the 5-minute write reservation, or the whole-batch check was skipped.
    Fix
    Clamp the effective cap, reserve worst-case cost, and halt oversized batches atomically.
    Verify
    pnpm test:lab2
  • F-10Reproducible

    Grading a truncated reply or mispricing cache

    Symptom
    A max_tokens or refusal turn passes, or ledger totals drift from the invoice.
    Diagnosis
    The stop reason was ignored, or Sonnet 0.05 times reads and the Haiku 100,000-token tier were misapplied.
    Fix
    Halt on max_tokens and refusal and bill exact integer units with each model's tier rules.
    Verify
    pnpm test:lab3

Transfer task and rubric

Set thinking, effort, and budget policy for an unseen fleet-telemetry service, diagnose four wire traces, and reconcile a ten-decimal ledger.

Analytic rubric: each criterion described at four performance levels, from Emerging to Exemplary
Criterion0 · Emerging1 · Developing2 · Proficient3 · Exemplary
R1: Gate G1 Capability-Aware Thinking Resolution and Schema Hygiene (15 pts, Critical)Sends disabled to Sonnet or between_tools to Haiku, accepts temperature or budget_tokens, or copies lab identifiers.Correct on most specs but accepts a forced tool_choice or a reasoning-extraction schema, or sends display on a fast mode.Resolves or rejects every spec correctly and names the sampling and budget_tokens rejection codes.Proficient, plus the forced tool_choice code, the reasoning-extraction rejection, no display on fast modes, and capabilities read from the supported field.
R2: Gate G2 Display Selection and Prefix Immutability (15 pts)Chooses display by habit, treats a summary as raw reasoning, or leaves system and tools mutable after signed thinking.Chooses displays correctly but errs on billing, empty-text signed blocks, or digest scope.Both display choices are correct and the digest scope covers system, tools, and prior messages.Proficient, plus the exact prefix rejection code, summarized display billed like omitted, and the zero-thinking-block case.
R3: Gate G3 Mid-Conversation Effort and Cache Diagnostics (15 pts)Mutates top-level effort mid-conversation.Appends an effort message with a wrong shape, a wrong beta header, or unstable headers.Appends the system message with empty content and holds the beta header stable from turn 1.Proficient, plus fast-mode shift rejection, previous message IDs on every turn, cache-miss monitoring, and a cache-read check against the static prefix.
R4: Gate G2 Signed Block Integrity and Boundary Pruning (15 pts, Critical)Strips empty-text signed blocks or redacted data mid-loop, or prunes during an open tool loop.Preserves blocks but neither compares them to a recorded digest nor requires signatures.Preserves blocks byte for byte mid-loop, requires signature or data, compares digests, and prunes only at a completed end_turn.Proficient, plus no empty assistant message, pruned-block counts, the suffix cache trade-off, and no claim of host-side signature verification.
R5: Gate G4 Task Budget Hygiene (10 pts)Passes remaining on full-history hops and accepts a total under the floor.Right on the floor but wrong on one hop type.Enforces the floor, omits remaining on full-history hops, and accepts remaining only after compaction.Proficient, plus correct arithmetic for the compacted case and the budget treated as advisory.
R6: Gate G4 and G5 Reservation, Batch Breaker, and Stop Handling (15 pts, Critical)Assumes a cache hit in the reservation, executes part of an over-cap batch, or accepts max_tokens or refusal as complete.Halts safely but uses a wrong effective max_tokens rule or wrong reservation values.Reserves the worst-case cache-write cost, halts batches atomically with zero partial executions, and uses distinct fail-closed stop codes.Proficient, plus exact preflight values on every case, per-invocation counting, halt dimensions, and the refusal category recorded.
R7: Gate G5 Ten-Decimal Ledger and Trace Forensics (15 pts)Wrong on every ledger row and every trace.Correct on one ledger row or one trace.Correct ledger on two rows and correct diagnoses on three traces.Proficient, plus exact tier, non-thinking tokens, and cost on all rows, the exact total, and all four traces correct.

Proficiency standard: Proficient or higher on every criterion. Proposed local standard, not an official certification.

Self-check

The full brief

The target domain is an unseen diagnostics desk that shares no incident IDs, hostnames, or action names with the lab workbench, so copied lab identifiers lose points.

Part 1: Resolve or reject four request specs, choose a display mode for two adaptive requests, and state the capability-read and prefix-immutability policy.

Part 2: Diagnose four wire traces covering a dropped signed block, a top-level effort cache bust, a system-prefix edit after signing, and a prune during an open tool loop, naming the first bad step, the violated gate, and the fix.

Part 3: Work four reservation preflights, two tool batches, four task budget cases, three stop reasons, and a three-row ten-decimal ledger. Submissions are screened structurally and graded by a human reviewer.

Teach it to a room

  • 3-hour facilitation run-of-show

    Timed workshop agenda covering offline preflight, the five-gate brief, three progressive labs with checkpoint recovery, and a debrief that contrasts model routing and compaction with steering inside a live loop.

  • Checkpoint recovery and 12-mutant check

    apply-checkpoint.mjs moves any learner workspace between starter-baseline, checkpoint-a, checkpoint-b, and final, while mutants.mjs kills 12/12 single-guard mutants offline.

  • Measured author clean-room walk

    Cold empty-store pnpm install finished in 593 ms (132 ms warm store), followed by all starter, checkpoint, replay, fault, and mutant gates in 15.88 s inside unshare -rn.

  • Observed teach-back clearance rubric

    Two calibrated observers score a live teach-back across anchored technical and facilitation dimensions alongside the unseen transfer assessment; instructor clearance stays human-signed.

  • Pass-rate report template

    Tracks enrolled and attending denominators with confidence intervals and version boundaries; kept unpopulated until a real cohort completes the module.

  1. [1]Adaptive thinking in Claude · platform.claude.comchecked Dec 3, 2026
  2. [2]Thinking steering, display omitted, and cost · platform.claude.comchecked Dec 3, 2026
  3. [3]Thinking in tool-use workflows · platform.claude.comchecked Dec 3, 2026
  4. [4]Thinking troubleshooting and timeouts · platform.claude.comchecked Dec 3, 2026
  5. [5]Effort levels in output_config · platform.claude.comchecked Dec 3, 2026
  6. [6]Change effort per message · platform.claude.comchecked Dec 3, 2026
  7. [7]Mid-conversation system messages · platform.claude.comchecked Dec 3, 2026
  8. [8]Task budgets across agent loops · platform.claude.comchecked Dec 3, 2026
  9. [9]Prompt caching in Messages API · platform.claude.comchecked Dec 3, 2026
  10. [10]Prompt cache miss diagnostics · platform.claude.comchecked Dec 3, 2026
  11. [11]Preserved thinking prefix checks · platform.claude.comchecked Dec 3, 2026
  12. [12]Migrating to Claude API 2026-10-21 · platform.claude.comchecked Dec 3, 2026
  13. [13]Refusals and reasoning_extraction fallback · platform.claude.comchecked Dec 3, 2026
  14. [14]Strict tool use and grammar-constrained schemas · platform.claude.comchecked Dec 3, 2026
  15. [15]Define tools and tool_choice rules · platform.claude.comchecked Dec 3, 2026
  16. [16]List Models capability discovery API · platform.claude.comchecked Dec 3, 2026
  17. [17]Claude 5.5 models overview · platform.claude.comchecked Dec 3, 2026
  18. [18]Claude API pricing · platform.claude.comchecked Dec 3, 2026
  19. [19]Token counting in Messages API · platform.claude.comchecked Dec 3, 2026
  20. [20]Handling stop reasons in Messages API · platform.claude.comchecked Dec 3, 2026
  21. [21]Claude platform release notes · platform.claude.comchecked Dec 3, 2026
  22. [22]Linux unshare(1) network namespaces · man7.orgchecked Dec 3, 2026

Independent work. Not affiliated with or endorsed by any vendor named in this guide.

Jordan Hudgens

Written by

Jordan Hudgens

Technical educator and AI engineering leader. 16 Udemy courses, 111K students, and curricula used by 250K+ learners.

Next in the path

All guides