[FEATURE] Allow subagents to inherit the parent's prompt cache for shared dynamic context
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
Subagents cold-start on context the parent has already prefilled and cached. When a parent briefs a child, it re-serializes task context (repo canon, file contents, prior findings) into the child's prompt, and the child pays full prefill on it. The parent's cached copy is not reusable across the invocation boundary.
This is distinct from the static-prefix waste measured in #74318. That issue targets content that is identical across all subagents of a type (system prompt, tool schemas, project rules), ~97% of a ~37k cold start. The tokens here are the opposite: dynamic, parent-accumulated, task-specific, and different for every parent; none of that issue's three fixes reach them.
The waste scales linearly with fan-out width, and is worst in the pattern where fan-out is most valuable: dispatching N read-only analysis agents over a shared body of context.
Proposed Solution
When a subagent runs on the same model as its parent, let it inherit the parent's existing cache for any shared prefix instead of re-prefilling it. concretely: widen prompt-cache reuse from "across turns within one session" to "across invocations within one agent tree."
Same model, same weights, same tokenizer; no representation alignment, no adapters, no new wire format. #74318 establishes that meaningful gains here are reachable with the existing GA prompt-caching API; this is a scope change to what may be shared and with whom, not new machinery.
Framed against that issue's fix 2 ("persistent per-type prefix"), this is the same mechanism with its scope widened from static-shared-across-siblings to parent-derived-shared-with-children.
Degrades gracefully: no shared prefix, or a model mismatch between parent and child, and it is an ordinary cold start.
Alternative Solutions
- Resume an existing subagent with a follow-up instead of spawning a fresh one. Works, and is already the documented guidance, but only helps when the work is a continuation. It does nothing for genuine parallel fan-out, where the children are independent.
- Write shared context to a file and have each child read it. Trades prompt tokens for tool-call round trips and still costs each child a full prefill of the content.
- Hand-minimise brief length. Reduces the waste but does not remove it, and trades against brief quality. Under-specified subagents fail more, which costs more than the tokens saved.
- Implement 74318's three fixes only. Valuable and orthogonal, but bounded to the static prefix; the dynamic prefix remains fully duplicated.
Priority
Medium - Would be very helpful
Feature Category
Performance and speed
Use Case Example
Orchestration session on an offline Python project (~325 tests). The parent thread read project canon, three design briefs and several source files, then dispatched three read-only analysis subagents in parallel. Strategy chosen specifically because read-only stages cannot conflict, so they can run concurrently while write stages are serialized.
Each child was briefed from overlapping parent context: same repo layout, same prior commits, same source files, differing only in the question asked. The three consumed roughly 83k / 107k / 127k tokens; a fourth ran at ~94k. The parent had already prefilled and cached the shared portion before any of them were spawned.
With cache inheritance, only the per-child delta (the actual question, typically a small fraction of the brief) would need prefilling.
Additional Context
Applicability: this is not workflow-specific. Any parent that briefs children from shared context pays this cost: code review fanned out across dimensions, parallel file analysis, multi-agent verification, migration sweeps, etc. The cost scales with fan-out width, so it grows precisely as agentic pipelines get more parallel.
Related: #74318 (subagent prompt-cache strategy, ~14% of subagent input cost). That issue and this one are complementary (static prefix vs dynamic prefix), and its fix 2 is the natural place this would generalize from. Cross-linked deliberately rather than filed as a duplicate.
Scope note: this does not involve latent or vector inter-agent communication. Subagents still emit ordinary text; reports, diffs and tool calls remain fully readable. Review workflows that depend on inspecting what an agent actually did are unaffected. This is solely about not recomputing a prefix twice.
Evidence caveat: the figures above are from a single session on one project and are illustrative, not a benchmark. #74318 carries the rigorous measurement (95 sessions, ~1,800 subagents, 6.8B input tokens); the argument here is structural.