Measure Claude Code subagent spawn cost and use break-even math to decide when to delegate

This guide shows how to measure the fixed token cost (the “spawn tax”) of a Claude Code subagent, compute a break-even threshold that tells you when delegation saves tokens and money, and implement simple routing rules to avoid accidental token burn. All steps are measurement-first: do the probe on your repo; numbers vary by project and toolchain.

Key takeaways

  • Measure your repo's subagent spawn tax with a do-nothing probe; values vary widely.
  • Compute break-even: spawn_tax ÷ (cache-discount × remaining-requests) = inline_read_tokens threshold.
  • Route by task shape and model pinning to cut dollar cost; surface spawn estimates in the UI.
  • Trim auto-loaded files (CLAUDE.md, tool schemas) to reduce fixed payloads.

Why this matters

Spawning a Claude Code subagent is not a cheap thread spawn — it creates a full agent loop and rebuilds that agent’s context window. Anything that auto-loads for the parent (system prompt, project instructions like CLAUDE.md, tool schemas and skills) is serialized into the child. That upfront context can be large enough that delegating becomes more expensive than reading files inline in the parent session unless you cross a break-even point. Measuring your own fixed cost lets you make routing decisions with data instead of guesswork.

Prerequisites

  • Access to your Claude Code project repository (the same harness that spawns subagents).
  • A reproducible task you can run twice: once in-process and once forced through a subagent.
  • Ability to read session-level token metrics (total request tokens or the equivalent delta per run). Prompt-caching metrics are useful if available.

High-level approach

Measure the per-spawn fixed token overhead by running the same minimal task in two modes, computing the token delta, and averaging a few runs. Then use that fixed cost to compute the break-even reading size where delegation costs less than sending tokens inline (accounting for cached re-send discount and expected remaining session requests). Finally, apply routing rules based on task shape and model pinning.

Step-by-step measurement (5–15 minutes)

  1. Pick a trivial probe task that does minimal work but exercises a subagent spawn (for example: “Create a one-line summary of this file”). The probe should avoid reading the file content for the parent run so you isolate spawn overhead.
  2. Run the probe in the parent session without spawning a subagent. Note the session token delta for that request (call this T_parent).
  3. Run the same probe but force it through a new subagent instance (call this T_subagent_run). The subagent should do nothing beyond returning an empty acknowledgement or a one-line response — you want to capture the spawn creation cost, not file processing costs.
  4. Compute the spawn tax = T_subagent_run − T_parent. Repeat the two-run pair at least three times and take the median value to reduce noise from caching or transient differences.
  5. Optional refinement: if your harness exposes cache metrics, measure cache_creation_input_tokens directly with a do-nothing probe subagent; that value is another view of the fixed context payload the child receives at first request.

Interpreting the number

The measured spawn tax represents the token-sized fixed cost paid once when a subagent is created. It is not universal — it depends on what auto-loads into every agent: system prompts, CLAUDE.md, imported project files, and serialized tool schemas (MCP or similar). Teams have reported widely different values; one public measurement reported ~436,000 tokens in a particular setup, while an alternative measurement on the same project that accounted for cached prefixes measured roughly 54,154 tokens. Expect variation and measure yours.

Break-even math (how to decide whether to delegate)

Delegation trades a one-time fixed cost (spawn tax) for avoiding repeated re-sends of large inline reads across remaining requests. Use this formula:

spawn_tax ≈ inline_read_tokens × effective_re_send_multiplier

Solve for inline_read_tokens at break-even:

inline_read_tokens_break_even = spawn_tax ÷ effective_re_send_multiplier

Where effective_re_send_multiplier is the product of two factors:

  • cache resend discount factor (how much cheaper prompt-cached input is when re-sent) — reported examples indicate about an order-of-magnitude discount in some systems;
  • expected number of remaining requests in the session that will re-send the read content.

Example workflows from teams (use these as illustration, not universal constants):

  • Conservative example used by one team: cache-read discount ≈ 10× and ~30 remaining requests ⇒ effective multiplier ≈ 3 (they computed effective N × 3). With spawn_tax ≈ 436k, break-even ≈ 145k tokens (rounded to 200k for safety).
  • Refined measurement that accounts for cached prefixes produced a spawn_tax ≈ 54k tokens ⇒ break-even ≈ 30–50k tokens for same-model delegation; routing the subagent to a cheaper model lowered the dollar cost and brought break-even near ~10k tokens.

Compute your own multiplier by measuring: (a) how many future requests will need the content, and (b) how much the system actually discounts cached re-sends. Plug those into the formula and you have a data-driven threshold for delegation.

Routing rules and practical policies

Use measured thresholds to implement simple, auditable rules that gate subagent spawns. Examples proven useful in practice:

  • Never spawn for a single-file fact. Small reads rarely cross break-even.
  • Bias against spawning unless inline_read_tokens > break-even_threshold. Prefer a safety margin: add 20–50% cushion to avoid borderline spawns.
  • Route by task shape: mechanical bulk reading → pin a mid-tier model subagent; adversarial judgment or synthesis → keep on the large model; orchestration or workflow management → run on the parent harness if the read size is small.
  • Bundle reviewers with overlapping concerns. Two subagents with 80% overlapping context duplicate fixed costs; where concerns overlap, prefer one reviewer with clear rubric.
  • Report and surface spawn cost in the UI/harness. When the estimated token/dollar cost is visible to the user or automation, spawning behavior self-regulates.

Implementation workflow: where to put this in your code

  1. Add a small measurement endpoint or test script in your harness that runs the probe measurement and returns spawn_tax (median of N runs).
  2. Compute a per-project break-even threshold using your expected session length and measured cache discount; store it as a configuration value (e.g., subagent_break_even_tokens).
  3. Before creating a subagent, estimate inline_read_tokens for the content you would otherwise send inline. If it is below the threshold, keep processing in the parent; if above, spawn a subagent and consider model pinning to reduce dollar cost.
  4. Log every spawn with estimated token cost and the reason; expose a simple dashboard to track spawn frequency and cumulative spend.

Common pitfalls and troubleshooting

  • Counting cached prefixes repeatedly inflates the spawn tax. Measure with a do-nothing probe subagent to capture the actual fixed context sent at first request.
  • Ignoring model routing hides dollar trade-offs. The token counts can be similar across models but dollars differ; pinning bulky reads to a cheaper model can shift break-even dramatically.
  • Not accounting for session length. Early in long sessions, delegation becomes cheaper sooner because more future requests will avoid re-sends; late in a session, almost nothing justifies a spawn.
  • Assuming one-size-fits-all thresholds. Different repos and tool schemas change the fixed cost; measure per repo/harness.

Alternatives and trade-offs

Options to consider when delegation looks expensive:

  • Trim auto-loaded project files (e.g., reduce CLAUDE.md or split into modular files that are loaded only when needed). This reduces the fixed payload the child must receive.
  • Use prompt caching aggressively and measure the cache discount; cached re-sends can make inline reading cheaper when the session has many subsequent requests.
  • Pin large, read-heavy subagents to mid-tier models to reduce dollar cost while preserving isolation.

Quick checklist to adopt this in a team

  1. Run the spawn probe on your repo and commit the median spawn_tax to configuration.
  2. Decide expected remaining requests per session for typical workflows and measure cached re-send discount where possible.
  3. Compute break-even and add a safety margin; codify into routing rules.
  4. Expose spawn cost estimates in the harness UI/logs and require a visible confirmation for expensive spawns.
  5. Periodically re-measure after changes to CLAUDE.md, tool schemas, or model routing policies.

FAQ

Q: Is the headline 436k tokens a universal fixed cost?
A: No. That figure was measured in one setup and reported publicly; other measurements on the same project that accounted for cached prefixes found a much smaller fixed payload (~54k). The decisive point is to measure your own spawn_tax.

Q: When should I route a read-heavy job to a smaller model?
A: When model pinning is supported, route mechanical bulk reads to a mid-tier model. This can lower dollar costs and move the break-even point down significantly. Use token-based thresholds to automate the decision.

Q: How often should I re-run the measurement?
A: Re-run after any change that affects what auto-loads into agents (updates to CLAUDE.md, added tool schemas, new skills) or after a policy change to prompt caching or model routing.

Summary

Measure the fixed token cost of spawning a Claude Code subagent in your own repo, compute a break-even threshold using your expected session length and cache discount, and implement routing rules that prevent casual spawns. The qualitative guidance — don’t spawn reflexively, bundle overlapping work, and pin heavy reads to cheaper models — holds across setups; the numeric thresholds do not. Make decisions with measurements, not assumptions.

Stay in Touch

spot_img

Related Articles