[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

  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_

View original on GitHub ↗

134 Comments

PabloLION · 10 months ago

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

OMorris95 · 10 months ago

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.

PabloLION · 10 months ago
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.

TUstudents · 10 months ago

I can confirm this bug in 1.0.111

cahaseler · 10 months ago

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.

leichti · 10 months ago

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

OMorris95 · 10 months ago

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.

PabloLION · 10 months ago

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.

VirtualMaestro · 10 months ago

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" />

DANDROZAVR · 10 months ago

+1

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

acidtech · 10 months ago

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.

EddiePiazza · 10 months ago

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

derekbking · 10 months ago

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

ngochuy97hp · 10 months ago

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

dfpersonal · 10 months ago

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.

flux627 · 10 months ago

Just ran into this for the first time.

dfpersonal · 10 months ago

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

stiang · 10 months ago

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

dfpersonal · 10 months ago

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

cokekain · 10 months ago

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

jezzarax · 10 months ago

<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.

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.
newsbot415-cell · 10 months ago

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

dticson · 10 months ago

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

SOSKIN123 · 10 months ago

+

angeloviciy · 10 months ago

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.

hisnameisjoel · 10 months ago
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.

AJV009 · 10 months ago

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

AnalogTransformer · 9 months ago
> 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

mahircanyuksel · 9 months ago

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

acidtech · 9 months ago

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.

OMorris95 · 9 months ago

@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

mtaksa · 9 months ago

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.

beepv · 9 months ago

If I do /context then /compact, this constantly happens. I need to shut the CC down and rerun the terminal to compact

piotrmol2002 · 9 months ago

waiting for auto-compact works for me, but still irritating I can't do it on my own
hope they'll fix it

khari998 · 9 months ago

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

RayNawara · 9 months ago

I'm getting it constantly today!! Help!!

timdonohue-aerology · 9 months ago

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 & continue and /compact produces Error: Error during compaction: Error: Conversation too long. Press esc twice to go up a few messages and try again.

andySquirro · 9 months ago
> /context
  ⎿  ⛁ ⛀ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁
     ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁
     ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁   Context Usage
     ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁   claude-sonnet-4-20250514 • 92k/200k tokens (46%)
     ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛶ ⛶ ⛶ ⛶
     ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶   ⛁ System prompt: 3.3k tokens (1.6%)
     ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶   ⛁ System tools: 11.5k tokens (5.7%)
     ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶   ⛁ Messages: 76.9k tokens (38.4%)
     ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶   ⛶ Free space: 108.4k (54.2%)
     ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶

> /compact
  ⎿  Error: 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.

JozefJarosciak · 9 months ago

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.

elucidsoft · 9 months ago

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.

andreas-bergstrom · 9 months ago

Either this got fixed in 1.0.124 or closing claude and then resuming previous session (claude --resume) mitigates this issue.

lxgbrl · 9 months ago

I always get this:

/compact
  ⎿ Error: Error during compaction: Error: API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"This credential is only authorized for use with Claude
    Code and cannot be used for other API requests."},"request_id":"req_011CTV2hrmVrCzSFKk1285RN"}

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.

edhemKod · 9 months ago

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.

kevinjcroke · 9 months ago

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.

FilipeAleixo · 9 months ago

Also having this often. Annoying issue, but closing the session and resuming it again makes the /compact work

escamoteur · 9 months ago

Same problem since yesterday

nikolayv · 9 months ago

Just got this today on 1.0.128.

synt-or · 9 months ago

I'm still having this on Version: 2.0.0.
claude-opus-4-1-20250805 • 149k/200k tokens (74%)

> /compact 
  ⎿  Error: Error during compaction: Error: Conversation too long. Press esc twice to go up a few messages and try again.
jacquesjg · 9 months ago

This is happening an insane amount. It's destroying everything about the experience.

ryan-williams · 9 months ago

Workaround (also mentioned in https://github.com/anthropics/claude-code/issues/7530#issuecomment-3346485573):

  1. ^C^C (exit claude)
  2. claude (reopen)
  3. /resume last session
  4. /compact; this time it worked

This 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:

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

───────────────────────────────────────────────────────────────────────────────────
>
───────────────────────────────────────────────────────────────────────────────────
  ? for shortcutsContext low (12% remaining) · Run /compact to compact & continue
danfelbm · 9 months ago
Workaround that just worked for me (edit: just noticed #7530 (comment) also said this above): 1. ^C^C (exit claude) 2. claude (reopen) 3. /resume last session 4. /compact; this time it worked Agreed it's been quite frustrating, I just ran into it at "12% remaining", which I think is a new record for me: `` > /compact ⎿ Error: Error during compaction: Error: Conversation too long. Press esc twice to go up a few messages and try again. ─────────────────────────────────────────────────────────────────────────────────── > ─────────────────────────────────────────────────────────────────────────────────── ? for shortcutsContext low (12% remaining) · Run /compact to compact & continue ``

Yup, that workaround seems to be working! Thanks.

adriangalilea · 9 months ago

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:

  • Solve bugs that cause unfair inflated usage calculations
  • Reset usage

Also:

  • Time your notices better, we received an email ages ago, and you randomly activate usage limits overnight
  • Have proper visibility on usage, both for current context and weekly limits, add permanent progress bar, not a random approaching weekly limit when I'm on 80% and already f**d

P.S.: I'm now aware of the workaround and I will surely use it from now on, but still.

dobsonddev · 9 months ago
> Workaround that just worked for me (edit: just noticed #7530 (comment) also said this above): > > 1. ^C^C (exit claude) > 2. claude (reopen) > 3. /resume last session > 4. /compact; this time it worked > > Agreed it's been quite frustrating, I just ran into it at "12% remaining", which I think is a new record for me: > `` > > /compact > ⎿ Error: Error during compaction: Error: Conversation too long. Press esc twice > to go up a few messages and try again. > > ─────────────────────────────────────────────────────────────────────────────────── > > > ─────────────────────────────────────────────────────────────────────────────────── > ? for shortcutsContext low (12% remaining) · Run /compact to compact & continue > `` Yup, that workaround seems to be working! Thanks.

Workaround doesn't work for me :(

Very negligent of Anthropic to let this linger for this long. Very annoying.

nsanden · 9 months ago
/compact

⎿ 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

weisisheng · 9 months ago

Ridiculous broken operations

adriano461997 · 9 months ago

This is very bad, this problem has been around for a long time, I think he should solve.

danieltty · 9 months ago

<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.

siberianwm · 9 months ago

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.

siberianwm · 9 months ago
Workaround that just worked for me (edit: just noticed #7530 (comment) also said this above): 1. ^C^C (exit claude) 2. claude (reopen) 3. /resume last session 4. /compact; this time it worked Agreed it's been quite frustrating, I just ran into it at "12% remaining", which I think is a new record for me: `` > /compact ⎿ Error: Error during compaction: Error: Conversation too long. Press esc twice to go up a few messages and try again. ─────────────────────────────────────────────────────────────────────────────────── > ─────────────────────────────────────────────────────────────────────────────────── ? for shortcutsContext low (12% remaining) · Run /compact to compact & continue ``

Working with claude code cli. Thanks.

maxritter · 9 months ago

This bug is really annoying and stops me from working!

StayMeaty · 9 months ago

Still happening. Super annoying!

rhys-041 · 9 months ago

Happening to me as well. Close, /resume seems to work, but adding my 2c to hopefully get the team to actually fix this.

Novitsh · 9 months ago

Same issue

afborga · 9 months ago

Same issue just only in Windows 11 environment, in macOS and Debian Linux works fine at least for me.

katnyeung · 9 months ago

Same issue with Windows 10, WSL 2. exit, /resume and /compact a great workaround for me.

Same issue just only in Windows 11 environment, in macOS and Debian Linux works fine at least for me.
INTEGRITY2077 · 9 months ago

아이 진짜 미치겠네.

mtaksa · 9 months ago
> Workaround that just worked for me (edit: just noticed #7530 (comment) also said this above): > > 1. ^C^C (exit claude) > 2. claude (reopen) > 3. /resume last session > 4. /compact; this time it worked > > Agreed it's been quite frustrating, I just ran into it at "12% remaining", which I think is a new record for me: > `` > > /compact > ⎿ Error: Error during compaction: Error: Conversation too long. Press esc twice > to go up a few messages and try again. > > ─────────────────────────────────────────────────────────────────────────────────── > > > ─────────────────────────────────────────────────────────────────────────────────── > ? for shortcutsContext low (12% remaining) · Run /compact to compact & continue > `` Working with claude code cli. Thanks.

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.

ShutoKeisuke · 9 months ago

I encountered the same issue. After exiting once with exit and then resuming with the -c option, I ran /compact, and it worked correctly.

oliveres · 9 months ago

Same issue. Mac OS, Claude Code v2.0.14

BobPirate6 · 9 months ago

Same issue. Win 2.0.14 claude max

soheil42 · 9 months ago

Same issue on macos

alberduris · 9 months ago

Same issue:

alber@mac-joseador ### % claude

 ▐▛███▜▌   Claude Code v2.0.14
▝▜█████▛▘  Sonnet 4.5 · Claude Max
  ▘▘ ▝▝    /Users/alber/###

> /doctor 

 Diagnostics
 └ Currently running: native (2.0.14)
 └ Path: /Users/alber/.local/bin/claude
 └ Invoked: /Users/alber/.local/share/claude/versions/2.0.14
 └ Config install method: native
 └ Auto-updates enabled: default (true)
 └ Search: OK (bundled)

 Press Enter to continue…
ArtemB91 · 9 months ago

same issue, Windows 11

happens on second-third compacting in one session

maxritter · 9 months ago
> > Workaround that just worked for me (edit: just noticed #7530 (comment) also said this above): > > > > 1. ^C^C (exit claude) > > 2. claude (reopen) > > 3. /resume last session > > 4. /compact; this time it worked > > > > Agreed it's been quite frustrating, I just ran into it at "12% remaining", which I think is a new record for me: > > `` > > > /compact > > ⎿ Error: Error during compaction: Error: Conversation too long. Press esc twice > > to go up a few messages and try again. > > > > ─────────────────────────────────────────────────────────────────────────────────── > > > > > ─────────────────────────────────────────────────────────────────────────────────── > > ? for shortcutsContext low (12% remaining) · Run /compact to compact & continue > > `` > > > Working with claude code cli. Thanks. 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.

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..

mregnauld · 9 months ago

Same issue.
Exiting and restarting Claude "fixed" the problem, now I can compact my conversation.

villesau · 9 months ago

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.

felixniemeyer · 8 months ago

<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 --continue allowed me to /compact

flip-in · 8 months ago
<img alt="Image" width="745" height="282" src="https://private-user-images.githubusercontent.com/5720176/503235754-1ca2bfa4-41fb-4919-8319-ba4ca1bc3106.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NjEyMjQ2MzcsIm5iZiI6MTc2MTIyNDMzNywicGF0aCI6Ii81NzIwMTc2LzUwMzIzNTc1NC0xY2EyYmZhNC00MWZiLTQ5MTktODMxOS1iYTRjYTFiYzMxMDYucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MTAyMyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTEwMjNUMTI1ODU3WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MTg3OWJiNTRjMDllZTk0MTUxNTUzNDQ2YTA3ZDExYWRhZGU3ZWNhODcxMjM0ZGZiNDkzZWNhYWYxM2QwMjhhMiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.IjRXZVZlmj5VP7rF66cBZld92vTBXmXO6XyM1UhINlA"> 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 --continue allowed me to /compact

This worked for me

jamesblackwell · 8 months ago

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

freemarmoset · 8 months ago

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?

StayMeaty · 8 months ago

The fix that came with the latest update resolved the issue for me. Good job!

dokterbob · 8 months ago
The fix that came with the latest update resolved the issue for me. Good job!

Still broken here.

RayNawara · 8 months ago

Still broken for me.

StayMeaty · 8 months ago
Still broken for me.
Still broken here.

@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

carlosrodera · 8 months ago

same here

phillip-dwellyo · 8 months ago

Current version: 2.0.42

Still seeing this error.

sid374 contributor · 7 months ago

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 /bug so we can investigate?

likeahoss · 7 months ago

2.0.22 here, still occurs.

jizhi0v0 · 7 months ago

still exist in 2.0.55 version

hareeshmu · 7 months ago

<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

/compact
   Error: Error during compaction: Error: API Error: 400
    {"type":"error","error":{"type":"invalid_request_error","message":"messages.1.content.127:
    `thinking` or `redacted_thinking` blocks in the latest assistant message cannot be
    modified. These blocks must remain as they were in the original
    response."},"request_id":"req_011CVfzz6tzj9d2r8Zaztb4W"}
brianmcaudill · 7 months ago

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.

addean · 7 months ago

i found a workaround by following this step

  1. close claude code (ctrl+c) until you back to cmd
  2. run claude --model sonnet
  3. /resume to continue
  4. /compact

Voila, you just fix the error

davidjpnelson · 7 months ago
i found a workaround by following this step 1. close claude code (ctrl+c) until you back to cmd 2. run claude --model sonnet 3. /resume to continue 4. /compact Voila, you just fix the error

You are a beautiful soul, thank you for finding this workaround.

brianmcaudill · 7 months ago
> i found a workaround by following this step > > 1. close claude code (ctrl+c) until you back to cmd > 2. run claude --model sonnet > 3. /resume to continue > 4. /compact > > 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)

jodyshapiro · 7 months ago

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:

brianmcaudill left a comment (anthropics/claude-code#7530) <https://github.com/anthropics/claude-code/issues/7530#issuecomment-3642919413> i found a workaround by following this step 1. close claude code (ctrl+c) until you back to cmd 2. run claude --model sonnet 3. /resume to continue 4. /compact 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) — Reply to this email directly, view it on GitHub <https://github.com/anthropics/claude-code/issues/7530#issuecomment-3642919413>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AF7R4D3W6KIRGS7IPXHNE3D4BGRD3AVCNFSM6AAAAACGLVRTIKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTMNBSHEYTSNBRGM> . You are receiving this because you are subscribed to this thread.Message ID: @.***>
chillz-id · 7 months ago

/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"}

i found a workaround by following this step 1. close claude code (ctrl+c) until you back to cmd 2. run claude --model sonnet 3. /resume to continue 4. /compact Voila, you just fix the error

The hero we need, not deserve.

dantelope · 7 months ago

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....

BrunoCerberus · 6 months ago

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

BrunoCerberus · 6 months ago
i found a workaround by following this step 1. close claude code (ctrl+c) until you back to cmd 2. run claude --model sonnet 3. /resume to continue 4. /compact Voila, you just fix the error

Unfortunately that didn't work for me, /compact as the same way before using /resume

elucidsoft · 6 months ago

This 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.

usorama · 6 months ago

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" />

imageschool · 6 months ago

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" />

PhilETaylor · 6 months ago
This 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.

@elucidsoft This!! ^^

fehmisener · 6 months ago
This 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.

+1

GukDev · 6 months ago

@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

yigitkonur · 6 months ago

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

alberduris · 6 months ago

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).

phinolex · 5 months ago

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

cloudconsultants · 5 months ago

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

ericyangliu · 5 months ago

I'm on 2.1.31, and this just happened to me. Never happened before.

ryan-williams · 5 months ago

Same, hadn't seen this since September, seems it's back now in 2.1.31, and my workaround above doesn't help 🫠.

vilnitsky · 5 months ago

it hits on every /compact now v2.1.34

phinolex · 5 months ago

<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 /compact command still fails with:

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

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 /compact command failed with the same error as originally reported

schizoidcock · 5 months ago

Happened to me today too

kirniy · 5 months ago

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.

Iconised · 5 months ago

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%

RazeBerry · 5 months ago

Still a very annoying bug in 2.1.37 version using Opus

jeffgicharu · 5 months ago

Adding another data point:

  • Version: 2.1.37
  • Platform: Linux (Debian, x86_64)
  • Model: Opus 4.6 (Claude Max)
  • Trigger: Reading multiple large files (~19 files: docx, xlsx, pdf) in a single session using skill-based tools (pandoc, pandas, etc.)

Reproduction:

  1. Started a long session reading and summarizing many documents
  2. Context filled up → "Context limit reached · /compact or /clear to continue"
  3. /compactError: Error during compaction: Error: Conversation too long. Press esc twice to go up a few messages and try again.
  4. Repeated /compact → same error
  5. Session deadlocked — cannot compact, cannot continue, only /clear works

Still hitting this on the latest version (v2.1.37). This is a significant workflow blocker for document-heavy sessions.

blamechris · 5 months ago

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.

cstelmach · 5 months ago

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)

  1. Want to compact, can't: Error (see above).
  2. Note down the session id.
  3. Open and run in a new terminal tab (for safety): claude -resume SESSION_ID
  4. Try compacting again (might need to go up to the respective failed compacting attempt using ESC-ESC). _Sometimes works_.
  5. _If it doesn't work_: Quit session. Resume+kill: again and again, until you get in the resume session not the full chat displayed, but only the Claude mascot (e.g. initialisation screen).
  6. /compact again. _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.

vilnitsky · 5 months ago

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

polat-mustafa · 5 months ago

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.

phinolex · 5 months ago
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

ansonphong · 5 months ago

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.

welfvh · 5 months ago

Getting this all the time.

orenpa · 5 months ago

Getting this all the time.

switching to codex.. can't work with it

vladimir-trifonov · 5 months ago
/clear
/resume
/compact
junaidtitan · 4 months ago

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 treat on a bloated session typically removes 40-70% of the noise, which in my experience makes compaction succeed where it was failing before.

gonewx · 4 months ago

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:

  1. Run /compact proactively before the context gets too large, not when the system warns you
  2. Use Mantra to capture session states continuously — when compaction fails, I can browse back to any earlier point in the session and start a new one with the relevant context. It is basically insurance against compact failures.

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.

Vinix24 · 4 months ago

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.

yurukusa · 3 months ago

While the compaction error is a core issue, you can protect against state loss with a PreCompact hook:

HANDOFF="\$HOME/.claude/session-handoff.md"
{
    echo "# Pre-Compact State (\$(date -Iseconds))"
    [ -d .git ] && echo "Branch: \$(git branch --show-current 2>/dev/null)"
    [ -d .git ] && echo "Last commit: \$(git log --oneline -1 2>/dev/null)"
    [ -d .git ] && echo "Modified:" && git diff --name-only 2>/dev/null | head -5
} > "\$HANDOFF"
exit 0

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\

junaidtitan · 3 months ago

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 init

If anyone here is still hitting this, I'd appreciate hearing whether the guard daemon prevents the error from recurring.

claude[bot] contributor · 2 months ago

This is a duplicate of #2038, which was fixed as of version 2.1.85.

github-actions[bot] · 2 months ago

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.