Background task output polling blocks /compact requests, consuming entire context window

Resolved 💬 4 comments Opened Feb 8, 2026 by RDSweet1 Closed Mar 9, 2026

Description

When a long-running background task is active (e.g., a Playwright E2E test suite running for 1+ hours), repeatedly polling TaskOutput consumes the context window. If the user requests /compact during this time, the compaction does not take priority — instead, the system continues polling the background task output, eventually filling the entire context window and forcing a "Context limit reached" error.

Steps to Reproduce

  1. Start a long-running background command (e.g., npx playwright test --workers=1 with 600+ tests, ~1.5 hours)
  2. The agent polls TaskOutput periodically to check progress
  3. User types /compact while the background task is still running
  4. Expected: Compaction happens immediately, preserving context for continued work
  5. Actual: The /compact request is ignored or deferred. The agent continues polling TaskOutput, each poll adding thousands of lines to context. Eventually hits "Context limit reached" with no ability to compact.

Observed Behavior

In my session, I typed /compact twice while waiting for a Playwright run to finish. Both times, the system continued polling the background task instead of compacting. The context window filled completely, forcing a hard stop. The conversation history from the prior session transcript shows:

❯ /compact        ← User request #1 (ignored)
[agent continues polling TaskOutput]

❯ /compact        ← User request #2 (ignored)  
[agent continues polling TaskOutput]
⎿ Context limit reached · /compact or /clear to continue

Impact

  • Lost work context: The entire conversation history up to that point was lost because compaction never happened
  • Wasted tokens/cost: Thousands of lines of test output were pulled into context unnecessarily
  • User frustration: Explicit user commands to manage context were not honored

Suggested Fix

  • /compact should take immediate priority over any pending TaskOutput polls
  • Long-running background tasks should not continuously dump output into the main context — perhaps summarize or truncate after a threshold
  • Consider a mechanism where background task output is only pulled on-demand rather than auto-polled

Environment

  • Claude Code v2.1.37
  • Model: Opus 4.6
  • Platform: Windows (MSYS/Git Bash)
  • Task type: Background Bash command (npx playwright test --workers=1 --reporter=line)

Additional Context

The background task eventually completed successfully — the issue is purely about context management and /compact priority.

View original on GitHub ↗

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