Auto-compact enters infinite retry loop after timeout, consuming rate limit
Resolved 💬 4 comments Opened Feb 3, 2026 by git-push-it-real-good Closed Mar 4, 2026
Description
When leaving a Claude Code session open overnight (macOS sleep), the auto-compact agent enters a retry loop that doesn't stop.
Observed behavior
- 27
agent-acompact-*subagent files created over ~2.5 hours - 4,246 API requests from compact agents alone
- ~695 million cache-read tokens consumed
- Exhausted the 5-hour "Current Session" rate limit without any user interaction
Timeline
00:28 - 1 compact attempt (machine briefly woke?)
- 10h gap (sleep)
10:14 - Machine wakes, compact loop starts
10:14-12:37 - 27 new compact agents spawned (~1 every 5-8 min)
12:37 - Loop ended (rate limit hit or manual intervention)
Expected behavior
- Auto-compact should have a max retry limit
- Should not retry indefinitely after timeout
- Should detect rate limit and back off gracefully
Environment
- Claude Code version: 2.1.29
- Model: claude-opus-4-5-20251101
- OS: macOS (Darwin 25.2.0)
- Subscription: Claude Max
Steps to reproduce
- Start a Claude Code session with a large context (near 200k limit)
- Leave session open overnight with machine going to sleep
- Wake machine in the morning
- Observe multiple
agent-acompact-*files being created in~/.claude/projects/<project>/<session-id>/subagents/
Additional context
The compact agent seems to timeout after ~10 minutes and then immediately retry, creating a new subagent each time. There appears to be no exit condition or maximum retry count.
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗