Agent Teams teammate delivery intermittently triggers full conversation cache rewrite (~400-513k cache_creation; only system+tools survive)
Summary
Agent Teams teammate-message delivery into a long-running session intermittently triggers a full conversation cache rewrite: cache_read_input_tokens drops to ~21–22k (system + tools prefix only) and the entire messages array is re-written at the cache-write premium (cache_creation_input_tokens 396k–513k per event in our sessions). The trigger is intermittent: in our telemetry, 3 out of 44 externally identical deliveries busted; 41 stayed warm.
Environment: Claude Code 2.1.217, Linux, model claude-fable-5, long sessions (500k+ context), 1h cache TTL, Agent Teams (teammate mailbox) in active use.
Signature (from session transcripts, message.usage)
One second before a busted delivery the cache was demonstrably warm:
14:05:29 assistant cache_read=530k cache_creation=0k (warm)
14:05:30 system subtype=stop_hook_summary
14:05:30 user <teammate-message …> (6,385 chars)
14:06:06 assistant cache_read=21k cache_creation=513k (FULL REWRITE)
All bust events share this exact shape: only system+tools (~21–22k) survive; the break sits at the start of the messages array.
Telemetry: 3 busts vs. 41 warm deliveries — no external discriminator
We scanned all our session transcripts (4 days) and measured every teammate delivery (n=44 across 2 fable sessions): payload size and gap to the previous assistant entry.
| Event (UTC) | cache_creation | payload | gap to turn end |
|---|---|---|---|
| Jul 22 20:33 | 420k | 2,392 chars | 0.104 s |
| Jul 23 03:22 | 396k | 4,507 chars | 3.563 s |
| Jul 23 14:06 | 513k | 6,385 chars | 0.106 s |
Hypotheses we could refute with the 41 warm counterexamples:
- Payload size: warm deliveries up to 20,124 chars; busts as small as 2,392.
- Same-second race with a Stop hook: dozens of warm deliveries at 0.05–0.5 s gaps; one bust at 3.6 s.
stop_hook_summarypresent before delivery: present before busts and several warm deliveries.- Queued (mid-turn) vs. direct delivery: both variants occur warm and busted.
- CLAUDE.md / config file changes before the request: no corpus changes anywhere near two of the three busts.
Conclusion: busted and warm deliveries are indistinguishable in every externally observable property — the discriminator lives inside Claude Code's request assembly (two delivery/assembly paths, or a nondeterministic race).
Relation to existing issues
- #27048 (mid-session state change → full user-content rewrite, system preserved; closed as not planned): same class and signature — this report adds a first-party trigger (Agent Teams delivery, an actively promoted feature) plus field telemetry.
- #42338 (session resume invalidates entire cache): related but distinct — our events happen mid-session with the cache demonstrably warm one second earlier.
- #47098 (no cache marker between auto-injected
messages[0]content — hooks, skills, project CLAUDE.md, deferred tools, MCP descriptions — and the first real user content): the mechanism proposed there fits our signature exactly (system+tools survive, everything frommessages[0]on is invalidated). If teammate deliveries (sometimes) mutate that auto-injected head region, an unmarked mutation would produce precisely what we measure — and the intermittency would come from when that region is regenerated.
Impact
On large-context sessions each event re-writes 400–513k tokens at the cache-write premium. Users running Agent Teams on expensive models pay this repeatedly and cannot mitigate it: the receiving side has no hook point, and our data shows sender-side heuristics (message size, delivery timing) don't correlate with the bust.
Ask
- Add the missing cache breakpoint after the auto-injected
messages[0]head (as proposed in #47098), and/or - make teammate-delivery assembly deterministic w.r.t. the cached prefix (append-only), and
- if helpful, we can provide the full transcript excerpts (usage lines + entry sequences) for the three events.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗