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

Resolved 💬 13 comments Opened Jan 4, 2026 by hiranotomo 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 ↗

This issue has 13 comments on GitHub. Read the full discussion on GitHub ↗