Bug: Context becomes full and /compact stops working after using subagents (Task tool)

Status Closed — not planned
Maintainer reply None cached
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

  1. Start a Claude Code session
  2. Use the Task tool to spawn a subagent (e.g., subagent_type: Explore or general-purpose)
  3. The subagent performs file reads, greps, and other operations
  4. Context usage jumps significantly after subagent returns
  5. Repeat subagent usage 2-3 times
  6. Context reaches ~100%
  7. Attempt to run /compact
  8. Command fails or is ignored

Expected Behavior

  • /compact should work especially when context is near capacity (this is when users need it most)
  • Or: automatic context management before reaching critical levels

Actual Behavior

  • /compact becomes unresponsive when context is full
  • User loses all session work and must start a new session
  • No warning before reaching this state

Proposed Solutions

  1. Reserve context space for /compact - Always keep enough headroom to execute compaction
  2. Subagent result summarization option - Allow users to receive summarized results instead of full output
  3. Context usage warnings - Alert users at 70%, 80%, 90% thresholds
  4. Auto-compact option - Automatically compress context when reaching a threshold
  5. Graceful degradation - If /compact can'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.

View original on GitHub ↗

13 Comments

github-actions[bot] · 7 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/16025
  2. https://github.com/anthropics/claude-code/issues/15957
  3. https://github.com/anthropics/claude-code/issues/15191

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

hiranotomo · 7 months ago

Related Issues

This issue is related to several existing reports:

  • #1168 - Error compacting conversation when context at 0%
  • #6616 - /compact failure despite having free context space
  • #15957 - Context compaction race condition with parallel async agents
  • #13112 - Auto-Compact causes context loss

My specific case involves subagent (Task tool) usage rapidly consuming context, leading to a state where /compact becomes unresponsive. If this is considered a duplicate, feel free to close.

narath · 7 months ago

Also occurred for me in this exact scenario today.

ariccio · 6 months ago
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?

gabrielbryk · 6 months ago

+1 — hitting this consistently. After heavy subagent (Task tool) usage, context fills up and /compact stops 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 /compact could aggressively summarize or drop subagent result blocks when the context is critically full, rather than failing silently.

ariccio · 6 months ago
+1 — hitting this consistently. After heavy subagent (Task tool) usage, context fills up and /compact stops 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 /compact could 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?

Notum · 6 months ago

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.

narath · 6 months ago
> 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?

Hi @ariccio - I saw multiple agents loading and running, but once context full, the system was not functional, so could not trigger compaction.

ariccio · 6 months ago
> > 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? 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

narath · 6 months ago
> > > 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? > > > 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: #23257 (comment)

Tried the example case and it compacted well. I'll give the subagents approach a try again!

ariccio · 6 months ago
> > > > 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? > > > > > > 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: #23257 (comment) 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

github-actions[bot] · 5 months ago

Closing for now — inactive for too long. Please open a new issue if this is still relevant.

github-actions[bot] · 5 months ago

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.