[BUG] Error during compaction
Resolved 💬 134 comments Opened Sep 12, 2025 by mtaksa Closed Apr 27, 2026
💡 Likely answer: A maintainer (sid374, contributor)
responded on this thread — see the highlighted reply below.
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?
The /compact command fails with an error message stating "Conversation too long. Press esc twice to go up a few messages and try again." This prevents users from compacting their conversation history when the conversation becomes lengthy.
What Should Happen?
The /compact command should successfully compress the conversation history regardless of length, summarizing previous messages while preserving important context. Users should be able to compact conversations of any reasonable size to manage token usage and maintain conversation continuity.
Error Messages/Logs
Steps to Reproduce
- Start a new conversation in Claude Code
- Have an extended conversation with multiple tool calls, file reads, and edits (likely 50+ messages)
- Run the /compact command
- Observe the error: "Error during compaction:Error: Conversation too long. Press esc twice to go up a few messages and try again."
Claude Model
None
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
1.0.111
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
134 Comments
I see this too in the recent days. a lot of failures on /compact even when I'm at 25% (barely have no dialogue)
This has also been happening to me a lot recently. Pressing esc twice and going back messages also doesn't help and attempting to compact still brings the same error.
I forgot this part. It happens more than 80% of the time. And when it happens, even I retry multiple times it still doesn't work.
And I also observed: when the context goes out of length, it seems a force /clear will happen, and we will be thrown to a new session, losing all the access to the old chat history. I know it stored somewhere in my file system, but it's not in the TUI.
I can confirm this bug in 1.0.111
Also seeing this issue on almost any manual compact, if I then add tons more context to force it to auto-compact at 100% of context, it works just fine. So clearly the issue isn't actually too many messages.
Can confirm that as well. See it since a few days quite often, but seems to not effect the automatic compact
Haven't experienced the issue today, but when I was experiencing it, it was also affecting the auto compact. Currently on v1.0.113, not sure what version I was on when I had the issue yesterday.
On my side it's also fixed. Guess we can close now.
It seems that in the new /compact does clear the history visually. Bugs are introduced in the implementation and are fixed now.
I got it now.
OS: Win 11
Claude Code: 1.0.113
Terminal: MINGW64 (Git/Bash)
<img width="1903" height="693" alt="Image" src="https://github.com/user-attachments/assets/cee115df-2ce6-41b8-81b1-e3448b689336" />
+1
a workaround is to copy the conversation and remove all the pasted user messages manually, then paste it into a new session
It seems to me the first 1 2 or even 3 /compacts does work. But then it gets this error. Based on this, It seems to me they are now trying to compact the entire jsonl session file instead of the logs from the LAST /compact to present.
Fking Nightmaire, every time losing all context even compactin at 15% remaning, like start a new conversation every time needed to compact.
Been running into this constantly. Very annoying to deal with. 1.0.115 (Claude Code)
I’m experiencing the same issue, it’s pretty cringey.
I am experiencing this problem several times each day. I have taken to asking CC to write a detailed markdown summary of progress as I approach the context limit, so that I can regain context in the inevitable new conversation.
Just ran into this for the first time.
The problem seems to be fixed (for me at least) in the latest release 1.0.117
Still happening on 1.0.117 (it happened on both of my last two attempts to compact, in two different instances).
I'm on the max 20x plan. I wonder if the plan, and therefore likelihood of hitting limits, makes a difference ..
Same thing happened to me, only compacted once before this error. Used to be able to compact 4-5 times without any issues.
<img width="608" height="293" alt="Image" src="https://github.com/user-attachments/assets/14a6eebb-367d-4abf-bab8-c7fc26f0b016" />
I tried to go back some messages up after that, and that didn't help either.
Edit: somehow the screenshot got cut (?). On the top of it before status there was
First time i've noticed this issue but identical presentation as previously described - i'm on Debian
happened today in .117 - still an issue. it should just work
+
Have similar issue on v1.0.119. One consistent workaround I've been using the past few days is to kill the claude code instance and then restart with claude --continue. Afterwards, the compaction command seems to work.
This is the way to do it. It seems to happen after two full sessions (I'm on 20x max) where I've compacted once (sometimes twice) already. But closing and resuming will allow it to compact again. Definitely a bug since compacting works, just not after a longer conversation.
Yeah have been facing this issue a lot since a day or couple of days maybe.
BUT yeah closing and resuming the session works, weird, I wonder whats the logic going on behind /compact that causes this regression so rarely
Doing this you will remove context, as --continuing only loads the conversation, not the context. But if that's all good, you can just do:
/clear
/resume - this will loads the convo
/compact - > no need to close claude code
"sometimes" it works after restarting the claude instance, fyi.
Note, this is NOT about too long a CURRENT context. I believe Anthropic has broken something somewhere so it is trying to compact ALL the jsonl data for THAT PARTICULAR SESSION ID. That could be 2, 3 or 10 actual sessions of FULL CONTEXT. I had this error come up when I tried compacting with less than 70k tokens used in the current session(this was from your OWN /context command) so I KNOW this bug has nothing to do with the CURRENT sessions context window.
@acidtech I did think this might be the issue. Seems it is trying to compact everything in terminal which is why it works when opening a new terminal and doing --continue
Has anyone been able to get a refund over this? I'm paying $200 month and can't even get this simple feature to work. Very irritating.
If I do /context then /compact, this constantly happens. I need to shut the CC down and rerun the terminal to compact
waiting for auto-compact works for me, but still irritating I can't do it on my own
hope they'll fix it
This needs to be fixed. Can confirm im getting this same error. Have to quit claude and run it with continue to pick up where i left off and then it works for some reason. so it only breaks after claude code has been running for a while? very strange
I'm getting it constantly today!! Help!!
I'm encountering this when I continue or resume a conversation: the initial conversation has >20% context left, however when I return to it via resume or continue, context consumed is >100% (e.g. 151%). A typical prompt produces
Context low · Run /compact to compact & continueand /compact producesError: Error during compaction: Error: Conversation too long. Press esc twice to go up a few messages and try again.As a clear example of where compact should work, as far as I can tell.
The only way that worked for me, was to go back to the session, copy entire text of it, and paste it into a brand new session. Not ideal, but no other workaround fix it, and I tried them all. This sort of worked, gets you 90% there.
I've noticed this and I've also noticed that in one my sessions it was compacting like crazy, it would do just a couple of things, then compact, a couple of things then compact. There was no reason for it.
Either this got fixed in 1.0.124 or closing claude and then resuming previous session (claude --resume) mitigates this issue.
I always get this:
It doesn't matter if it's auto-compact or manually. I just cannot compact anymore. I tried all your suggestions. But it is not working.
I could imagine that it has something to do with the agents I am using with CC. But I have no time to figure this out.
I'm having the same issue:
https://i.imgur.com/6LgAYve.png
I'm at 67% context, it says that I have 12% left until it auto-compacts and when I try to push it to compact is gives me the exact same error.
I was having this problem too, and I switched over to Sonnet (1M context) and it worked. I shouldn't have to do that, but I doubt that costs that much more.
Also having this often. Annoying issue, but closing the session and resuming it again makes the /compact work
Same problem since yesterday
Just got this today on 1.0.128.
I'm still having this on Version: 2.0.0.
claude-opus-4-1-20250805 • 149k/200k tokens (74%)This is happening an insane amount. It's destroying everything about the experience.
Workaround (also mentioned in https://github.com/anthropics/claude-code/issues/7530#issuecomment-3346485573):
^C^C(exitclaude)claude(reopen)/resumelast session/compact; this time it workedThis has worked for me 100% of the time (N≈30) over the last ≈week.
Agreed it's been quite frustrating, I just ran into it at "12% remaining", which I think is a new record for me:
Yup, that workaround seems to be working! Thanks.
Since this bug started I’ve been going into the 0% auto-compact to not lose context, otherwise I’m very clean with my context pruning and /compact very frequently and try to never go below 40%. When context is low usage increases exponentially(unfairly since it's a bug) and quality lowers.
Well, I just received:
<img width="743" height="104" alt="Image" src="https://github.com/user-attachments/assets/6af4d3e4-32b5-447b-98f6-01402b5c217e" />
So I checked the new /usage section and:
<img width="860" height="133" alt="Image" src="https://github.com/user-attachments/assets/af185b46-23fe-4fa8-bc56-350ec6146e76" />
This will ruin my week..
I don't like when people are cry-babies on gh issues, but this is not a random open source repo, we are paying up to $200/mo (personally since day 1), so I feel like Anthropic should:
Also:
P.S.: I'm now aware of the workaround and I will surely use it from now on, but still.
Workaround doesn't work for me :(
Very negligent of Anthropic to let this linger for this long. Very annoying.
⎿ Error: Error during compaction: Error: Conversation too long. Press esc twice to go up a few messages and
try again.
Workaround did work for me
Ridiculous broken operations
This is very bad, this problem has been around for a long time, I think he should solve.
<img width="699" height="220" alt="Image" src="https://github.com/user-attachments/assets/99bec438-4b39-4b76-bb85-c6b96922c515" />
same here. it asks me to go up several conversations, but then I'll lose the plan and context in the previous chat. what should I do? pls fix immediately as compact should not matter if the context is too long. it was working fine few versions ago.
a suggestion to Anthropic, divide the chat conversation into smaller parts and compact them individually, then combine them. in this way we can compact arbitrarily long contexts.
Same problem for me. It can't count correclty when compact must be made and you lose this moment, after that you can't compact.
Working with claude code cli. Thanks.
This bug is really annoying and stops me from working!
Still happening. Super annoying!
Happening to me as well. Close, /resume seems to work, but adding my 2c to hopefully get the team to actually fix this.
Same issue
Same issue just only in Windows 11 environment, in macOS and Debian Linux works fine at least for me.
Same issue with Windows 10, WSL 2. exit, /resume and /compact a great workaround for me.
아이 진짜 미치겠네.
This is the only thing that works. Incredibly frustrating to turn /compact into a multi-step process that completely breaks your flow. Doesn't seem like Anthropic cares to fix this anytime soon, so do with that information as you will.
I'm also now hitting 12% context left after JUST ONE question which makes it even more frustrating. It's becoming very difficult to be a user of this product.
I encountered the same issue. After exiting once with exit and then resuming with the -c option, I ran /compact, and it worked correctly.
Same issue. Mac OS, Claude Code v2.0.14
Same issue. Win 2.0.14 claude max
Same issue on macos
Same issue:
same issue, Windows 11
happens on second-third compacting in one session
Same for me, very frustating, seems the CC team at Anthropic has lost control over their QA processes completely. Otherwise I have no explaination how this can not be fixed for such a long time, as it seems to bother a lot of users..
Same issue.
Exiting and restarting Claude "fixed" the problem, now I can compact my conversation.
I am getting "Conversation too long" even when 49% of context left. This happens at least with vscode plugin.
Looks like there's 62 issues mentioning "Conversation too long" of which 30 are open.
<img width="745" height="282" alt="Image" src="https://github.com/user-attachments/assets/1ca2bfa4-41fb-4919-8319-ba4ca1bc3106" />
same happens for me. weird thing: I'm at 201k/200k tokens and autocomplete buffer is filling quite some space. what's going on?
edit: closing claude and restarting with
--continueallowed me to/compactThis worked for me
This happens to me 100% of the time now, /compact is completely broken
The hacky fix is to run /resume, select same chat, then run /compact
Hopefully they can fix soon though
Happens all the time. Compact is completely broken. Which means we're always stuck with the possibility of hitting auto compact in the middle of a complex implementation which doesn't always end well. If auto-compact consistently works why can't the slash command just trigger that same process?
The fix that came with the latest update resolved the issue for me. Good job!
Still broken here.
Still broken for me.
@dokterbob @RayNawara What versions are you working with? I'm on Claude Code v2.0.34
The issue should be fixed from v2.0.31 on : https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md
same here
Current version: 2.0.42
Still seeing this error.
hey folks we've shipped a few fixes related to /compact in the last few weeks. for anyone who has experienced this issue past 2.0.40 - can you please share you transcript using
/bugso we can investigate?2.0.22 here, still occurs.
still exist in 2.0.55 version
<img width="955" height="348" alt="Image" src="https://github.com/user-attachments/assets/0e905cfb-b4f4-4685-81b2-72d9528b29dc" />
Claude Code v2.0.55
Context low · Run /compact to compact & continue
The best "fix" I was able to come up with is to /export my chat context, then rewind (press esc twice) the conversation, not the code, back to a previous point where the context was shorter. Then run /context and you can see how much context you have available. Refer Claude to your exported file for any necessary context. I also used gemini.google.com to compress the conversation export so that I could rewind all the way back to the beginning of the conversations in Claude and load the compacted export in as the new context.
i found a workaround by following this step
Voila, you just fix the error
You are a beautiful soul, thank you for finding this workaround.
I ran this fix and i did not work until I went back into claude and ran
/model
⎿ Set model to Default (Opus 4 for up to 20% of usage limits, then use Sonnet 4)
Similar - I realized the compaction issue only occurred if Claude was
somehow stuck using an older version of a particular model. Forcing it to
current version using /model resolved my issues
On Thu, Dec 11, 2025, 9:15 AM Brian Caudill @.***>
wrote:
/compact
⎿ Error: Error during compaction: Error: API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"tools: Tool names must be unique."},"request_id":"req_011CWBpz7faroHYugyjmzvKB"}
The hero we need, not deserve.
Yeah this is happening to me daily as well. Tool names must be unique -- despite no new MCP changes happening in that time. Concerned about corruption.
The solution provided by @addean works for me as well (THANK YOU!)
BE WARNED: if you go over compact limits and ask claude to save a plan, it may not do so even though it says it did. I lost a significant amount of work due to this....
It's been happening a lot to me, 5 occurrences on a single day, and I pay for Max 5x plan, so it's super annoying paying that much and not receiving based on its value
Unfortunately that didn't work for me,
/compactas the same way before using/resumeThis is caused by parallel agents finishing after the compaction buffer is hit, the main context window begins compaction but the background agents continue to push data into main context as they finish which eats into the buffer eventually causing the main context compaction to fail. I am not sure if it's always from parallel agents, but it's definitely from background tasks running eating into context buffer typically saved for compaction.
I continue to see this again in version 2.0.76. When will this be fixed? change log says it's fixed 2 versions ago, how did it come back? I've tried macOS native terminal, warp, Ghostly, terminal inside VS Code, even a stop hook and another hook to remind Claude to compact - nothing seem to matter or work !
<img width="665" height="95" alt="Image" src="https://github.com/user-attachments/assets/094deecd-de46-46dd-b606-ec344901f047" />
can we please fix this ? i am dying
<img width="1006" height="547" alt="Image" src="https://github.com/user-attachments/assets/ada436d4-0bc3-46a0-9423-0ee78a81ed04" />
@elucidsoft This!! ^^
+1
@sid374 Where is an update from you on this? Its happend so frequently. Its like your whole session is just bricked after this comes up. None of the "fixes" above work
if you run subagents a lot the context window thing is such a pain, let's ship something that makes the best AI product even better anthropic crew
This bug has been solved for weeks; come on guys, just update Claude Code (or stop complaining about bugs that are ALREADY SOLVED).
(I can understand not wanting to update because Anthropic has definitely introduced a bunch of really harmful bugs over the last month, but that doesn't change the fact that this is a CLOSED ISSUE).
Still experiencing this issue on v2.1.25 (Claude Code CLI). Running /compact manually consistently fails with "Conversation too long" error, even when context is around 70-80%.
/compact remains broken
I am on version 2.1.27 and hit this issue on every /compact attempt. this is new to me never happened in earlier versions
I'm on 2.1.31, and this just happened to me. Never happened before.
Same, hadn't seen this since September, seems it's back now in 2.1.31, and my workaround above doesn't help 🫠.
it hits on every /compact now v2.1.34
<img width="1092" height="522" alt="Image" src="https://github.com/user-attachments/assets/de045308-2849-4884-a227-a1a3bb3e23af" />
Still experiencing this issue on the latest version.
Claude Code version: v2.1.34
Model: Claude Opus 4.6
The
/compactcommand still fails with:In my case, I was running multiple sequential agents to create training course modules (5 agents total). After all agents completed successfully, each hitting context limit, the
/compactcommand failed with the same error as originally reportedHappened to me today too
Yeah, sadly it keeps happening, especially now with the new team feature. I still haven't found a way to make it work because it always ends up like this. For example, I would use the "--dangerously-skip-permissions" mode + agent swarm hoping that I could walk away from the computer. But then I come back and nothing has been done because it just errored out because of the compaction problems.
Following
Model: claude-opus-4-6
Tokens: 58.3k / 200k (29%)
Estimated usage by category
Category | Tokens | Percentage
-- | -- | --
System prompt | 3.1k | 1.6%
System tools | 16.8k | 8.4%
Skills | 61 | 0.0%
Messages | 3107.9k | 1553.9%
Autocompact buffer | 33k | 16.5%
Still a very annoying bug in 2.1.37 version using Opus
Adding another data point:
Reproduction:
/compact→Error: Error during compaction: Error: Conversation too long. Press esc twice to go up a few messages and try again./compact→ same error/clearworksStill hitting this on the latest version (v2.1.37). This is a significant workflow blocker for document-heavy sessions.
I also encountered this issue when leveraging the agent teams. It seems that one of them needed to compact, the compact errored out then it caused the "lead" terminal chat (Non-sub-agent I guess?) To break as well. There was a very very big output as well so clearly something is getting messed up when a subagent runs into context limitations.
v3.1.38, Opus. Still same error:
Error during compaction: Error: Conversation too long. Press esc twice to go up a few messages and try again.This is a temporary fix/reaction workflow to allow working despite this blocking error (that worked for me)
claude -resume SESSION_ID/compactagain. _Works_ (even if other methods don't).Sometimes other things might help, like turning autocompact on, compacting, then off. But essentially this is "percussive maintenance", doing anything, flicking on switches on and off, hoping something starts moving once again. But that this sometimes works might help to figure out the underlying problem, and help Claude fix it.
ESC-ESC restoring back to -1 message and compacting works.
But this is a really bad workaround, all automated flow with agents is broken now
Issue persists in v3.1.28.
Found a workaround: run /exit, use /resume to return to the affected chat history, and then run /compact. This seems to clear the bug for now.
Thanks @polat-mustafa for sharing this workaround! 🙌 The /exit → /resume → /compact sequence is a great temporary fix
This bug is happening many times a day, just started happening recently.
Error: Error during compaction: Error: Conversation too long. Press esc twice to go up a few messages and try again.I'll try that work-around. It's getting very annoying.
Getting this all the time.
Getting this all the time.
switching to codex.. can't work with it
One pattern I've noticed is that compaction failures correlate with session bloat — sessions packed with duplicate file reads, progress ticks, and large tool outputs are much harder for the summarizer to handle cleanly. I built cozempic to prune that dead weight before compaction triggers. Running
cozempic treaton a bloated session typically removes 40-70% of the noise, which in my experience makes compaction succeed where it was failing before.Still hitting this regularly. Failed compaction is one of the worst UX moments in Claude Code — you are told "context is low, run /compact" but then compact itself fails, leaving you stuck.
The real damage is not the error itself — it is losing the session context you spent time building. All the file knowledge, decisions, and debugging steps are effectively gone when you have to start fresh.
Two things that have helped me:
Would love to see the compact command become more robust, but in the meantime having a session safety net has saved me countless hours of re-explaining context to a fresh session.
The root problem here isn't compaction itself — it's that compaction is a lossy operation being asked to do lossless work. When it fails, you lose everything.
I sidestepped this entirely by rotating before compaction becomes necessary. A PreToolUse hook checks context usage on every tool call — at ≥65% it blocks the agent and instructs it to write a structured handover file (task state, files touched, progress, next steps). A PostToolUse hook detects the handover, then a detached script sends /clear via tmux and injects a continuation prompt into the fresh session.
The 65% threshold is the key insight: that's ~15 points before auto-compact kicks in at ~80%. Enough headroom for the agent to write a clean handover without racing against compaction.
The fresh session picks up the handover and knows exactly where to resume. No context lost, no "press esc twice" errors, no manual intervention. Works especially well for long multi-file sessions and agent workflows where compaction consistently chokes.
I open-sourced the setup recently — there's a dry-run replay you can run locally without needing an LLM to see the full lifecycle.
While the compaction error is a core issue, you can protect against state loss with a PreCompact hook:
This runs before compaction happens, so even if compaction fails or loses context, you have a recovery file at \
~/.claude/session-handoff.md\.Install: \
npx cc-safe-setup --install-example session-handoff\For CLAUDE.md re-injection after compaction:
\
npx cc-safe-setup --install-example reinject-claudemd\The "Conversation too long" compaction error happens when the session has grown so large that even the compaction prompt itself exceeds the context window. The fix is to prune before compaction ever triggers.
Cozempic v1.4.1 does this automatically — the guard daemon monitors your session and runs pruning when token usage crosses thresholds. The PreCompact hook also fires a final prune pass right before Claude's native compaction, so it operates on a much smaller input.
17 strategies target different bloat sources: progress ticks (40-48% savings), thinking blocks, stale file reads, duplicate system-reminders, and the new
compact-summary-collapse(85-95% savings on compacted sessions).pip install cozempic && cozempic initIf anyone here is still hitting this, I'd appreciate hearing whether the guard daemon prevents the error from recurring.
This is a duplicate of #2038, which was fixed as of version 2.1.85.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.