Bug: Context becomes full and /compact stops working after using subagents (Task tool)
Status Closed — not planned
Maintainer reply None cached
Workaround ✓ Mentioned in thread ↓
Activity 13 comments · opened Jan 4, 2026 · closed Mar 18, 2026
Description
When using subagents via the Task tool, context usage can spike rapidly and reach 100% capacity. At this point, the /compact command becomes unresponsive, leaving users with no way to recover the session.
Steps to Reproduce
- Start a Claude Code session
- Use the Task tool to spawn a subagent (e.g.,
subagent_type: Exploreorgeneral-purpose) - The subagent performs file reads, greps, and other operations
- Context usage jumps significantly after subagent returns
- Repeat subagent usage 2-3 times
- Context reaches ~100%
- Attempt to run
/compact - Command fails or is ignored
Expected Behavior
/compactshould work especially when context is near capacity (this is when users need it most)- Or: automatic context management before reaching critical levels
Actual Behavior
/compactbecomes unresponsive when context is full- User loses all session work and must start a new session
- No warning before reaching this state
Proposed Solutions
- Reserve context space for
/compact- Always keep enough headroom to execute compaction - Subagent result summarization option - Allow users to receive summarized results instead of full output
- Context usage warnings - Alert users at 70%, 80%, 90% thresholds
- Auto-compact option - Automatically compress context when reaching a threshold
- Graceful degradation - If
/compactcan't run normally, provide a minimal emergency compaction
Environment
- OS: macOS (Darwin 24.5.0)
- Claude Code version: $(claude --version 2>/dev/null || echo "unknown")
Impact
This issue causes significant workflow disruption. Users lose context, unsaved work patterns, and must restart complex debugging or exploration sessions from scratch.
13 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
Related Issues
This issue is related to several existing reports:
/compactfailure despite having free context spaceMy specific case involves subagent (Task tool) usage rapidly consuming context, leading to a state where
/compactbecomes unresponsive. If this is considered a duplicate, feel free to close.Also occurred for me in this exact scenario today.
Do you see multiple skills that the subagents load, show up in your context, after compaction?
+1 — hitting this consistently. After heavy subagent (Task tool) usage, context fills up and
/compactstops being able to recover the session. The only workaround is starting a fresh conversation.This pairs with #23463 — subagent results silently overflow the parent context, and once that happens, compaction can't dig out of the hole. The combination of these two issues makes multi-agent workflows fragile: you get maybe 2-3 rounds of parallel agent work before the session is toast.
Would be great if
/compactcould aggressively summarize or drop subagent result blocks when the context is critically full, rather than failing silently.Do you also see the skills loaded by subagents into the main context?
I can confirm this bug and currently working with claude code as an agenting development is just impossible.
Agents context window is shared between agents and main claude code context:
● Agent "Create Certifications migration+model" completed
⎿ Context limit reached · /compact or /clear to continue
● Agent "Add CRS org settings migration" completed
⎿ Context limit reached · /compact or /clear to continue
● Agent "Create CRS models and migration" completed
⎿ Context limit reached · /compact or /clear to continue
● Agent "Add Authorization access matrix" completed
⎿ Context limit reached · /compact or /clear to continue
● Agent "Auth routes, controller, sidebar" completed
⎿ Context limit reached · /compact or /clear to continue
This I got in same moment.
Hi @ariccio - I saw multiple agents loading and running, but once context full, the system was not functional, so could not trigger compaction.
See if this reproduces for you:
https://github.com/anthropics/claude-code/issues/23257#issue-3899431790
Tried the example case and it compacted well. I'll give the subagents approach a try again!
Luckily, it got patched today!
https://github.com/anthropics/claude-code/issues/23257#issuecomment-3916610937
Closing for now — inactive for too long. Please open a new issue if this is still relevant.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.