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

[BUG] Error loop between 'context low' and '/compact'

Open zxdxjtu opened this issue 9 months ago • 38 comments

Environment

  • Platform (select one):
    • [ ] Anthropic API
  • Claude CLI version: 1.0.17
  • Operating System: macOS 12
  • Terminal: normal

Bug Description

⎿ Context low · Run /compact to compact & continue

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

Image

Steps to Reproduce

Expected Behavior

Actual Behavior

Additional Context

zxdxjtu avatar Jun 13 '25 02:06 zxdxjtu

same here, cant get out of it. I followed the instructions esc, went up a few messages to find a large message I pasted a bunch into, i deleted the large paste, reformatted my message and tried again, still stuck.

santekotturi avatar Jun 13 '25 17:06 santekotturi

Same experience. Then got rate limited 💀

angerman avatar Jun 14 '25 10:06 angerman

Confirmed on

Environment

  • Connection: Claude Code Max
  • Claude Version: 1.0.24 (Claude Code)
  • Terminal: Windows Terminal
  • OS: Ubuntu 24.04.2 LTS

adamkwhite avatar Jun 16 '25 22:06 adamkwhite

Same deal here.

innocentdiaz avatar Jun 17 '25 16:06 innocentdiaz

Similar to #42 - which has been active again.

Downchuck avatar Jun 17 '25 16:06 Downchuck

Same here

jeitnier avatar Jun 19 '25 02:06 jeitnier

Same here

contiyo avatar Jun 19 '25 14:06 contiyo

same here

nhod avatar Jun 20 '25 16:06 nhod

same here

sonic4002 avatar Jun 24 '25 14:06 sonic4002

same here, any solution?

ItzikEzra avatar Jun 30 '25 11:06 ItzikEzra

I was able to unlock with /clear.

agustin107 avatar Jul 04 '25 23:07 agustin107

@agustin107 you ran /clear and then were able to continue the conversation? I tried that, but it went back to the "run /compact" message.

fwiw: I was encountering this issue in vs code. I quit and started claude in terminal. From there, I was able to get out of the loop.

polyphonic13 avatar Jul 06 '25 19:07 polyphonic13

I was able to resolve this by clearing out ~/.claude/projects and ~/.claude/todos. Note: this is a destructive action and will remove existing data.

gabewillen avatar Jul 09 '25 22:07 gabewillen

me too

micuentadecasa avatar Jul 10 '25 12:07 micuentadecasa

Experiencing the same issue. All the suggested solutions don't work for me. Can't use Claude Code at all.

kdvmgn avatar Jul 13 '25 15:07 kdvmgn

For me restarting helped for now.

dereuromark avatar Jul 23 '25 23:07 dereuromark

Same here too

yabasha avatar Aug 05 '25 19:08 yabasha

on macOS :

Image

thorleydk avatar Aug 12 '25 04:08 thorleydk

Also experiencing this

> /compact
  ⎿ Error: Error during compaction: Error: API Error: 400 {"type":"error"
    ,"error":{"type":"invalid_request_error","message":"input length and
    `max_tokens` exceed context limit: 199544 + 20000 > 200000, decrease
    input length or `max_tokens` and try again"}}

> /compact make sure you do not exceed context limit
  ⎿ Error: Error during compaction: Error: API Error: 400 {"type":"error"
    ,"error":{"type":"invalid_request_error","message":"input length and
    `max_tokens` exceed context limit: 199714 + 20000 > 200000, decrease
    input length or `max_tokens` and try again"}}

> /compact
  ⎿ Error: Error during compaction: Error: API Error: 400 {"type":"error"
    ,"error":{"type":"invalid_request_error","message":"input length and
    `max_tokens` exceed context limit: 199867 + 20000 > 200000, decrease
    input length or `max_tokens` and try again"}}

pbower avatar Aug 14 '25 20:08 pbower

same here

⎿  Context low · Run /compact to compact & continue

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

Connection: Claude Code Max Claude Version: 1.0.81 (Claude Code) Terminal: built-in Terminal / IntelliJ IDEA terminal OS: macOS 15.6

adv3nt3 avatar Aug 15 '25 21:08 adv3nt3

@here - ok everyone: very simply - vibe coding the CLI is super cool. But, a set of strong validation to a) ensure invalid UTF-8 doesn't get in the jsonl files and b) have a basic recovery mechanism when the context length being compacted went over the high water mark is... completely doable my dear friends at Anthropic. For everyone else go read Empire of AI - it'll give you a little more context as to why the folk at Anthropic are working there instead of at other positions.

Downchuck avatar Aug 16 '25 03:08 Downchuck

Thanks for the report. Couple questions:

  1. Do you guys have auto-compact switched off?
  2. If anyone is able to /bug and upload their transcript + share the feedback_id here -> this would greatly help with debugging

sid374 avatar Aug 17 '25 03:08 sid374

Thanks for the report. Couple questions:

  1. Do you guys have auto-compact switched off?
  2. If anyone is able to /bug and upload their transcript + share the feedback_id here -> this would greatly help with debugging

Hi there,

  1. When I posted it above, it happened the once randomly during auto-compact.
  2. i don’t have that available, but will do so if it happens again.

pbower avatar Aug 17 '25 15:08 pbower

same here

/clear ⎿  (no content)

claude usage ⎿  Context low · Run /compact to compact & continue

/compact ⎿  Compacted. ctrl+r to see full summary

still having problem:  Context low · Run /compact to compact & continue

SlowBoat2015 avatar Aug 18 '25 00:08 SlowBoat2015

same here

YeautyYE avatar Aug 23 '25 15:08 YeautyYE

I had this happening today too. Opening a brand new session, context would be mostly empty as normal.

Image

But as soon as I pasted in my prompt which I had been writing in Apple Notes, Claude was immediately at >100% context window usage.

Image

/clear did nothing and /compact would fail as in OP's message.

I was eventually able to recover by re-processing my prompt (which was only 4 paragraphs of text long!). I noticed that when I first pasted it into Cursor, I got this warning.

Image

So I removed the line terminators and then asked Cursor to reformat the document for me. It did a minimal tidy up to format it as Markdown, but it must've cleared up some weird encoding issue. Pasting the result into a new session allowed Claude to keep going.

rossshannon avatar Aug 25 '25 10:08 rossshannon

2. bug

Done: Feedback ID: 5f378575-474a-428c-80e8-cc6032a3b8fa

swilkeyhc avatar Sep 23 '25 08:09 swilkeyhc

Im having this issue, and I think it relates to the PostToolUse hook Ive setup, and if the issue is in there it doesnt autocompact, does that tally?

Both times it looked like :

  ⎿  Hook PostToolUse:Write completed
  ⎿  Context low · Run /compact to compact & continue

haveaguess avatar Sep 23 '25 16:09 haveaguess

/clear resolve

vashxd avatar Sep 26 '25 11:09 vashxd

/init fixes this without clearing your work

FinanceJT avatar Sep 30 '25 18:09 FinanceJT