claude-code - 💡(How to fix) Fix [BUG] Claude Code auto-compaction runs indefinitely [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#45170Fetched 2026-04-09 08:11:40
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Author
Timeline (top)
labeled ×4commented ×1

Error Message

Error Messages/Logs

RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

When auto-compaction is triggered, it runs indefinitely, and drained all tokens in this session after running for ~15 minutes.

What Should Happen?

Claude should compact the previous converstaion, and continue to do the rest of its job.

Error Messages/Logs

Steps to Reproduce

I'm not sure about the exact trigger of this bug.

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

2.1.96

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

iTerm2

Additional Information

<img width="953" height="167" alt="Image" src="https://github.com/user-attachments/assets/3f4eb9e9-6842-4e6e-8c58-c69a5c483f5c" />

As you can see in the screenshot, I was forced to interrupt the compaction. After that my current session is "100% used", though it still has ~ 1/3 before the compaction.

extent analysis

TL;DR

The issue might be resolved by adjusting the auto-compaction settings or implementing a timeout to prevent indefinite execution.

Guidance

  • Investigate the auto-compaction trigger and settings to determine if there's a threshold or condition that's causing it to run indefinitely.
  • Review the Claude Code documentation for any guidelines on configuring auto-compaction or troubleshooting similar issues.
  • Consider implementing a manual timeout or interrupt mechanism to prevent auto-compaction from draining all tokens in a session.
  • Examine the screenshot and system logs for any clues about what might be causing the compaction to fail or hang.

Example

No code snippet can be provided without more information about the specific implementation or APIs used.

Notes

The lack of error messages or logs makes it difficult to determine the root cause of the issue. The fact that the session is reported as "100% used" despite having ~1/3 remaining before compaction suggests a potential discrepancy in token tracking or session management.

Recommendation

Apply workaround: Implement a manual timeout or interrupt mechanism to prevent auto-compaction from draining all tokens in a session, as this seems to be the most immediate way to mitigate the issue.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING