↓ Skip to main content
  1. Articles/

Claude Code Subagent Cost Controls: autoCompactWindow, Workflow Model Pinning, and Cache-Write Telemetry

·772 words·4 mins·
Florent Clairambault
Author
Florent Clairambault
CTO & software engineer — writing daily about spec-driven development and agentic coding

Claude Code Subagent Cost Controls: autoCompactWindow, Workflow Model Pinning, and Cache-Write Telemetry

Multi-agent setups get expensive in a boring way. No single call is outrageous. Ten subagents each drag a bloated context through a dozen turns, and the bill arrives as a surprise. The last two Claude Code releases add three small controls aimed at exactly that. Everything below comes from the official changelog. I have not run these features hands-on, so treat the behavior descriptions as the changelog’s claims, not my measurements.

autoCompactWindow: compaction per subagent
#

v2.1.296 (October 9) added autoCompactWindow to subagent frontmatter and to --agents definitions. The changelog’s wording: a subagent can now auto-compact earlier than the main conversation’s window.

Why it matters: a research subagent that greps a monorepo accumulates tool output fast. Previously it inherited the same compaction threshold as everything else. A short-lived worker rarely needs a huge window. It needs to finish and hand back a summary. Setting a smaller window per agent keeps each turn’s input smaller, which is where most of the spend sits.

A sketch of what the frontmatter might look like (field name from the changelog; the value and its unit are my assumption, so check the docs before copying):

---
name: repo-scout
description: Finds call sites and summarizes them
model: haiku
autoCompactWindow: 60000
---
Search the codebase for the requested symbol. Return a summary of at most 20 lines.

CLAUDE_CODE_WORKFLOW_SUBAGENT_MODEL: one model for the whole workflow
#

Also in v2.1.296: the CLAUDE_CODE_WORKFLOW_SUBAGENT_MODEL environment variable runs every workflow agent on one model, while other subagents keep theirs.

This pairs naturally with Haiku 5.5’s pricing as a cheap worker tier. Fan out a workflow of twenty agents and you can force the entire fan-out onto a small model with one variable, rather than editing each definition. The trade-off is obvious and worth saying out loud: a pinned cheap model on a hard step will fail more, and you will pay for the retries. Use it for mechanical fan-out such as per-file review or migration passes, not for the planner.

The same release also priced Sonnet 5.5 cache reads at $0.10 per million tokens in /cost, the status line, --max-budget-usd, and the SDK (it was $0.20). That is a display-side correction to match the halved price, but it means budget caps now count differently, so a limit you tuned last month will stretch further.

Cache-write telemetry in v2.1.300
#

v2.1.300 (October 14) added cache_creation_5m_tokens and cache_creation_1h_tokens to the OpenTelemetry api_request event, splitting cache writes by lifetime.

This is the piece I’d adopt first. Last week’s idle-compaction change in v2.1.299 exists because a one-hour prompt cache expiring mid-session forces a full reprocess. Until now you could see that cost only in aggregate. With the split, you can answer concrete questions:

  • Are my subagents writing 1-hour cache entries for work that lasts three minutes?
  • Which workflows churn 5-minute entries because they idle between turns?
  • Did a config change move writes between buckets?

If you already export OTel to a dashboard, adding two fields to a panel is cheap. If you don’t, this is a decent reason to start.

Smaller changes worth a line
#

  • Large requests to api.anthropic.com now use gzip compression even with telemetry disabled; CLAUDE_CODE_GZIP_REQUEST_BODIES=0 turns it off. If you run behind a proxy that inspects bodies, test this before rollout.
  • Exit now force-kills background commands still running 1.5 seconds after being asked to stop. Good for leaked processes, bad if you relied on a background job surviving a quit.
  • CLAUDE_CODE_OVERLOADED_RETRY_MAX_DELAY_MS sets a longer maximum backoff for 529 overloaded retries, useful for unattended runs.
  • The MCP tool-description cap sent up front moved from 2,048 to 4,096 characters.
  • virtualText for mod prompt decorations draws text in the prompt box that never enters the submitted prompt.

What to do this week
#

  1. Add autoCompactWindow to your two or three most-spawned subagents and compare token usage before and after.
  2. Pin mechanical workflow fan-out with CLAUDE_CODE_WORKFLOW_SUBAGENT_MODEL, keep planning on your strongest model.
  3. Add the two cache-creation fields to your telemetry so you can see what you are paying for.

The bigger point
#

This is the unglamorous side of spec-driven development. When the spec is good and the agents run unattended, cost per run becomes a property you tune, like latency. Editor-bound tools that keep a human approving each step never face this problem, because the human is the throttle. A terminal-native agent that fans out to dozens of workers needs budgets, per-agent limits, and telemetry, and Claude Code is now shipping them release by release. That is what autonomy at scale requires. The caveat stands: until someone publishes measurements, how much these save is unknown. Measure your own runs.

Sources
#

Guides

Claude Code v2.1.299: Stricter MCP Allow Rules, Fail-Closed Plugin Hooks, and Idle Compaction

Claude Code v2.1.299 (Oct 14) narrows MCP allow rules to the exact named server, makes plugin hooks that can’t answer refuse the action, stops following redirects on connector proxies, and compacts idle 200K+ token sessions before the one-hour cache expires.

Oct 14, 2026 · 5 min read

Guides

Claude Code Now Speaks MCP 2026-07-28 by Default. Here's What That Does to Your Servers

Since Claude Code v2.1.292 (Oct 6) local stdio MCP servers negotiate protocol 2026-07-28 by default, and v2.1.295 (Oct 8) does the same for claude.ai connectors. Servers that ignore the check get remembered for 7 days and connected the old way; MCP_PROTOCOL_NEGOTIATION=legacy opts out.

Oct 13, 2026 · 5 min read

AI Tools

Claude Code Hooks Can Now Fail Closed: onFailure: block and What v2.1.293–296 Changed

Claude Code v2.1.295 (Oct 8) added onFailure: “block” for command and HTTP hooks, so a hook that crashes, times out or exits unexpectedly now blocks the action instead of silently allowing it. v2.1.294 also fixed instruction-style prompt hooks that allowed what they were meant to block, while the MCP description limits changed twice in 48 hours.

Oct 10, 2026 · 6 min read

AI Tools

Claude Haiku 5.5: A $0.10 Subagent Model With Effort Levels, and Why It Isn't Your Main Coder

Anthropic released Claude Haiku 5.5 on October 7, 2026 at $0.10/$0.50 per million input/output tokens for prompts up to 100k, roughly 75% cheaper than Haiku 4.5 on average. It scores 39.2% on Terminal-Bench 4.0 against 70.6% for Sonnet 5.5, which makes it a subagent and compaction model rather than a primary coder.

Oct 9, 2026 · 5 min read

AI Tools

Claude Code v2.1.271: Per-Command Domain Allowlisting Is the Kind of Security Feature Nobody Announces

Claude Code v2.1.271 (Sept 14) added per-command allowed_domains for Bash, PowerShell, and Monitor in auto mode with sandboxing, plus omitClaudeMd for subagents, fast mode in Remote sessions, and a marked-up pricing multiplier for internal chargeback. None of it got a launch post — it shipped as one changelog among 60-plus line items.

Sep 15, 2026 · 5 min read