Compaction cascade loop when spawning many parallel subagents via Task tool

Resolved 💬 4 comments Opened Feb 23, 2026 by mr-lee Closed Mar 25, 2026

Summary

Spawning a large number of parallel subagents (10-15+) via the Task tool can trigger an unrecoverable compaction cascade. The parent session's context fills rapidly from subagent return values, triggering compaction. But compaction fires session_start internally, which adds overhead back to the context, which triggers more compaction — creating a feedback loop the session cannot escape.

Steps to Reproduce

  1. Start a Claude Code session with several MCP servers configured (adds to base context size)
  2. Dispatch 10-15 parallel subagents via the Task tool in a single message
  3. Crucially, each subagent should do substantial work and write detailed summaries back to the parent (e.g., research tasks that return multi-paragraph findings, code exploration that returns file contents and analysis). The large return payloads are what overwhelm the parent context.
  4. As subagents complete and return results, the parent context grows rapidly
  5. Compaction triggers, but the post-compaction state plus incoming subagent results immediately re-fills context
  6. Session becomes unresponsive — compaction keeps firing but can't recover enough space

Expected Behavior

The session should gracefully handle the context pressure — either by queuing subagent results, compacting more aggressively, truncating excessively large subagent returns, or warning the user before accepting that many parallel dispatches.

Actual Behavior

The session enters a compaction loop and becomes unrecoverable. The only option is to kill the session, losing all in-progress subagent work and parent context.

Environment

  • macOS Darwin 25.2.0
  • Claude Code (observed across multiple recent versions)
  • Opus 4.6

Notes

Related to #24591 (compaction + subagents) and #26575 (unrecoverable compaction states), but the specific trigger here is the volume of parallel Task tool dispatches — each returning substantial content — overwhelming the parent context faster than compaction can recover it.

View original on GitHub ↗

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