[Feature Request] Subagents should inherit parent agent context to avoid redundant codebase scanning
Status Fixed / completed
Maintainer reply None cached
Workaround ✓ Mentioned in thread ↓
Activity 11 comments · opened Dec 1, 2025 · closed Aug 17, 2026
Hey it would be really awesome if claude could spawn its subagents with the main agent's existing context. That way the subagents don't need to go around scanning the codebase for knowledge the main agent already has. Also means we won't have to do an expensive compact/compress to feed instructions and context into every agent.
This should be a frontmatter setting in each agent. Some agents would greatly benefit from this, for example test runner agents that prevent the main agent's context from being filled with junk.
Showing cached comments. Read the full discussion on GitHub ↗
10 Comments
Yes - need this big time. I have related, but opposite problem - i'm trying to save context in a planning agent by having it spawn subagents to straightforward stuff (like write documents, etc.). The idea being that file writing is context expensive. But the cost of transferring context to an agent eats up the savings from file writing. "Spawn" would solve this nicely.
BTW - anyone with a different workaround for my issue, let me know (i've reached the limits of my creativity on this one...)
This would be epic. Most subagent use-cases would benefit, enabling more frequent delegation even as the context window grows, without wasting context:
Write tests
Some new use cases may emerge:
Shouldn't be just frontmatter though, the main agent should be allowed to decide (also for a generic Task)
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
I really think this is the optimal behavior for a large percentage of the agents (and skills and commands) people currently create.
Right now, if you want to define a re-usable prompt for something that involves a lot of detailed thinking/tools you have to choose between:
--fork-sessionor read the conversation history log files (very wasteful because of lack of token caching).As an example: The other day I wanted to implement a
/reflectskill that asks Claude to look back at the conversation so far, identify anything it got hung up on or had to hack around, and brainstorm specific followups that would make the process smoother in the future. As far as I can tell, there is effectively no way to implement something like that right now without dumping all of the intermediate brainstorming into the main context.I think the _ideal_ solution would be for the existing
context: forkoption on skills to work this way (and to create some other option likecontext: isolatedfor the current behavior). This naming would be more consistent with what the--fork-sessioncli option.https://code.claude.com/docs/en/skills#run-skills-in-a-subagent
(That's a breaking change though, so I'm assuming the Claude Code team would want to do something slightly different)
Rather than the breaking change I think it could just be a new argument for the Task tool and/or a new field in the subagent frontmatter. I'm honestly surprised this hasn't been prioritized, it seems so obvious
Adding evidence from a heavy production user (11 custom agents, daily use since Dec 2025, v2.1.70).
What We Tried
We have 11 specialized agents (pipeline orchestrator, RAM safety auditor, VOLD analysis, news/shock agent, live ops monitor, etc.) for a 0DTE options trading system. Each agent has detailed instructions in its definition MD file.
Over the past month, we systematically tried to get sub-agents to follow instructions:
What Actually Works
The only reliable way to get a sub-agent to follow instructions is to put them directly in the
promptparameter of the Agent tool call. Agent definition MDs and CLAUDE.md are effectively decorative for sub-agent behavior.Impact
This makes the agent architecture unreliable for real production use. We configure detailed instructions in agent MDs and CLAUDE.md expecting them to cascade to sub-agents — and they silently don't. The main session follows the rules, spawns a sub-agent, and that sub-agent flies blind.
Related issues confirming the same class of problem: #5528 (all directives ignored, locked), #4554 (name-based override), #7166 (CLAUDE.md inheritance undocumented), #22177 (inheritance flip-flopped between versions), #7515 (locked), #8395 (rule propagation, locked), #24773 (identity conflicts), #6825 (context inheritance configurable).
This is arguably the most fundamental gap in the agent system — everything else (permissions, hooks, compaction) is secondary if sub-agents can't read their own instructions.
Yes I agree. It should be an option Claude can decide.
Would save a lot of tokens when Claude decides
+1 on this. One specific use case: after a long investigation session, I'd love to spin off a subagent that inherits the full conversation context to generate documentation about what occurred — while I continue working in the main conversation in parallel.
Today the only options are
/fork(interactive, blocks you) or the Agent tool (no parent context). A background fork that inherits context would bridge that gap.One request: please consider making context inheritance opt-in (e.g.
inherit_context=true) rather than the default. Subagents starting fresh is a useful property for isolated tasks, and changing the default would break existing workflows that rely on clean subagent contexts. Backwards compatibility matters here.We experimentally confirmed the current limitations:
/branchtext passed to Agent prompt → treated as plain string, no historyresume→ "No transcript found" (only subagent IDs work)/forkworks for interactive branching but can't be dispatched as backgroundA
PreToolUsehook on the Agent tool can inject context into every subagent launch:A more practical approach: maintain a
project-context.mdthat gets injected viaUserPromptSubmit:Then auto-generate the context file periodically:
This ensures subagents (which also trigger UserPromptSubmit hooks) automatically receive the project context without the main agent needing to pass it explicitly.