Cost & Turn Control¶
Uncapped loops are expensive and can run indefinitely on open-ended prompts. Always set limits for unattended runs.
# Agent SDK (Python)
from claude_agent_sdk import query, ClaudeAgentOptions
async for message in query(
prompt="refactor the auth module",
options=ClaudeAgentOptions(
max_turns=30, # hard turn cap
max_budget_usd=2.00, # hard cost cap
effort="high", # reasoning depth: low|medium|high|xhigh|max
model="claude-sonnet-5",
)
):
...
Model Reference (September 2026)¶
Four models are current as of this writing. Figures are from Anthropic's own model comparison and pricing pages, fetched 2026-09-04.
| Model | API ID | Context | Max output | Reliable knowledge cutoff | Positioning |
|---|---|---|---|---|---|
| Claude Fable 5.1 | claude-fable-5-1 |
1M | 128K | Jun 2026 | "For demanding reasoning and long-horizon agentic work" |
| Claude Opus 5 | claude-opus-5 |
1M | 128K | May 2026 | "For complex agentic coding and enterprise work" |
| Claude Sonnet 5 | claude-sonnet-5 |
1M | 128K | Jan 2026 | "The best combination of speed and intelligence" |
| Claude Haiku 4.5 | claude-haiku-4-5 |
200K | 64K | Feb 2025 | "The fastest model with near-frontier intelligence" |
(Anthropic, Models overview, fetched 2026-09-04.)
The Haiku 4.5 row lists the alias. Its pinned snapshot ID is claude-haiku-4-5-20251001;
claude-haiku-4-5 is a convenience pointer that resolves to it, because Haiku 4.5 predates the
4.6 generation. The other three IDs in the table are themselves pinned snapshots — from 4.6 on,
Anthropic ships dateless IDs and "every Claude model ID is a pinned snapshot, including the
dateless IDs used from the 4.6 generation on." Never append a date suffix to a dateless ID.
Pricing per MTok — base input / 5-minute cache write / 1-hour cache write / cache read / output:
| Model | Base input | 5m cache write | 1h cache write | Cache read | Output |
|---|---|---|---|---|---|
| Fable 5.1 | $10 | $12.50 | $20 | $0.25 | $50 |
| Mythos 5.1 (limited availability) | $10 | $12.50 | $20 | $0.25 | $50 |
| Fable 5 (legacy, still available) | $10 | $12.50 | $20 | $1.00 | $50 |
| Opus 5 | $5 | $6.25 | $10 | $0.50 | $25 |
| Sonnet 5 | $2 | $2.50 | $4 | $0.20 | $10 |
| Haiku 4.5 | $1 | $1.25 | $2 | $0.10 | $5 |
Note the cache-read column: Fable 5.1 reads at 4× cheaper than the Fable 5 it replaced ($0.25 vs $1.00/MTok) — a Fable-tier judge pass that leans on a warm cache got meaningfully cheaper for free on the upgrade. The general cache-pricing rule, verbatim:
"5-minute cache write: 1.25x base input price... 1-hour cache write: 2x base input price... Cache read (hit): 0.1x base input price (0.025x on Claude Fable 5.1 and Claude Mythos 5.1)."
(Anthropic, Pricing, fetched 2026-09-04.)
Context footnote, verbatim: "1M tokens is roughly 555k words or 2.5M Unicode characters on the current tokenizer (introduced with Claude Opus 4.7); models before it fit about 750k words in 1M tokens." (Same source.) Part of a 1M-context model's headroom pays for its own tokenizer: the newer tokenizer "produces approximately 30% more tokens for the same text" than the one Sonnet 4.6 and earlier models used — with the caveat the same page attaches, "the exact increase depends on the content and workload shape." Anthropic's Sonnet 5 announcement puts the same effect as a range: "roughly 1.0–1.35x depending on the content type." Budget against the range, not the midpoint. (Anthropic, Pricing, and Introducing Claude Sonnet 5.)
Timeline¶
- Sonnet 5 — released 2026-06-30, became the default for Free and Pro, replacing Sonnet 4.6. "Sonnet 5 narrows the gap: its performance is close to that of Opus 4.8, but at lower prices." Its launch pricing turned out to be permanent, not introductory: "The $2/$10 per million input/output token pricing for Claude Sonnet 5, announced at launch as introductory pricing through August 31, 2026, is now the standard price. The previously scheduled increase to $3/$15 per million input/output tokens on September 1, 2026 will not occur." (Anthropic, Introducing Claude Sonnet 5; pricing note from Pricing.)
- Opus 5 — released 2026-07-24 (Claude Code v2.1.219), the new default on Max and the strongest model on Pro, replacing Opus 4.8: "a thoughtful and proactive model that comes close to the frontier intelligence of Claude Fable 5 at half the price." Fast mode runs at twice the base rate — $10/$50 per MTok. (Anthropic, Introducing Claude Opus 5.)
- Fable 5.1 — released 2026-09-01 (Claude Code v2.1.257), now the default Fable model.
Changelog, verbatim: "Added Claude Fable 5.1 (
claude-fable-5-1), now the default Fable model — 1M context, $10/$50 per Mtok with $0.25/Mtok cache reads." (v2.1.257 release notes.)
Every model ID, price, context window, cutoff and positioning quote in this section was
re-verified against the live Models overview
and Pricing pages on 2026-09-06, and
every release-note quote against CHANGELOG.md at its tag in
anthropics/claude-code. All 30 figures in the pricing
table matched.
October 2026 update: the 5.5 generation¶
The "four current models" above are superseded as of 2026-10-19. Anthropic's Models overview now lists Fable 5.1, Opus 5.5, Sonnet 5.5 and Haiku 5.5 as the current set, and the older Sonnet 5, Opus 5 and Haiku 4.5 sit under "Additional models" (both pages fetched 2026-10-19). Prices from Pricing, per MTok:
| Model | API ID | Input / output | 5m / 1h cache write | Cache read | Default effort |
|---|---|---|---|---|---|
| Opus 5.5 | claude-opus-5-5 |
$4 / $20 | $5 / $8 | $0.20 | medium |
| Sonnet 5.5 | claude-sonnet-5-5 |
$2 / $10 | $2.50 / $4 | $0.10 | high |
| Haiku 5.5, prompt up to 100K tokens | claude-haiku-5-5 |
$0.10 / $0.50 | $0.125 / $0.20 | $0.01 | medium |
| Haiku 5.5, prompt over 100K tokens | claude-haiku-5-5 |
$0.50 / $2.50 | $0.625 / $1 | $0.05 | medium |
All four current models list 1M context, 128K max output and a June 2026 reliable knowledge cutoff; Fable 5.1 is unchanged from the table above. Against the September table: Opus 5.5 is $1/$5 under Opus 5, Sonnet 5.5 keeps Sonnet 5's $2/$10 base price but halves the cache-read rate ($0.20 to $0.10), and Haiku 5.5 is one-tenth of Haiku 4.5's base price (up to 100K tokens) and moves the cheap tier from 200K to 1M context. Anthropic's positioning line for Haiku 5.5 is "For high-volume, latency-sensitive tasks such as classification, extraction, and routing", which is the cheap-hands role in the table below. Three caveats on that price:
- The price steps up 5x above 100K prompt tokens, so a worker whose context grows long loses most of the saving. (Simon Willison, 2026-10-07.)
- The tokenizer is less generous. On one long prompt, his Claude Token Counter showed about 1.25x as many tokens on Haiku 5.5 as on Haiku 4.5 — one measurement on one prompt, but the same "budget against the range" logic as the tokenizer note above applies. (Same post.)
- Reasoning cannot be turned off on Haiku 5.5 and defaults to medium, per the same post, so a "cheap" worker still has an effort setting to pin.
Sonnet 5.5 launched 2026-09-28; The New Stack's report gives Terminal-Bench 4.0 at 70.6% versus Opus 5.5's 66.4% and up to 30% lower cost per task (launch figures as reported, not independently reproduced here). Worked example of the cheap-worker shape on the new tier: a Rundown AI guide has a Sonnet main model create a read-only Haiku subagent to sort a small batch, requires each item once with a source quote, has Sonnet review the flagged items, leaves refunds and replies to a human, and compares the cost against a Sonnet-only run. It is a newsletter walkthrough with no published cost figures, but it carries all three pieces the table below asks for: cheap hands, a stronger reviewer on exceptions, and a measured comparison. See Subagents.
Choosing a Model for the Job¶
A table alone tells nobody what to do. Three levers actually decide the model bill on a loop: which role gets which tier, how effort is set on top of it, and whether a mid-session switch busts the prompt cache you were relying on.
One measured data point, for calibration only. An Anthropic employee had Opus 5.5 and Fable 5.1 each port HAProxy from C to Rust: "We had Opus 5.5 and Fable 5.1 each port HAProxy from C to Rust. Both passed nearly all of HAProxy's tests, but Opus 5.5 finished in 9.5 hours compared to Fable 5.1's 12 hours, and for 51% less cost." This is one run reported by the person who ran it — no harness, configuration, or test counts are published, and "nearly all" is not quantified, so no per-hour or per-test cost figure should be derived from it. (@bcherny, Sep 2026.)
Main loop, subagents, and a judge pass are not the same purchase¶
Subagents already makes the case for allocating models by role rather than uniformly — cheap hands do the high-volume work, strong eyes decide only at the gates. Mapped onto the current lineup:
| Role | Typical tier | Why |
|---|---|---|
| Main loop / interactive session | Sonnet 5 | Now $2/$10 per MTok list price — Opus-4.8-adjacent capability at Sonnet price, per Anthropic's own comparison above |
| Subagents, high-volume (search, test execution, log triage) | Haiku 4.5, or Sonnet 5 where more judgment is needed | Cheapest capable model; subagent output rarely needs Opus-tier reasoning |
| Judge / adjudicator pass (the gate that decides "confirmed" vs. "refuted") | Opus 5 or Fable 5.1 | Rare, high-stakes, decision-only calls — exactly where Anthropic frames Opus 5 ("half the price" of Fable 5) and Fable 5.1 ("demanding reasoning and long-horizon agentic work") as fitting |
This is the same principle the reasoning-effort finding below applies to effort — spend the marginal dollar where it changes the outcome — applied to model choice instead of reasoning depth. A judge that flips one bad "confirmed" into a shipped defect costs far more than the price delta between Sonnet and Opus on that one call.
Plan mode can run on a different model than execution¶
Effort and role aren't the only levers — which phase of the loop model tokens hit matters
too. Since v2.0.17, a Haiku 4.5 session automatically runs plan mode on Sonnet and
execution on Haiku (the changelog's own shorthand: "SonnetPlan by default") — the model doing
your architecture review is not the model that writes the code. Bedrock and Vertex are not
auto-upgraded; set ANTHROPIC_DEFAULT_HAIKU_MODEL there to opt in manually. The mechanism
generalizes: a session that would upgrade to a model excluded by an availableModels
allowlist instead uses the newest permitted version of that family, and only stays on its own
model when every upgrade candidate is excluded (fixed at v2.1.205 — before it, an excluded
newest version blocked the upgrade entirely even when an older version was still allowed).
A comparable option exists for higher tiers: /model opusplan (added v1.0.77) runs Opus
only during plan mode and switches to Sonnet for execution — Opus's research quality on the
phase where mistakes are cheapest to review, Sonnet's price on the phase that runs the most
tokens. On subscription tiers where Opus auto-upgrades to 1M context, opusplan gets that
upgrade in the plan phase too (append [1m] — opusplan[1m] — to force it where you aren't
on an auto-upgrade tier).
What these auto-upgrades resolve to is itself configurable: ANTHROPIC_DEFAULT_SONNET_MODEL,
ANTHROPIC_DEFAULT_OPUS_MODEL, ANTHROPIC_DEFAULT_HAIKU_MODEL, and
ANTHROPIC_DEFAULT_FABLE_MODEL (the Sonnet/Opus pair added v1.0.88; Haiku and Fable added
later) pin what the sonnet, opus, haiku, and fable aliases — and opusplan — resolve
to, letting a fleet lock every session to a specific dated model without rewriting every
--model flag or waiting for an alias to move underneath it. See Model
configuration for the full mechanics, and
Explore→Plan→Implement→Commit for where plan mode itself sits
in a loop.
Practical read: if a loop's cost model assumes one model runs the whole session, check
/model (or the pinned env vars above) for which phase actually ran on which model — a
Haiku-tier budget can be quietly spending Sonnet-tier tokens on every planning step.
Which model a subagent actually runs on¶
Whether a subagent honours the tier you intended depends on precedence, not on what you wrote in its frontmatter. Official docs give the resolution order, verbatim:
- The per-invocation
modelparameter- The subagent definition's
modelfrontmatter, whereinheritselects the main conversation's model- The
CLAUDE_CODE_SUBAGENT_MODELenvironment variable, when you set it to a model alias or model ID- The main conversation's model
(Anthropic, Sub-agents, fetched 2026-09-04.)
This order is not old. It reordered in v2.1.251: "Changed CLAUDE_CODE_SUBAGENT_MODEL to
set the default subagent model rather than override everything: an agent definition's model:
and an explicit per-spawn model now take precedence over it." Before that release the env var
won outright — a subagent definition's pinned model: field could be silently overridden by
whatever CLAUDE_CODE_SUBAGENT_MODEL happened to be set to in the shell. (v2.1.251 release
notes.)
v2.1.257 added the knob back for when a hard override is actually wanted:
CLAUDE_CODE_SUBAGENT_MODEL_FORCE. Verbatim: "CLAUDE_CODE_SUBAGENT_MODEL is a default, so a
subagent's definition or a model Claude passes still takes precedence over it. To apply one
model to every subagent, teammate, and workflow agent, also set
CLAUDE_CODE_SUBAGENT_MODEL_FORCE to 1. Requires Claude Code v2.1.257 or later." Two kinds
of subagent stay exempt even with FORCE on: a fork (inherits the parent's context and model
directly) and a skill run in a subagent with model: inherit. (Anthropic, Sub-agents — run
every subagent on one model,
fetched 2026-09-04.)
Practical read: CLAUDE_CODE_SUBAGENT_MODEL=haiku sets a floor for anything not explicitly
pinned, without fighting a subagent definition that pins something more expensive on purpose.
Reach for CLAUDE_CODE_SUBAGENT_MODEL_FORCE=1 only when that floor must hold with zero
exceptions — a cost audit, a compliance run — because it also overrides the built-in Explore
and Plan subagents' own model fields.
The precedence order, version-stamped:
| Rank | Source | Since | Notes |
|---|---|---|---|
| 1 (highest) | Per-invocation model parameter (what Claude passes when spawning this specific subagent) |
Always | Wins even over a pinned agent definition |
| 2 | Subagent definition's model: frontmatter (inherit = main conversation's model) |
Always | Wins over CLAUDE_CODE_SUBAGENT_MODEL since v2.1.251 only |
| 3 | CLAUDE_CODE_SUBAGENT_MODEL env var |
Sets only the default since v2.1.251 | Before v2.1.251 this rung was highest-precedence and silently overrode rungs 1 and 2 — including model: inherit |
| 4 (lowest) | Main conversation's model | Always | Applies when nothing above is set |
| — override — | CLAUDE_CODE_SUBAGENT_MODEL_FORCE=1 |
v2.1.257+ | Ignores ranks 1–2 (per-spawn and agent-definition overrides), forcing rank 3 — or rank 4 if CLAUDE_CODE_SUBAGENT_MODEL is unset — onto every subagent, teammate, and workflow agent, except a fork and a skill run with model: inherit |
What this means in plain terms: setting CLAUDE_CODE_SUBAGENT_MODEL is a default, not a
guarantee. Since v2.1.251, an agent definition's own model: field — or a model Claude passes
at spawn time — silently outranks it, so a fleet you believe is capped at Haiku can still run
individual subagents on Opus if their definitions say so. Anyone who set the env var expecting a
hard cost ceiling, not just a fallback, needs CLAUDE_CODE_SUBAGENT_MODEL_FORCE=1 (v2.1.257+) —
without it, the cap is advisory.
This is no longer something to assume and hope: /tasks and the agent detail dialogs show the
model (and effort level) each subagent actually ran on, as of v2.1.243 — "Added the model (and
effort level) each subagent ran on to /tasks and the agent detail dialogs." (v2.1.243 release
notes; the official Sub-agents
reference cites
"Requires Claude Code v2.1.242 or later" for the same /tasks display.) Practical advice:
after setting a model floor, check /tasks on a real run rather than trusting the env var alone
— it is the cheapest way to catch an agent definition that quietly opted out of the cap.
See Subagents → Custom agents for where the
model: frontmatter that outranks the env var is actually set.
The Explore trap this interacts with: Explore is a built-in subagent, so it is not
exempt from any of the above — and since v2.1.198 it inherits the main conversation's model
by default rather than always running on Haiku, so "Explore is cheap because it's Haiku" is no
longer true unless you pin it. On the Claude API that inheritance is capped at Opus — a main
conversation on a higher tier still runs Explore on Opus, and a session on Sonnet or Haiku runs
it on that same model — so on Fable 5.1 ($10/MTok) Explore bills at Opus 5's $5/MTok, not Fable's.
The cap is Claude-API-only: on Bedrock, Google Cloud, Foundry and Claude Platform on AWS, Explore
inherits the main conversation's model directly, uncapped. Setting only
CLAUDE_CODE_SUBAGENT_MODEL_FORCE leaves the cap in place. See Subagents → built-in subagent types
for the full mechanics and the fix (a project Explore agent definition with model: haiku).
Token consumption benchmarks¶
Real-world multipliers relative to standard single-turn chat:
| Mode | Approximate token multiplier |
|---|---|
| Single agent | ~4× |
| Multi-agent | ~15× |
Set --max-budget-usd conservatively on first deployment (e.g. $2–5 for a single-agent
loop), then raise after observing actual consumption on real runs.
(Data Science Dojo, "Agentic Loops: From ReAct to Loop Engineering", 2026.)
Team multiples, measured on a coding benchmark. Vals AI ran GPT-6 Sol and Claude Opus 5.5 on its Vibe Code Bench as solo agents and as teams, at medium and maximum reasoning effort. Per The Decoder's report, teams cost 1.8x to 5.1x more, and only one of the four team-versus-solo comparisons (GPT-6 Sol at medium effort, +7.3 points) was statistically significant; at maximum effort neither model gained anything real from a team. The same report cites Anthropic's own tests with Opus 5.5, where going from ten to 100 agents nudged scores up only slightly after 24 hours. This is secondhand: the explainer that surfaced it could not find Vals' own write-up of the team experiment, so treat the multiples as reported until Vals publishes methodology. It sits between the ~15x multiplier above and the 20x harness step-change below: orchestration is not free, and the evidence for what it buys is narrower than the pitch. See Agent Teams.
A small factory run, with the integrator included. A MindStudio write-up of a "documented test run" (underlying run not linked, so secondhand) puts a 10-issue parallel coding run at about $3.67 of Claude Code tokens for the triage, worker, verifier and reviewer stages, plus $6.37 for a fifth integrator stage because 7 of 9 approved pull requests hit merge conflicts, against roughly one cent of sandbox compute. Whatever the exact figures, the shape is the useful part: the stage added to repair parallel agents' collisions can cost more than the pipeline that caused them, and the token bill dwarfs the infrastructure bill. (MindStudio, 2026-10-10.) See Fan-Out.
Real project cost benchmarks¶
From Anthropic's own harness engineering work (Prithvi Rajasekaran, "Harness design for long-running application development", Mar 2026):
| Task | Architecture | Time | Cost | Result |
|---|---|---|---|---|
| Retro game maker | Solo agent | 20 min | $9 | Broken core functionality |
| Retro game maker | Full harness (Planner + Generator + QA) | 6 hours | $200 | Fully playable, 16-feature spec, 10 sprints |
| Digital audio workstation | Simplified harness (no sprints) | 3h 50min | $124.70 | Working application |
The DAW cost breakdown: Planner $0.46 · Build phases $113.85 · QA phases $10.39.
Key takeaway: the 20× cost increase (solo → harness) on the game maker yielded qualitatively different output — not incrementally better. Budget for this step-change when reliability and completeness are non-negotiable.
At the other extreme, tight environment- and budget-engineering can make frontier results cheap: a system budget-engineered around a narrow, well-defined environment reached state-of-the-art results on a 26-circle packing benchmark for under $11 total API cost — evidence that BUDGET (Loop Contract) is not just a runaway-cost guard but a design lever that, tightened around a narrow enough SCOPE, can buy frontier-level output cheaply. (EurekAgent, arXiv 2606.13662, Jun 2026.)
Fleet-scale internal telemetry, for calibrating the numbers above against an organization rather than a single project. OpenAI's internal usage data on researchers running coding agents daily: a median spend of ~$600/day per researcher, with the 90th percentile above $7,000/day, and a reported 3.1:1 agent-to-human workday ratio (the agents collectively do the work of roughly three extra researchers per human). Even at that spend and ratio, more than half of successful 4–8 hour autonomous tasks still needed at least one human intervention — a data point for Human-in-the-Loop Escalation as much as for cost: high spend and high leverage did not eliminate the need for a human checkpoint, they just moved where it falls. (OpenAI, "Research acceleration: The view inside OpenAI", Sep 2026.)
Secondary coverage of the same report adds the operational detail the ratio implies. The New Stack's reporting breaks the internal usage into Epoch AI's six-area taxonomy — Decide, Design, Build, Run, Analyze, Communicate — and names two supervision-cost signals the raw ratio doesn't show: internal debugging-office-hours attendance fell enough that one team stopped holding them, and a July 20 series of agent-caused outages was severe enough that OpenAI took its training container service offline. A second incident — early evidence the frontier model (GPT-6 Astra) could reach the "Critical" cybersecurity threshold in OpenAI's own Preparedness Framework — led to an access tightening on Aug 7 that cut Astra-class GPU allocation 59.2% in the following week, with other models absorbing roughly 85% of that drop. OpenAI's stated next target is an automated AI researcher by March 2028. Read this as evidence that high spend and high leverage create their own supervision failure modes (outages, safety-threshold near-misses), not just a cost number to budget against. (Amanda Caswell, "AI Agents Create More Work Than They Eliminate," The New Stack, 2026-09-07 — reporting on the same OpenAI source above.)
Token cost by loop pattern¶
Concrete benchmarks from operating named loop patterns (Cobus Greyling, cobusgreyling/loop-engineering, Jun 2026):
| Run type | Token cost |
|---|---|
| Noop pass (empty watchlist, early exit) | ~3,000–5,000 |
| Report-only triage run | ~50,000–80,000 |
| Action run (implementer + verifier) | ~200,000–250,000 |
| CI Sweeper at 15 min cadence, no early exit | ~5,000,000/day |
The early exit rule: every loop must check for work before doing any triage. If the watchlist is empty, exit immediately at <5k tokens. Never run the full loop body if there is nothing to act on.
Without early exit, a CI Sweeper running every 15 minutes against a green repo burns ~5M tokens per day on no-ops. The early exit rule converts it to ~3k tokens per pass. This is not an optimisation — it is a correctness requirement for always-on loops.
See Loop Patterns for the eight named loop patterns and their typical token envelopes.
Cost Per Loop, Now First-Party¶
Until v2.1.243, the benchmarks above were the closest a loop engineer could get to a
per-loop cost figure without hand-rolled instrumentation — someone else's operating
experience, not a measurement of your loop. That release added it as a built-in report,
verbatim: "Added a Loops breakdown to /usage: per-loop run count, total tokens, tokens per
run, and last run, so runaway or chatty /loop tasks are easy to spot." (v2.1.243 release
notes.)
This is the number Ng's cost-per-unit-of-work argument asks
for, now first-party instead of hand-instrumented: tokens per run is cost per closed unit
for any loop whose unit of work is one wake-up (Daily Triage, Debt Audit); divide by
units-closed-per-run for a loop like PR Babysitter that can close several in one pass. It is
also the direct instrument for the Loop Contract's BUDGET leg — a
LOOP.md that sets a per-run token cap can check that cap against /usage instead of
estimating it from a benchmark table, and a loop whose tokens-per-run climbs without a
matching rise in units closed is the runaway-cost signal to slow down or kill (see
Operational Kill / Pause / Slow-Down Thresholds
below), read directly instead of inferred from the bill.
The same release also made /loop itself quieter about doing nothing: "Improved /loop:
consecutive wake-ups where Claude has nothing to do now fold into a single line in the
terminal instead of printing each one." (Same source.) And as of v2.1.248, self-paced
dynamic mode and the no-prompt autonomous default lost their platform gate — see Loop
Patterns → Loop Command Modes.
Where the Money Goes: Turns, Not Observations¶
Most loop-cost advice targets the size of what the agent reads. TurnCost (arXiv 2610.15093, v1 submitted 2026-10-10) tests that against 600 publicly released coding-agent trajectories from two scaffolds and two models, and defines loop engineering as context management, model selection, compaction and termination. From its abstract:
- Observations are small. Median observations are 118-286 tokens; the large build logs used to motivate compression sit near the 99th percentile.
- Nearly all input is cached. 98.6% of input tokens are prefix-cache hits, so flat input pricing overestimates loop cost by roughly 7x on average under near-ideal caching.
- Turn count is the driver. It explains 84% of the variance in log trajectory cost, against 4% for mean observation size; the most expensive trajectories have the most turns despite the smallest observations.
- Delegation has a break-even. The authors derive a closed-form break-even condition for model delegation and validate it empirically: delegation increased cost in half of the evaluated settings, near the predicted boundary.
The authors' own caveat matters: these are associations, and they "do not establish that turns can be removed while holding task success fixed". It is one preprint on public trajectories, not a measurement of your loop. Read with this doc's other sections, it points at three levers: cut turns (the early-exit rule and an explicit STOP in the Loop Contract), keep the prefix stable so the 98.6% stays a hit (see The Cache Cost of Switching Model or Effort Mid-Session), and treat a cheaper-model delegation as something to price with the break-even rather than assume. The companion tool, TurnCost, re-scores trajectory corpora under alternative caching, pricing, compression and routing policies. A separate theory paper, Harnessing LLMs as Agents: What Does It Cost? (arXiv 2610.02488), charges harness-level resources and derives communication, access and recomputation lower bounds on model calls and context-memory traffic; no empirical figure is taken from it here.
Two adjacent cost drivers that are not tokens read per turn:
- Tool definitions. The New Stack reports Chrome DevTools MCP at roughly 18,000 tokens (9% of a 200K window) before any work, and describes Pi keeping MCP tool definitions out of the prompt: a QuickJS-sandboxed "Codemode" lets the agent discover and call tools from JavaScript. Under TurnCost's cache numbers the dollar cost of a stable prefix is likely mostly cache-read pricing; the larger loss is window headroom (inference, not measured). See Context Management.
- Tool calls as the bottleneck. In The Batch, Andrew Ng says one of his agents (paperreview.ai) makes roughly 5-10K web search calls a day and that for some agentic workflows tool calls, not token throughput, are the bottleneck. An unattended loop's budget needs a tool-call or wall-time dimension, not only dollars; see Multi-Dimensional Budget Pressure.
A harness-level lever found by an auto-research loop: SoL-Pi. SoL-Pi (NVIDIA/MIT; paper, 17 Sep 2026; MIT-licensed, an extension for the Pi harness) packages four mechanisms an automated search kept, each aimed at a cost driver above: fuse an edit with its follow-up command into one tool call; replace a large tool result with a handle and excerpt after two requests; replace long build/test logs with a cheap-model receipt checked against the archived log; compact at finished plan steps (or near the window limit) when projected savings beat the cost of rewriting the prompt cache. The authors' numbers on the 51 public EdgeBench tasks, unreplicated: against Pi the full stack used 44.7-49.0% fewer tokens and about a third less API cost (33.2% and 33.5% on the two models) while keeping 93.7-94.3% of Pi's average score (42.0 vs 44.8 on GPT-5.6 Sol); against the native Codex and Claude Code harnesses the cost cut was 50.0% and 54.3%. The trade shows in their cache numbers: cache reads halved, cache writes more than doubled (0.0141 B to 0.0316 B tokens), and total cost still fell ($1,339 to $894). On Terminal-Bench 4 (63 CPU-only tasks) it solved 15 tasks against 18 for Pi and Codex, at 26.3% lower cost than Pi. All four mechanisms are opt-in and off by default, and the log reducer sends log content to a second model, so the project's SECURITY.md says not to enable it for logs that must stay local. How the search was gated: Harness Patterns.
Routing and Decision Models: Strong Model Only Where It Decides¶
The role table in Choosing a Model for the Job allocates models by role. Routing allocates them per task, and a newer class of small decision models takes the narrowest calls off the LLM entirely. Four October 2026 data points, with their provenance:
| Evidence | Result | Provenance |
|---|---|---|
| LangChain's Open SWE router | 973-thread live A/B against always using GPT-6 Astra: median cost per thread $2.61 to $0.94 (64% lower; mean 42%, p90 37% lower); merged-PR rate 29.2% vs 27.3% (p = 0.49), PR-open rate 38.9% vs 39.6% (p = 0.82) | First-party, LangChain's own traffic |
| Cloudflare Clef | Open-weight (Apache 2.0) decision models @cf/cloudflare/clef and clef-flash on Workers AI: read a state plus typed questions, return a probability per allowed answer; Cloudflare claims Clef is 2.5x faster than Jev at the median and Clef-flash 13x, and top on 7 of 10 decision benchmarks |
Vendor launch claims, not reproduced here |
| Proceda on SOP-Bench | Main-LLM calls 2,537 to 1,785 (29.6% fewer); estimated cost including the decision model $6.41 to $4.70; 360/360 tasks correct vs 357/360 for Qwen alone | Self-disclosed: the author built the harness and ran the test |
| OpenAI customer stories: LegalOn, Asana | 65% cut in estimated daily Codex cost by matching models to tasks and managing budgets; browser agent 76x cheaper and 5x faster in tests | Vendor-reported; only the titles and descriptions were read (pages returned 403) |
What the Open SWE router actually is. Three tiers (fast: GLM-5.3-Flash at xhigh effort; balanced: GPT-5.6 Sol at medium; performance: GPT-6 Astra at low), chosen once from the thread's first human message and kept for the whole thread. Routed threads split 56% balanced, 34% fast, 10% performance, with median cost $0.097, $1.50 and $2.88 per thread — a roughly 30x spread across tiers. LangChain notes the control was its most expensive model, so a large saving is unsurprising, and that mid-thread rerouting is not handled by this version. Its classifier first ran on an LLM with structured output and now runs on the Jev decision model, which LangChain reports made classification almost 50x faster. The argument to take: the router belongs in the harness rather than a generic gateway, because the harness already holds the task context the choice depends on (LangChain's reading). The success metric was merged PRs, an artifact, not a rating; the Cobus Greyling opinion piece makes the same ownership argument (own the harness, rent the model) with little evidence behind it. A non-significant difference at this sample size is not proof of equivalence — re-measure on your own task mix.
The decision-model pattern. In the Proceda test a small decision model gated step completion: if both "tool calls made" and "evidence sufficient" yes-probabilities reached 0.8 the harness advanced without the follow-up LLM turn, otherwise the main LLM continued; tools still ran. For email intent it accepted a valid choice at probability 0.8 or above and fell back otherwise. The author's own summary of the pattern: supply the evidence, define the allowed choices, validate the result, keep an LLM fallback. Caveats he states: completion-checking alone saved 23.8% of LLM calls but finished 356/360 correct, and the combined 360/360 comes from one subset and does not establish an accuracy gain. This is a stop-condition step-gate whose failure mode is silently accepting a wrong "done" — the confidence threshold is the thing to validate (see Confidence-Scheduled Verification and Verification).
Measure the choice, and audit the alias. Two small worked examples from one open-source setup, claude-code-monorepo:
- A commit
(2026-09-30) revisited whether a bug-fix skill should pin
model: sonnetormodel: opuswitheffort: low. The Sonnet 5.5 and Opus 5.5 posts disagreed, so the note concludes to measure both on your own tasks, because cost is tokens plus retries rather than the per-token price. - Another commit
removed
ANTHROPIC_DEFAULT_HAIKU_MODEL, which had silently sent everyhaikurequest to a Sonnet. A hidden alias override changes the model, and so the bill, without any line in the prompt or skill saying so; check settings and environment before attributing a cost change to the loop. (See Which model a subagent actually runs on.)
Hard Budget Caps and Honest Cost Accounting¶
max_budget_usd caps one run. Three further layers cap or measure spend
across runs, and October 2026 produced evidence for each:
- At the provider. Simon Willison argues (2026-10-03) that coding and personal agents make runaway spend likely, so pay-by-usage services need hard caps on by default, not warn-only emails; he points to AWS's new spend limits (announced 16 Sep; a project that reaches its limit is paused for the month, though AWS's own page says the experience is releasing to a limited number of customers) and Google Cloud's Spend Caps (July) as a trend. For the Anthropic API, his Haiku 5.5 post relays two relevant changes: a monthly API credit for Max and Team subscribers (Max 5x $100, Max 20x $200, Team up to $500 pooled; no rollover), and the option to disable auto-reload so that "API requests will stop when your balance runs out". With auto-reload off, the balance becomes a provider-side hard cap for an unattended loop. (Figures as relayed by Simon from Anthropic's announcement; not re-fetched from Anthropic.)
- In the harness policy layer. omnigent v0.17.0
(2026-10-06) adds period-based cost budgets to its governance policies, plus a
turn_finalindicator so RESPONSE-phase checks can act on a finished turn. The release notes are the only source read: they establish that the budget is enforced by the harness rather than the prompt, not its configuration syntax. It is the inter-run counterpart to per-run caps, and the enforcement version of the "budget >80% of period" row in Operational Kill / Pause / Slow-Down Thresholds. - In the meter. A cap is only as honest as the cost it computes.
neal v0.6.12 adds
neal usage(turns, tokens and cost by provider and role, per run or all runs, read fromevents.ndjsonso unfinished runs are covered) and fixes cached input being billed at the full input rate: on an 80%-cached turn with cached input at a tenth of the full rate, cost came out about 3.6x too high. The same omnigent release prices cached prompt tokens at the cache-read rate for its openai-agents and Codex-native sessions. Together with TurnCost's roughly 7x flat-pricing overestimate, the lesson is that a budget gate computed at the full input rate trips early by multiples on a cache-heavy loop; check the meter against the provider invoice before trusting the gate.
A lens for when verification itself is the expensive part. An opinion essay, not a measurement: frmsaul's LessWrong post The Expensive-Loop Problem (2026-10-12) separates "cheap-loop" domains (fast, deterministic, cheap feedback) from "expensive-loop" ones where feedback is scarce, and argues models do poorly in the latter because they lack theory-building, proxy management and budgeting. Its practical reading for this doc: when the real check is slow or costly, the loop needs a ladder of cheaper proxies (its software example runs unit tests, integration tests, code review, then customers) and the proxy must be watched for Goodhart drift, which connects to Verifier Theater. A loop whose only verifier is expensive should say so in its BUDGET.
An ambient agent has a standing cost, not only a per-run cost. swyx says (8 Oct 2026) his team "stopped using Tags after finding out they cost ~$3k/mo minimum passive ingestion". It is a third-party user's own estimate with no method or breakdown, and the post is the only source read, so take it as a prompt to price an always-on or ingest-everything loop before enabling it (see Claude Tag), not as a Claude Tag price.
Effort levels¶
| Level | Use when |
|---|---|
low |
File lookups, listing directories |
medium |
Routine edits, standard tasks |
high |
Refactors, debugging |
xhigh |
Complex coding tasks (Fable 5 / Opus 4.7+) |
max |
Multi-step problems requiring deep analysis |
Reasoning effort is the dominant reliability lever — not tool access¶
A 90-run observational study (building the same spec'd app — a real-time retro board — across multiple model generations, two harnesses, two effort levels, a testing tool, and two design prompts; scored on a 14-criterion / 42-point rubric) found that reasoning budget, not extra tooling, is what buys first-try reliability:
| Lever | Effect on first-try-perfect (all 14 criteria, zero corrective prompts) | Cost delta |
|---|---|---|
Raise effort high → xhigh |
28% → 89% first-try-perfect; ~5× fewer corrective prompts | +9–29% |
| Add a testing tool | No improvement in functional score or reliability (even on interface-visible criteria) | +42–68% |
The counterintuitive result: checking mechanisms and tool access do not fix failures whose root cause is weak reasoning. When the model's reasoning is the bottleneck, spend the marginal dollar on reasoning budget (or a stronger model) before adding testing tools or checker passes — the effort bump is both cheaper and dramatically more effective. This does not override the verification mandate (an independent verifier still catches what the maker cannot self-see); it says a self-run testing tool bolted onto a weak-reasoning maker is a poor trade against simply raising effort.
(Reasoning effort, not tool access, buys first-try reliability in agentic code generation, arXiv, Jul 2026.)
When a checker pays for itself — the reach rule¶
The paper above leaves the obvious follow-up open: effort beats tools was measured on a greenfield spec'd build, so when does a checker earn its cost? The same author answered it in a controlled follow-up, and the answer is not the one this KB expected.
It is not codebase size and not task length. It is reach:
A verification tool improves the output artifact only where its reach covers the way the application actually fails.
Method: a minimal coding agent whose tool list is the single controlled variable, used to build 1,116 web applications across six models and eight tool configurations, every one graded by a condition-blind human against a frozen rubric, plus automatic probes.
What that buys you, in cost terms — and the shape is steeply diminishing:
| Verification surface | Measured effect |
|---|---|
| None | "about one build in seven fails to launch at all" |
| A single boot probe | "removes nearly all of these failures at roughly 35 percent of a full shell's token cost" |
| A full shell | "multiplies the no-tools cost by 2.35" |
| Screenshots | Help "where mistakes are visible (e.g. element placement, interaction)" — but "the gain over a shell is modest and does not survive correction for multiple statistical comparisons" |
| Screenshots, on a failure you can only measure | "In cases where failures can only be measured rather than seen, such as keeping scrolling smooth over a 100,000-row list, screenshots add nothing" |
How to spend a loop's verification budget, from this.
- Buy the cheap floor first. The single highest-return check is the one that answers did it
even come up — one build in seven did not, and a boot probe fixes almost all of that for about a
third of a shell's tokens. In a loop, that is the
STOPcondition's first clause. - Match the instrument to the failure mode, then stop. A screenshot checker on a performance regression is pure cost. Ask what this loop's outputs actually fail at, and buy the one tool whose reach covers it.
- A bigger verification surface is not a better one. A full shell costs 2.35× the no-tool baseline; past the boot probe, the marginal tool mostly buys tokens.
Read alongside the effort finding above, the two compose into one budget rule: raise effort for the reasoning, and buy exactly one checker whose reach matches the failure mode. Neither substitutes for the other, and both beat spending on the other's job.
(The reach of a verification tool decides its value: A controlled study of verification surface,
artifact quality, and cost in AI coding agents, Achint Mehta,
arXiv, submitted 28 Aug 2026 — a direct follow-up by the same author as 2607.02436. Figures above
are quoted from the abstract, verified 20260906; the paper's brownfield and long-horizon results are
in the body and are not re-quoted here because only the abstract was read at source.)
Effort levels, officially¶
The table above is this KB's own framing. Official per-level guidance, verbatim (Anthropic, Model Config → Effort Level Guidance, fetched 2026-09-04):
| Level | Official guidance |
|---|---|
low |
"Reserve for short, scoped, latency-sensitive tasks that are not intelligence-sensitive" |
medium |
"Reduces token usage for cost-sensitive work that can trade off some intelligence" |
high |
"Balances token usage and intelligence. The default on every model except Opus 4.7" |
xhigh |
"Deeper reasoning at higher token spend. The default on Opus 4.7" |
max |
"Can improve performance on demanding tasks but may show diminishing returns and is prone to overthinking. Test before adopting broadly" |
ultracode |
"A Claude Code setting that plans a dynamic workflow for each substantive task with xhigh per-message reasoning" |
Two things worth pulling out of that table:
highis the default on every current model — Fable 5.1, Opus 5, and Sonnet 5 alike default tohigh, per Anthropic's own models comparison table. Opus 4.7 (a legacy model, not Opus 5) is the sole exception — but that exception is a Claude Code default, not an API one. The table above is Claude Code's, and Claude Code resolves "highon every model that supports effort, except that Opus 4.7 defaults toxhigh." Calling the same model through the API getshigh: "The API default ishigh. To usexhigh, seteffortexplicitly." Same model, two surfaces, two defaults — a loop that runs partly in Claude Code and partly through the SDK will silently run at two different depths, and pay two different bills, unless it sets effort explicitly. (Anthropic, Effort, fetched 2026-09-06.) Don't assume a newer or pricier model defaults to deeper reasoning — check/model.ultracodeis not "one level deeper thanmax." It is a qualitatively different setting: layered on top ofxhighreasoning, it auto-triggers a dynamic workflow for every substantive task in the session — Claude decides on its own to fan a task out into a scripted multi-agent workflow rather than only thinking longer about it inline. That changes orchestration strategy, not just per-turn token spend, so treat/effort ultracodeas "hand this session a harness," not as a five-starmax.ultrathinkis a separate, one-off in-prompt keyword for deeper reasoning on a single turn — it does not change the session's effort setting or trigger a workflow.
Effort persists per model, or scoped to one session¶
Two related changes to how /effort remembers its setting:
- v2.1.251, verbatim: "Changed
/effortto save your default effort level per model, so each model keeps its own setting when you switch." Before this, one/effortchoice applied across every model; a deliberate "raise effort on the hard model, leave the cheap one at default" split now survives a/modelswitch instead of needing to be re-set each time. - v2.1.257, verbatim: "Added
sin/effortto change effort for the current session only, matching/model." Use it for a one-off bump on a single hard turn without changing the default that future sessions on that model will pick up.
(v2.1.251 and v2.1.257 release notes.)
The Cache Cost of Switching Model or Effort Mid-Session¶
Every model, and on most models every effort level, keeps its own prompt cache. Official docs, verbatim (Anthropic, Prompt caching → Actions that invalidate the cache, fetched 2026-09-04):
"Two settings don't appear in the layer table but still affect what stays cached: Model: each model has its own cache. Switching models recomputes the entire request even when the content is identical... Effort level: on most models, each effort level has its own cache, so changing effort mid-session recomputes the entire request. On Fable 5.1 with an API key or a Claude subscription, the cache stays intact by default."
That quote is frozen at its 2026-09-04 fetch date. The same page, re-fetched 2026-09-28 for the paragraph below, now names Opus 5.5 in this section too, not just Fable 5.1.
That Fable 5.1 exception is new, and it shipped broken: "Before v2.1.260, changing effort on Fable 5.1 with an API key or a Claude subscription also invalidated the cache" — the same release (v2.1.257) that shipped Fable 5.1 itself shipped it with that bug, fixed three versions later.
A second model extends the exception — now confirmed against the official cache docs. The
same reference page, re-fetched 2026-09-28, now reads: "On Opus 5.5 and Fable 5.1 with an API
key or a Claude subscription, changing effort keeps the cache, and Claude Code applies the new
level without asking. This doesn't apply on Amazon Bedrock, Google Cloud's Agent Platform, or a
Claude apps gateway, or when you set CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS or your
organization has a HIPAA configuration." (Anthropic, Prompt caching → Changing effort
level, fetched
2026-09-28.) That quote is frozen at its 2026-09-28 fetch date and has since gone stale: re-fetched
2026-09-29, the same page now reads "On Opus 5.5, Sonnet 5.5, and Fable 5.1 with an API key or a
Claude subscription, changing effort keeps the cache..." — Sonnet 5.5 has joined the exception. A
Wayback Machine snapshot from
2026-09-25
— the closest capture to 2026-09-28; none exists for 2026-09-28 itself, and none exists between
2026-09-25 and 2026-09-29 (checked 2026-09-29) — still shows the two-model wording quoted above.
With this doc's own 2026-09-28 fetch, that puts the change between the 2026-09-28 fetch and the
2026-09-29 re-fetch; only the Wayback bound (2026-09-25) can be re-checked independently.
Anthropic's own Opus 5.5 announcement post frames the same mechanism from the
product side: "For newer models like Opus 5.5 and Fable 5.1, you can now change effort levels
during your sessions without resetting your cache" — alongside forked subagents that "start from
the parent's cache instead of paying for the same context again" (see Subagents § Cache-Safe
Forking and Isolated Child State).
The same post's "3.3x"/"2.6x" figures
are aggregate Claude Code usage trends from March to September 2026, not a comparison with Opus
4.6: "Claude works 3.3x longer on each prompt with more than 40% more model calls per prompt"
and "Context per request has grown 2.6x."
(Michael Segner, Anthropic, "Claude Opus 5.5 is built for coding sessions that use more context", Sep 24, 2026.)
Setting the cache TTL directly¶
For API-key and cloud-provider (Bedrock/Vertex/Foundry) users, the cache TTL is also a configurable setting rather than a fixed default:
- v2.1.243, verbatim: "Added
promptCacheTtlandsubagentPromptCacheTtlsettings so API-key and cloud-provider users can keep a 1-hour prompt cache on the main conversation while subagents stay at 5 minutes" - v2.1.248, verbatim: "Added
experimental.cacheTtl(\"5m\"or\"1h\") to agent frontmatter: a per-agent prompt cache TTL used when no subagent TTL setting is configured"
(v2.1.243 and v2.1.248 release notes.)
Loop engineering read: a 1-hour cache write costs 2× base input price against a 5-minute
write's 1.25× (the cache-pricing rule quoted above) — so promptCacheTtl: "1h" is a bet that
the main conversation will still be warm an hour from now, worth it for a long-running
interactive session but wasted spend on a short-lived subagent. subagentPromptCacheTtl sets
that bet session-wide for every subagent; per-agent experimental.cacheTtl frontmatter
overrides it for one agent definition specifically, and only applies when no subagent-level TTL
setting is configured. Together they let a fleet keep the main loop's cache warm at 1h while
short-lived worker subagents default to the cheaper 5m write.
A measured case of that bet losing. ClaudeWarp recorded a background session that lived 64 seconds, did zero thinking, and produced 4 output tokens — and still cost $0.2425, of which $0.2406 was Opus 5. The driver was a 22,659-token 1-hour cache write: $0.2266 at Opus 5's $10/MTok 1h rate, or 94% of the session's entire cost, paid for a cache with 59 minutes of life left when the session ended. The identical write is $0.09 on Sonnet 5 and $0.05 on Haiku 4.5.
The lesson generalises past the TTL setting. Any short-lived session pays (system prompt + tool definitions) × the model's cache-write rate before doing any work, so the floor of a fan-out scales with the model's price, not the task's difficulty. For short-lived workers the lever is to pin a cheaper model, not to lower effort — effort was already zero here. Full figures and caveats in Background Agents § The per-session cost floor. (Measured by ClaudeWarp v0.42.1; the arithmetic is ours, and 5.8% of the recorded total is not explained by the published token counts. ClaudeWarp shares this KB's maintainer, so this figure is self-reported and unreproduced — see the first-party disclosure.)
Consequence for a loop: switching model or effort mid-run to save money on the harder half of a task can cost more than it saves, because the next request re-processes the entire conversation history uncached. The mechanic isn't Claude-Code-specific: per-turn routing is a cache-invalidation anti-pattern generally. Routing to a different model or tier on each turn — a common technique when cost-optimizing individual calls in isolation — breaks the prefix/KV cache the same way a mid-session switch does, because the router is choosing per-request rather than per-session. A 15-turn session that should hit roughly 90% cache reuse instead recomputes at full price on every routed turn; cited alongside this pattern, Uber's ~5,000-engineer Claude Code rollout reportedly burned its annual AI budget by April (@akshay_pachaar, Sep 2026). Two corollaries, the first restating Choosing a Model for the Job's principle at the cache layer:
- Pick model and effort at the top of a session (or at the top of each subagent spawn) and hold them for the run — per session, not per call. A DOER→CHECKER handoff that also changes model is not "free role-switching" — it is a cache-busting event, on top of whatever the role switch itself costs.
- A judge/adjudicator pass is the exception that doesn't need this warning — it should already run in a fresh context (see Session Architecture and Verification), so it pays the uncached first turn regardless of which model it runs on. The trap is switching mid-session, not spawning a differently-modeled pass in its own context.
/usage now surfaces this directly rather than leaving it to be inferred: the Prompt cache
(main) line reports request count, the percentage of input tokens served from cache, and miss
count with the tokens re-cached by the last miss (Claude Code v2.1.251+). A session with a
persistently low cache-hit percentage and no /compact//clear in its history is very likely
switching model or effort somewhere in its loop. (Anthropic, Costs → Prompt cache
statistics, fetched
2026-09-04.)
Confidence-Scheduled Verification¶
Not every iteration needs a full verification pass. A confidence-scheduled approach skips a verification pass when the maker's own confidence signal is high enough that the expected value of re-checking is low, and runs it in full when confidence is low — spending verification compute where it is likely to change the outcome rather than uniformly on every iteration. This is a budget-allocation refinement to Verification, not a replacement for it: the default disposition is still "verify," and the schedule only skips the check when a calibrated confidence signal (not the maker's self-report of correctness — see Verifier Theater) crosses a threshold. Framed by the source as a way to cut wasted GPU compute in long-running agent loops. (MindStudio, "Confidence-Scheduled Verification: How DeepSpark Cuts Wasted GPU Compute", Jul 2026.)
A stated intent, not a measured result. Peter Steinberger quote-tweeted @Altimor's "CI has become the top bottleneck of every engineering team I talk to (including Lindy). Our CI spend has become stratospheric." He described a plan rather than an outcome: "My plan is to let codex decide which tests actually need to run and drastically nix CI and run tests hourly." No cost or coverage figures have been published for it; the only cadence is the stated "run tests hourly". This goes a step further than confidence-scheduling when to verify — it has the agent choosing which checks run at all; see Verifier Integrity: Keeping the Check Unfakeable for what has to hold for a self-selected check to stay trustworthy. (@steipete, @Altimor, Sep 2026.)
Multi-Dimensional Budget Pressure¶
Rather than one ceiling (e.g. --max-budget-usd), track several budget dimensions at once
— tokens, tool calls, wall-time, dollars — and collapse them into a single pressure
scalar (the maximum utilization ratio across all four), so the loop degrades gracefully
as any dimension approaches its limit rather than only reacting to whichever one happens
to run out first:
| Pressure | Behaviour |
|---|---|
| < 0.7 | Full pipeline runs (Planner → Worker → Critic, all verification passes) |
| > 0.9 | Skip the Critic stage — degrade quality checks before halting entirely |
| = 1.0 | Halt, return partial results |
The design intent stated by the source: budget pressure makes degradation deterministic, not the LLM's own behaviour — the loop's response to running low on any resource is a designed step function, not an emergent property of the model deciding to wrap up. Pairs directly with this doc's Operational Kill/Pause/Slow-Down Thresholds below, one level down: those thresholds are inter-run policy (should this loop keep running at all); this is intra-run degradation (how one run's remaining budget should shape what it still attempts). (explainx.ai, "Basic Agent Loop to Production Harness", Aug 2026.)
A Concrete Countermeasure to Intent Debt: Ponytail¶
Intent debt — an agent silently filling gaps with plausible-
sounding but undocumented decisions — has a measured countermeasure at the
implementation-pattern level. Ponytail is a Claude Code/Codex skill/plugin enforcing a
six-step decision ladder before an agent is allowed to write new code: does it need to
exist at all → is it already in the codebase → does the standard library cover it → is
there a native platform feature → is there an installed dependency → only then write new
code. (Example: a date picker becomes a native HTML <input type="date"> instead of a
new library dependency.) Benchmarked on 12 feature tasks against a FastAPI template:
-54% lines of code, -22% tokens, -20% cost, +27% faster execution, with safety ratings
held at 100% in both runs — the rules explicitly protect validation, error handling,
security, and accessibility work, and only target unnecessary abstractions, wrappers,
config, and dependencies. A rare case of a named overengineering countermeasure with a
same-task, before/after benchmark rather than an anecdote.
(MindStudio, "Ponytail Benchmark", Sep 2026 — plugin by Dietrich Ayala, MIT-licensed.)
Handle result subtypes¶
if message.subtype == "error_max_turns":
# Resume the session with a higher limit
resume_session(session_id, max_turns=60)
elif message.subtype == "error_max_budget_usd":
alert("Budget exceeded — review and restart")
Operational Kill / Pause / Slow-Down Thresholds¶
Define explicit decision rules for three escalation levels before deploying any production loop:
| Signal | Action | Threshold example |
|---|---|---|
| Budget overspend mid-period | Slow down — reduce cadence or skip non-urgent runs | Budget >80% consumed before week mid-point |
| High false-positive rate | Slow down — human reviews before loop re-runs | False positives >30% of runs in a 7-day window |
| Production incident or schema migration | Pause — halt loop until incident resolved | Any active Sev-1 or open migration PR |
| Two consecutive weeks of negative cost-to-value | Kill — decommission the loop | 14 days: every run costs more than the defects it catches |
| Consistent loop failures | Kill | Loop fails to complete successfully 3+ times per week for 2 weeks |
| Team disengagement | Kill | No human has read a loop report in 14 days |
These thresholds are deployment prerequisites, not optional monitoring. Define them before the first production run — they cannot be calibrated after a runaway event.
(cobusgreyling/loop-engineering, Jun 2026.)