Deep dive · developers and IT adminsRevised October 2026

Subagents &
Prompt Caching.

Separate working contexts. Reuse matching input.

David Budáč
2
In practice

Two mechanisms, two different outcomes

Delegation

Separate an investigation and return useful evidence.

Caching

Reuse computed work on eligible matching input.

We will follow two helpers investigating an invoice export.

3
Architecture

Where the work happens in this example

Your computer

Harness
Lead + helper loops
Local test tools

Provider cloud

API endpoint
Model inference
Provider prompt cache

request → network → response

Example topology: a local harness calling a hosted model. Harnesses and tools can also run remotely.

4
Split the work · subagents

Delegate a question; ask for evidence back

  • Fresh helpers need a self-contained task and relevant inputs. Forks can inherit existing history.
  • Keep intermediate investigation in the helper’s context; return findings with file references.
  • Review the result. Delegation adds coordination cost and does not itself isolate filesystem access.

Example return: VAT calculation locations, the failing path, supporting lines and unresolved questions.

5
In practice

Delegate → investigate → return → integrate

Delegate

Task, inputs, limits and expected return.

Investigate

Helper uses tools within its own working context.

Integrate

Lead checks the returned evidence and resolves conflicts.

These are lifecycle steps. The investigation is not a network crossing.

6
In practice

Choose what the helper inherits

Fresh helperConversation fork
Task prompt plus its configured instructions and tools.Existing conversation and configured environment.
Provide the invoice rule and paths explicitly.Useful when the background is expensive to restate.

In both cases, specify scope and the evidence to return. Claude Code subagents and forks

7
In practice

Ask for an answer you can inspect

TASK: locate invoice VAT and CSV formatting paths. RETURN: - finding + file and line reference - relevant test or observed output - uncertainty and missing evidence - suggested next check SCOPE: read-only investigation; do not change files.

A short unsupported conclusion saves tokens by discarding the part you need.

8
In practice

Parallelize independent investigations

Helper A

Locate VAT calculation and its tests.

Helper B

Locate CSV formatting and escaping tests.

Lead

Resolve the shared contract and own the final patch.

Independent reads can overlap. Edits need ownership and an integration step.

9
In practice

Count the setup and the review

Potential benefit

Less raw investigation in the lead context; shorter elapsed time for independent work.

Additional work

Helper input, generated output, coordination and checking the returned findings.

Delegation can be worthwhile without being cheaper. Compare accepted outcomes.

10
In practice

One model call is not a tool-using helper loop

PSEUDOCODE context = task + configured_instructions while budget_remains: response = model(context) if response.requests_tools: context += permitted_tool_results(response) else: return structured_findings(response) return incomplete_report()

Handle errors, multiple content blocks and stop reasons in real code.

11
In practice

A compact trace still needs evidence

ILLUSTRATIVE — not a recorded Claude Code session Lead: investigate invoice calculation and export. Helper A: calc.py applies no VAT; see invoice rule. Helper B: export.py writes the calculated total unchanged. Lead: verify those findings, then plan one scoped patch.

Tool counts, timings and costs should come from a real run if you quote them.

12
The bill · KV cache · how

Caching reuses work on a matching prefix

  • A prompt cache can reuse computed state for eligible, matching earlier content.
  • Keep reusable instructions stable. Changes can invalidate the affected prefix and later content.
  • Inspect cache usage records: expiry, minimum length and provider rules affect whether you get a hit.

Animation shows prefix reuse. Its price label is illustrative; rates vary. Cached content still occupies context.

13
In practice

Keep the shared material before the questions

Shared eligible prefix tools + stable instructions + invoice schema Request A: Where is VAT applied? Request B: Where is CSV escaping handled? Changing the question need not change the shared prefix.

A matching prefix must be eligible and already cached; stable text alone does not create a hit. Caching docs

14
Count the work

Count each billing category separately

CategoryWhat to record
Uncached inputNew input processed at its applicable input rate.
Cache writes and readsSeparate token counts and the configured cache rates.
Generated outputOutput usage, including billable reasoning where applicable.

Bill = sum of each category’s tokens × its rate, plus any separate tool or service fees.

15
Worked arithmetic

Include the write before counting savings

Same eligible prefix; all later requests hit the cache. Normalize ordinary input cost to 1 per request. Total cached cost = w + (n − 1)r Caching saves when w + (n − 1)r < n. Example r = 0.10: w = 1.25 → savings at 2 requests w = 2.00 → savings at 3 requests

Illustrative multipliers: verify model, platform, TTL and expiry rules. A cache miss changes the calculation.

16
In practice

Reuse depends on a live, eligible entry

  • Claude documents a default five-minute cache lifetime and an optional one-hour lifetime.
  • A use refreshes the lifetime from the request start; generation time counts against it.
  • Minimum prefix length, matching, platform support and writes also determine hits.

Check the usage fields and current configuration. Provider caching documentation

17
In practice

Look for what was read and written

Usage recordMeaning
cache_creation_input_tokensNew content written to the prompt cache.
cache_read_input_tokensInput reused from a cache entry.
Uncached input and outputAdditional work outside that cached read.

Zeros are a diagnostic clue, not proof of why the cache missed. Compare complete task cost.

18
In practice

Concurrent requests do not guarantee shared hits

1. Prepare one eligible prefix and matching cache settings. 2. Start a request that writes that prefix. 3. Wait until its response begins and the entry is available. 4. Send matching helper requests; inspect cache usage.

Cold simultaneous requests can duplicate cache writes. Claude cache limits

19
In practice

Choose the supported client and credential path

Native Claude Code use

Sign in through the official flow under the applicable plan and usage rules.

Your product or service

Use API-key authentication or a supported cloud-provider route.

The boundary is not simply “human at keyboard” versus “automation”. Current authentication guidance

20
In practice

Separate investigation. Verify reuse.

  • Give helpers explicit inputs and require evidence in the return.
  • Separate working contexts do not enforce filesystem or network isolation.
  • Warm eligible shared prefixes and inspect actual cache reads and writes.

Delegation changes where work accumulates. Caching changes the processing cost of repeated input.

Optional reference material

21
Sources

Sources and further reading

Primary documentation checked 3 October 2026. Examples are illustrative unless explicitly attributed.