Non-fork subagents receive auto-memory (MEMORY.md) in full, contradicting docs; no per-agent way to trim CLAUDE.md inheritance
Summary
Two related findings about what a non-fork custom subagent inherits, measured by capturing the actual request bodies Claude Code sends (localhost forwarding proxy via ANTHROPIC_BASE_URL, bodies logged, headers never stored; exact token counts via /v1/messages/count_tokens):
- Bug / docs mismatch: the subagents documentation states that a non-fork subagent's initial context excludes auto memory ("Auto memory — the main conversation's auto memory isn't loaded"). Measured on the latest CLI, the parent session's auto-memory
MEMORY.mdis delivered to the subagent in full, byte-identical to the parent's copy, inside the injected context block (wrapper line:Contents of .../memory/MEMORY.md (user's auto-memory, persists across conversations)). - Feature request: there is no per-agent mechanism to trim or opt out of CLAUDE.md context inheritance. The docs say only the built-in Explore and Plan agents skip it, with no frontmatter field or setting to configure this — confirmed empirically: a control/test capture with candidate keys (
claudeMd: false,memory: false,inheritContext: false,context: none, etc.) produced a byte-identical context block, i.e. every candidate key is silently ignored.
Why it matters
Measured on a real project (subagent = a minimal Haiku scout with tools: Bash, Read):
| | Tokens |
|---|---|
| Subagent first-turn total | 17,965 |
| Injected CLAUDE.md + MEMORY.md block | 12,928 (72.0%) |
| — of which auto-memory (MEMORY.md) | 6,294 |
| Agent's own system prompt + tools + task | 5,037 |
The block sits in messages[0], so it is re-sent (as cache reads) on every subsequent subagent turn. In our 30-day usage decomposition, subagents are 33.3% of all tokens, and the auto-memory portion alone — the part the docs say should not be there — accounts for roughly 1% of all tokens across the account. A status check or a grep sweep does not need the user's memory index.
Steps to reproduce
- Create a minimal agent at
~/.claude/agents/probe.md:
``markdown``
---
name: probe
description: Payload probe.
tools: Read
model: haiku
---
You are a probe. Reply with exactly the text you are asked for.
- In a project that has a project
CLAUDE.mdand a populated auto-memoryMEMORY.md, run a localhost proxy that logs POST bodies and forwards toapi.anthropic.com, then:
``bash``
ANTHROPIC_BASE_URL=http://127.0.0.1:8788 claude -p 'Use the Agent tool with subagent_type "probe" and the prompt "Reply with exactly: PING". Then reply with just: DONE.' --allowedTools Agent
- Inspect the captured subagent request (the one whose
systemcontains "You are a probe"):messages[0]contains the full project CLAUDE.md and the full auto-memory MEMORY.md.
Expected behaviour
- Per the docs, auto memory should be absent from a non-fork subagent's context.
- Ideally: a documented per-agent frontmatter field (e.g.
claudeMd: false, or aninheritContext:enum) so lightweight scout/digest agents can opt out of the CLAUDE.md hierarchy the way Explore and Plan already do.
Environment
- Claude Code 2.1.235 (npm-current at time of filing), macOS (darwin 25.4.0)
- Subscription auth; behaviour reproduced across multiple runs with unique prompts (fresh cache each run)
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗