claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[BUG] Error during compaction

Open mtaksa opened this issue 3 months ago • 101 comments

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

  1. Start a new conversation in Claude Code
  2. Have an extended conversation with multiple tool calls, file reads, and edits (likely 50+ messages)
  3. Run the /compact command
  4. 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

mtaksa avatar Sep 12 '25 17:09 mtaksa

I see this too in the recent days. a lot of failures on /compact even when I'm at 25% (barely have no dialogue)

PabloLION avatar Sep 12 '25 20:09 PabloLION

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.

OMorris95 avatar Sep 13 '25 09:09 OMorris95

Pressing esc twice and going back messages also doesn't help

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.

PabloLION avatar Sep 13 '25 09:09 PabloLION

I can confirm this bug in 1.0.111

TUstudents avatar Sep 13 '25 20:09 TUstudents

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.

cahaseler avatar Sep 14 '25 01:09 cahaseler

Can confirm that as well. See it since a few days quite often, but seems to not effect the automatic compact

leichti avatar Sep 14 '25 10:09 leichti

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.

OMorris95 avatar Sep 14 '25 12:09 OMorris95

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.

PabloLION avatar Sep 14 '25 12:09 PabloLION

I got it now. OS: Win 11 Claude Code: 1.0.113 Terminal: MINGW64 (Git/Bash)

Image

VirtualMaestro avatar Sep 14 '25 18:09 VirtualMaestro

+1

a workaround is to copy the conversation and remove all the pasted user messages manually, then paste it into a new session

DANDROZAVR avatar Sep 15 '25 16:09 DANDROZAVR

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.

acidtech avatar Sep 15 '25 22:09 acidtech

Fking Nightmaire, every time losing all context even compactin at 15% remaning, like start a new conversation every time needed to compact.

EddiePiazza avatar Sep 15 '25 23:09 EddiePiazza

Been running into this constantly. Very annoying to deal with. 1.0.115 (Claude Code)

derekbking avatar Sep 16 '25 22:09 derekbking

I’m experiencing the same issue, it’s pretty cringey.

ngochuy97hp avatar Sep 17 '25 02:09 ngochuy97hp

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.

dfpersonal avatar Sep 17 '25 05:09 dfpersonal

Just ran into this for the first time.

flux627 avatar Sep 17 '25 16:09 flux627

The problem seems to be fixed (for me at least) in the latest release 1.0.117

dfpersonal avatar Sep 17 '25 16:09 dfpersonal

Still happening on 1.0.117 (it happened on both of my last two attempts to compact, in two different instances).

stiang avatar Sep 17 '25 17:09 stiang

I'm on the max 20x plan. I wonder if the plan, and therefore likelihood of hitting limits, makes a difference ..

dfpersonal avatar Sep 17 '25 18:09 dfpersonal

Same thing happened to me, only compacted once before this error. Used to be able to compact 4-5 times without any issues.

cokekain avatar Sep 18 '25 03:09 cokekain

Image

I tried to go back some messages up after that, and that didn't help either.

Claude Code v1.0.115
  L Session ID: 9df6a061-806e-4c89-905b-4224a9e084ba

Edit: somehow the screenshot got cut (?). On the top of it before status there was

/compact
  ⎿ Error: Error during compaction: Error: Conversation too long. Press esc twice to go up a few
    messages and try again.

jezzarax avatar Sep 18 '25 07:09 jezzarax

First time i've noticed this issue but identical presentation as previously described - i'm on Debian

newsbot415-cell avatar Sep 18 '25 21:09 newsbot415-cell

happened today in .117 - still an issue. it should just work

dticson avatar Sep 18 '25 22:09 dticson

SOSKIN123 avatar Sep 18 '25 23:09 SOSKIN123

When are we going to resolve this, it's been like this for the past week

JohnDotOwl avatar Sep 19 '25 03:09 JohnDotOwl

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.

angeloviciy avatar Sep 19 '25 05:09 angeloviciy

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.

hisnameisjoel avatar Sep 19 '25 14:09 hisnameisjoel

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

AJV009 avatar Sep 19 '25 16:09 AJV009

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.

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

AnalogTransformer avatar Sep 20 '25 05:09 AnalogTransformer

"sometimes" it works after restarting the claude instance, fyi.

mahircanyuksel avatar Sep 21 '25 07:09 mahircanyuksel