[Bug] Context limit reached without automatic compaction triggering
Resolved 💬 16 comments Opened Mar 3, 2026 by Playaa93 Closed Jun 21, 2026
Bug Description
context limit reached without compactation two times today
Environment Info
- Platform: darwin
- Terminal: ghostty
- Version: 2.1.63
- Feedback ID: 4c87b6a9-65b1-4fe7-be9e-595df9a56972
Errors
[{"error":"Error\n at YM (/$bunfs/root/claude:92:1144)\n at <anonymous> (/$bunfs/root/claude:93:10067)\n at emit (node:events:92:22)\n at endReadableNT (internal:streams/readable:861:50)\n at processTicksAndRejections (native:7:39)\n at request (/$bunfs/root/claude:95:2149)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-03-03T14:10:07.583Z"},{"error":"Error\n at YM (/$bunfs/root/claude:92:1144)\n at <anonymous> (/$bunfs/root/claude:93:10067)\n at emit (node:events:92:22)\n at endReadableNT (internal:streams/readable:861:50)\n at processTicksAndRejections (native:7:39)\n at request (/$bunfs/root/claude:95:2149)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-03-03T14:10:07.583Z"},{"error":"Error\n at YM (/$bunfs/root/claude:92:1144)\n at <anonymous> (/$bunfs/root/claude:93:10067)\n at emit (node:events:92:22)\n at endReadableNT (internal:streams/readable:861:50)\n at processTicksAndRejections (native:7:39)\n at request (/$bunfs/root/claude:95:2149)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-03-03T14:10:07.931Z"},{"error":"Error: 1P event logging: 7 events failed to export (status=429, code=ERR_BAD_REQUEST, Request failed with status code 429)\n at queueFailedEvents (/$bunfs/root/claude:6264:2403)\n at async doExport (/$bunfs/root/claude:6264:1310)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-03-03T14:10:12.435Z"},{"error":"Error: {\"message\":\"Failed to export 7 events (status=429, code=ERR_BAD_REQUEST, Request failed with status code 429)\",\"originalLine\":\"6264\",\"originalColumn\":\"1462\",\"line\":\"6264\",\"column\":\"1462\",\"sourceURL\":\"/$bunfs/root/claude\",\"stack\":\"Error: Failed to export 7 events (status=429, code=ERR_BAD_REQUEST, Request failed with status code 429)\\n at doExport (/$bunfs/root/claude:6264:1462)\\n at processTicksAndRejections (native:7:39)\",\"name\":\"Error\"}\n at error (/$bunfs/root/claude:2402:25029)\n at <anonymous> (/$bunfs/root/claude:119:92465)\n at A4D (/$bunfs/root/claude:119:93009)\n at <anonymous> (/$bunfs/root/claude:120:17366)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-03-03T14:10:12.435Z"},{"error":"Error\n at YM (/$bunfs/root/claude:92:1144)\n at <anonymous> (/$bunfs/root/claude:93:10067)\n at emit (node:events:92:22)\n at endReadableNT (internal:streams/readable:861:50)\n at processTicksAndRejections (native:7:39)\n at request (/$bunfs/root/claude:95:2149)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-03-03T14:10:15.556Z"},{"error":"Error\n at YM (/$bunfs/root/claude:92:1144)\n at <anonymous> (/$bunfs/root/claude:93:10067)\n at emit (node:events:92:22)\n at endReadableNT (internal:streams/readable:861:50)\n at processTicksAndRejections (native:7:39)\n at request (/$bunfs/root/claude:95:2149)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-03-03T14:10:15.556Z"},{"error":"Error\n at YM (/$bunfs/root/claude:92:1144)\n at <anonymous> (/$bunfs/root/claude:93:10067)\n at emit (node:events:92:22)\n at endReadableNT (internal:streams/readable:861:50)\n at processTicksAndRejections (native:7:39)\n at request (/$bunfs/root/claude:95:2149)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-03-03T14:10:15.556Z"},{"error":"Error\n at YM (/$bunfs/root/claude:92:1144)\n at <anonymous> (/$bunfs/root/claude:93:10067)\n at emit (node:events:92:22)\n at endReadableNT (internal:streams/readable:861:50)\n at processTicksAndRejections (native:7:39)\n at request (/$bunfs/root/claude:95:2149)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-03-03T14:10:15.556Z"},{"error":"Error\n at YM (/$bunfs/root/claude:92:1144)\n at <anonymous> (/$bunfs/root/claude:93:10067)\n at emit (node:events:92:22)\n at endReadableNT (internal:streams/readable:861:50)\n at processTicksAndRejections (native:7:39)\n at request (/$bunfs/root/claude:95:2149)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-03-03T14:10:15.657Z"},{"error":"Error\n at YM (/$bunfs/root/claude:92:1144)\n at <anonymous> (/$bunfs/root/claude:93:10067)\n at emit (node:events:92:22)\n at endReadableNT (internal:streams/readable:861:50)\n at processTicksAndReject…
Note: Content was truncated.
16 Comments
147k tokens...
Context limit reached · /compact or /clear to continue
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
I really don’t know how many more times this problem has to happen.
+1
## Bug Description
Auto-compaction does not trigger before reaching the context limit when using
the 1M token context window. The session abruptly stops with "Context limit
reached" instead of auto-compacting to free up space.
## Environment
## Steps to Reproduce
## Expected Behavior
Auto-compaction should trigger at some threshold (e.g., 80-90% of context
limit) to free up context space and allow the session to continue without
interruption. This behavior previously worked when the context window was
smaller (pre-1M expansion).
## Actual Behavior
No auto-compaction occurs. The session hits the context limit and stops
abruptly. Observed on multiple occasions:
bar) without auto-compaction
auto-compaction
In both cases, manual
/compactwas required. Prior to the 1M tokencontext window expansion, auto-compaction would trigger automatically.
## Impact
/compactproactively
interactive walkthroughs) where pausing to compact is disruptive
## Workaround
Manually run
/compactbefore reaching the limit. However, this requiresconstant monitoring of the context percentage in the status bar.
Hey...
<img width="1260" height="592" alt="Image" src="https://github.com/user-attachments/assets/f245d7a1-4df7-4246-9440-61e2a1782781" />
This isn't the same issue is it?
There's no way I have 1189K tokens of messages in this session, it's ~460K tokens worth of messages for this session - I compact the session regularly, have even cleared it a few times. This appears to be happening during a service outage. What the heck is going on? It's not letting me compact this even.
<img width="2400" height="1050" alt="Image" src="https://github.com/user-attachments/assets/df2c8737-af52-4356-b3d7-b500271fb080" />
Still a issue 04/03/26 context limit reached at < 450,000 while should be 1M
Any update?
Happened again today, 4/14/26 8:36am EST, while Claude Code was reporting context of 294,544 tokens (not anywhere close to 1M)
Claude Code version 2.1.204 (per Claude Code, this is the latest version as of this moment )
Current version: 2.1.104
Checking for updates to latest version...
Claude Code is up to date (2.1.104)
Happened again today
<img width="1355" height="182" alt="Image" src="https://github.com/user-attachments/assets/1ee1145b-5169-40cb-b757-7b94ca72e781" />
I might have figured it out.
It generates
<system-notification>lines that contain code changes.I reformatted my repo tree and then sent a message; I had a debugger attached and it tried to send an enormous change set as a
<system-notification>user message of changes relative to files the agent had previously touched. I aborted the process and restarted it, no change set - could pick back up where I left off. The downside is that I am on an older version, but... smoking gun?I am currently pinned at v2.1.80 and have some custom patches applied to avoid this issue. That is some insane stuff. 🤯
Silent hidden system-notification messages destroying context and possibly some misreads of current compaction-window session history depth after restarts on newer versions causing inability to send messages. @kimmeyh I recommend editing your jsonl file for that session and inserting a custom variant of a compaction line to "recover" it into a new compaction window. Can even instruct a new Claude session to act as a "neurosurgeon" on that session's jsonl. That will at least let you continue.
Not sure if fixed in 2.1.113, but auto-compact has happened twice since start of 04/18/26. Noting that both time it occurred Tokens was being reported at < 500K. However, prefer auto-compaction early or token count being incorrect than complete failure to do auto-compaction.
Failed to auto-compact today at 513851 tokens, version 2.1.113
Image
Upgraded to 2.1.114 04/20/26
Not sure if fixed in 2.1.113, but auto-compact has happened twice since start of 04/18/26. Noting that both time it occurred Tokens was being reported at < 500K. However, prefer auto-compaction early or token count being incorrect than complete failure to do auto-compaction.
Failed to auto-compact today at 513851 tokens, version 2.1.113
Image
Upgraded to 2.1.114 04/20/26
Adding a data point and a critical detail not yet captured in this thread.
The issue is reproducible on Windows 10 / Claude Code 2.1.113 / Max (5x) plan in fresh sessions with heavy development tool use. The session usage page (claude.ai/settings/usage) showed only ~15% of the session allocation consumed when the limit error occurred — the failure is happening well before the context window is full.
Most importantly — the financial impact of the stuck state: When auto-compact fails to fire and the limit is hit, manual
/compactalso fails with the same error. On the Max plan, the only escape is:/compactwith extra usage activeUsers are being forced to pay real money just to recover from a bug in the compaction system. None of the existing comments mention this. It is a significant consequence that should be factored into prioritisation.
Auto-compact works correctly on Linux (same account) and macOS (different account) with the same Claude Code version and configuration, pointing to a platform-specific regression on Windows.
See also: #51207
When CC's auto-compact doesn't fire and you hit the wall with no warning, having a second, independent trigger helps. cozempic's guard daemon watches session size and auto-prunes at thresholds you configure (defaults 25/55/80% of the window), so you're not relying solely on CC's compaction firing. For a session that's already stuck,
cozempic treat <session-id> --executereclaims space directly (writing a backup first). Open source,uvx cozempicto start. Won't fix why auto-compact isn't triggering, but it keeps a stuck session moving.Closing for now — inactive for too long. Please open a new issue if this is still relevant.