[BUG] /compact 95% forever

Status Fixed / completed
Reported on v2.1.141
Maintainer reply None cached
Activity 9 comments · opened May 14, 2026 · closed Jun 9, 2026

Preflight Checklist

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

What's Wrong?

2.1.141 (Claude Code)

API Error: 400 Invalid request: Your request exceeded model token limit: 262144 (requested:
262147)

Not auto compact, so I compact with /compact

What Should Happen?

❯ /compact

✻ Compacting conversation… (2h 12m 58s)
▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▰▱▱ 95%

Error Messages/Logs

Steps to Reproduce

just out of limit, and not auto compact

Claude Model

Sonnet (default)

Is this a regression?

No, this never worked

Last Working Version

_No response_

Claude Code Version

2.1.141

Platform

Claude

Operating System

macOS

Terminal/Shell

iTerm2

Additional Information

2.1.137 have same problem.

View original on GitHub ↗

8 Comments

yacb2 · 3 months ago

I ran into the same wedge on /compact and built https://github.com/yacb2/claude-session-handoff as a workaround — a wrapper + /handoff slash command that closes the stuck session and opens a fresh one seeded with a handoff prompt summarizing what you were doing, via SessionStart's additionalContext. It does not fix the underlying /compact hang — you still lose the in-flight compaction — but it gets you out of the 95% spinner without killing the terminal and losing all context.

shenguanjiejie · 3 months ago

I have fixed this problem by uninstall claude code & reinstall claude code.

quas-modo · 3 months ago
I have fixed this problem by uninstall claude code & reinstall claude code.

@shenguanjiejie
What's the version of the Claude Code you just installed?

shenguanjiejie · 3 months ago
> 我已经通过卸载 Claude Code 并重新安装 Claude Code 解决了这个问题。 @shenguanjiejie 你刚刚安装的 Claude Code 版本是什么?

latest

shenguanjiejie · 3 months ago

But I got this problem again..

I try to use different model to /compact, It's give me different error log.

<img width="943" height="558" alt="Image" src="https://github.com/user-attachments/assets/2172c4b4-6091-43f7-9b9a-80e15741f477" />

Sn3th · 3 months ago

use "CLAUDE_CODE_AUTO_COMPACT_WINDOW=1000000" this sets and unsets auto compaction... hope that helps
usage
export CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=80 <-- set to whatever you want...
export CLAUDE_CODE_AUTO_COMPACT_WINDOW=1000000 <-- must exist

shenguanjiejie · 2 months ago
use "CLAUDE_CODE_AUTO_COMPACT_WINDOW=1000000" this sets and unsets auto compaction... hope that helps usage export CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=80 <-- set to whatever you want... export CLAUDE_CODE_AUTO_COMPACT_WINDOW=1000000 <-- must exist

Thankyou my friend. it work for me.

wdportman · 1 month ago

this is still happening for me

Showing cached comments. Read the full discussion on GitHub ↗