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

Resolved 💬 49 comments Opened Jun 13, 2025 by zxdxjtu Closed Apr 18, 2026
💡 Likely answer: A maintainer (sid374, contributor) responded on this thread — see the highlighted reply below.

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.

<img width="942" alt="Image" src="https://github.com/user-attachments/assets/e4170bc1-6076-4814-b7f4-4c81e81171d7" />

Steps to Reproduce

  1. <!-- First step -->
  2. <!-- Second step -->
  3. <!-- And so on... -->

Expected Behavior

<!-- What you expected to happen -->

Actual Behavior

<!-- What actually happened -->

Additional Context

<!-- Add any other context about the problem here, such as screenshots, logs, etc. -->

View original on GitHub ↗

49 Comments

santekotturi · 1 year ago

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.

angerman · 1 year ago

Same experience. Then got rate limited 💀

adamkwhite · 1 year ago

Confirmed on

Environment

  • Connection: Claude Code Max
  • Claude Version: 1.0.24 (Claude Code)
  • Terminal: Windows Terminal
  • OS: Ubuntu 24.04.2 LTS
innocentdiaz · 1 year ago

Same deal here.

Downchuck · 1 year ago

Similar to #42 - which has been active again.

jeitnier · 1 year ago

Same here

contiyo · 1 year ago

Same here

nhod · 1 year ago

same here

sonic4002 · 1 year ago

same here

ItzikEzra · 1 year ago

same here, any solution?

agustin107 · 1 year ago

I was able to unlock with /clear.

polyphonic13 · 1 year ago

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

gabewillen · 1 year ago

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.

micuentadecasa · 1 year ago

me too

kdvmgn · 1 year ago

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

dereuromark · 11 months ago

For me restarting helped for now.

yabasha · 11 months ago

Same here too

thorleydk · 11 months ago

on macOS :

<img width="850" height="300" alt="Image" src="https://github.com/user-attachments/assets/8823311c-7635-4879-b5c9-7b4440539aa2" />

pbower · 11 months ago

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"}}
adv3nt3 · 11 months ago

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

Downchuck · 11 months ago

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

sid374 contributor · 11 months ago

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
pbower · 11 months ago
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.
SlowBoat2015 · 11 months ago

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

YeautyYE · 10 months ago

same here

rossshannon · 10 months ago

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

<img width="906" height="286" alt="Image" src="https://github.com/user-attachments/assets/7356643e-8e4d-4a75-b431-ab13da0783fd" />

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.

<img width="850" height="341" alt="Image" src="https://github.com/user-attachments/assets/26c91255-751a-4046-bd58-75fb6807b370" />

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

<img width="254" height="345" alt="Image" src="https://github.com/user-attachments/assets/104e1bfe-bd58-4b37-91cd-a3ce25ad1795" />

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.

swilkeyhc · 9 months ago
2\. bug

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

haveaguess · 9 months ago

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

/clear resolve

FinanceJT · 9 months ago

/init fixes this without clearing your work

greenpdx · 8 months ago

I have tried /clear and /init and /compact but nothing works

adamkwhite · 8 months ago

i experience the same thing. No tool use

Anthropic Max Plan
Claude CLI version: 2.0.31
Operating System: Windows 10
Terminal: Windows Terminal / WSL Ubuntu

doriancollier · 8 months ago
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 ``

The response from your hooks enters context. If the hook response is longer than your remaining context then you'll end up with the issue ( I have not definitely proved this, but this seems correct :) ). Good luck

adamkwhite · 8 months ago

I experience this without any post tool hooks.

jgarte · 7 months ago

I experienced this today as well.

gabrielbryk · 6 months ago

Same issue here, seems to be reported in a LOT of different issues in various ways. Mostly related to sub agents polluting context of main agent in some way causing main agent to have context that is 100+% total allowed which causes compact to fail

ThatDragonOverThere · 6 months ago

Still happening. Happens multiple times a week. Come on, guys. Get this fixed.

ThatDragonOverThere · 6 months ago

Additional reproduction cases (Jan 2026)

Still encountering this bug frequently:

Case 1: Parallel sub-agents

● Task Output af8f1e0
  ⎿  Context low · Run /compact to compact & continue
● Agent "Task 5.1" completed.
  ⎿  Context low · Run /compact to compact & continue

Case 2: Background bash command (not sub-agents)

● Task Output(non-blocking) b67d801
  ⎿  ... +3045 lines
  ⎿  Context low · Run /compact to compact & continue
● Background command completed (exit code 0).
  ⎿  Context low · Run /compact to compact & continue

Key observations:

  • /compact doesn't work in this state
  • /feedback also fails with "Error submitting feedback / bug report"
  • Pattern: any situation where multiple tool results come in sequence triggers the loop
  • Not limited to sub-agents - also happens with background bash commands

Environment: Windows 11, Node.js v22.12.0

ThatDragonOverThere · 5 months ago

New reproduction: API Error 400 due to tool use concurrency issues

When running 2 parallel Bash agents (overnight pipeline + EOD pipeline), after both completed successfully:

● 2 Bash agents finished (ctrl+o to expand)
   ├─ Run overnight pipeline · 9 tool uses · 31.9k tokens
   │  ⎿  Done
   └─ Run EOD pipeline · 7 tool uses · 45.1k tokens
      ⎿  Done

On the next user message, got:

API Error: 400 due to tool use concurrency issues. Run /rewind to recover the conversation.

This may be related to the compaction loop - user also saw "max compactions exceeded" error flash in the same session before this occurred.

ThatDragonOverThere · 5 months ago

Additional Report - Claude Desktop on Windows

Platform: Claude Desktop (latest), Windows 10/11
Date: January 30, 2026

Experiencing this consistently on Claude Desktop. The send button silently fails when context is high — message disappears with no error, no compaction attempt, nothing. Have to kill and restart the session.

This compounds with other Desktop issues:

  • Context percentage display is wrong (#20638) — shows 75% when actual usage is 93%, so you don't even know you're near the limit
  • When compaction does trigger, it can lose entire conversation history (#19888)

The combination makes Desktop nearly unusable for long coding sessions: you can't trust the usage meter, sending silently fails with no feedback, and if compaction kicks in it may destroy your context anyway.

Would love to see either a proper error message when send fails, or a reliable auto-compact that preserves instructions.

ThatDragonOverThere · 5 months ago

Another Instance - "This isn't working right now"

Platform: Claude Desktop (latest), Windows
Date: February 3, 2026

New error variant: when compaction triggers, Desktop now shows "this isn't working right now" and fails completely. No compaction occurs, session is stuck.

This is a different failure mode from the silent send failure reported earlier — at least this one shows an error message, but the result is the same: dead session requiring restart.

ThatDragonOverThere · 5 months ago

Another Instance - "Response could not be fully generated"

Platform: Claude Desktop (latest), Windows
Date: February 3, 2026

Yet another compaction failure variant. This time the error message is: "Claude's response could not be fully generated"

That's three different failure messages for the same root cause in recent sessions:

  1. Silent send failure (no message at all)
  2. "This isn't working right now"
  3. "Claude's response could not be fully generated"

All result in a dead session requiring restart.

ThatDragonOverThere · 5 months ago

Another Compaction Failure Variant - "Exceed length limit"

Platform: Claude Desktop, Windows
Date: February 5, 2026

New error message variant:

"Your message will exceed the length limit for this chat. Try attaching fewer or smaller files or starting a new conversation"

This is now the fourth distinct failure message for compaction issues on Desktop:

  1. Silent send failure (no message at all)
  2. "This isn't working right now"
  3. "Claude's response could not be fully generated"
  4. NEW: "Your message will exceed the length limit for this chat..."

All result in dead sessions. The system clearly knows it needs to compact but fails to do so, offering no recovery path except "start over."

swilkeyhc · 5 months ago

​​
​​​​
Stephen Wilkey
Technology Business Partner
,
Hammond Innovations
E: @.****@.>
|
P: +61 4 0314 9968<tel:+61%204%200314%209968>
|
M: +61 4 0314 9968<tel:+61%204%200314%209968>
Level 3-4, Building B, 207 Pacific Highway, St Leonards NSW 2065
www.hammondinnovations.com.au<https://au.content.exclaimer.net?url=https%3A%2F%2Fwww.hammondinnovations.com.au%2F&tenantid=NLIqmlkoEe-9_QAiSJJmVA&templateid=c30a519ef0cff0118196000d3a6a926d&excomponentid=W6bvJgBHL5FBYT6xWR9Anzifg5rdKo0fyvzt4Y4wwko&excomponenttype=Link&signature=AmlzhjMIVXQAHP8VBQ79IQ0zZB6V895Gu-Nz6Ari1tOAQQuqIL7Yw1xJpHphLzt0YS7OlA0YNao7jfAsCq5h16vncMH00Iq3pITjv87-vStBdxQiUC0FuOc6d-L0mcYK10PD-AWibGGezQ2kx57NzMfaayhwAmrAYEQkOXs-pnwU0cx1NallDUWJBd6r2LnuB203WKYXWVOKxwzHyK4DAUxRqkFJNHNXCX33D2YtF4SH9J5sVdjwDxjy4T61VoiTqkFoeNZ8RKMwy5YegKMJENnWOhuFVoePCodcHmSSO60qHVRRsjb6aCVrJ4EpST9hS_iwi799s6SbhiCO_afveg&v=1>
[Donate to The HammondCare Foundation]<https://au.content.exclaimer.net?url=https%3A%2F%2Fwww.hammond.com.au%2Fdonation%3Futm_campaign%3DFND%2520%257C%2520UTM%2520tracking%2520%257C%2520ongoing%26utm_source%3DeSig-FND-INN-teams&tenantid=NLIqmlkoEe-9_QAiSJJmVA&templateid=c30a519ef0cff0118196000d3a6a926d&excomponentid=DrtkSx3cZqq7fSC5xJbF3nGQTvVtBPK8SFLLYoLtW7o&excomponenttype=Image&signature=VeiSpYdgwwCMr5vzYChV3spKkR-DYu9EmTYRJIMWsnj-po64G2VGpQkqaSewrBddjiMPbX0bEX-iZubi5gQATj7O5r0Kgt3UIR-RBBOnZbL4u1FTcSylug0Rtu95Pb0LLHDcrA4QEEuxa9Fy6GG2hMy_QY1GiE1_s9BM9OhWeCFi_UkqVdo31hXbu3SCgStRB-NSc9Fq4o97l4JPlDwxYGBws953aSiPMJb-2MJD-aF1R5V6G50cfoMT6steHe_mSy6v5Pqfvc_zaWZvh2iIoTI2r5KIYUwtZnqN-8HmP-ZxIVVfKZXHuaIt7uyB5NzZZgArmP0R4xUB96Ybqsu0Jw&v=1>
________________________________
From: ThatDragonOverThere
@.*>
Sent: Friday, 6 February 2026 05:26
To: anthropics/claude-code @.*>
Cc: Stephen Wilkey
@.>; Comment @.**>
Subject: Re: [anthropics/claude-code] [BUG] Error loop between 'context low' and '/compact' (Issue #2038)

[https://avatars.githubusercontent.com/u/168599305?s=20&v=4]ThatDragonOverThere left a comment (anthropics/claude-code#2038)<https://urldefense.com/v3/__https://github.com/anthropics/claude-code/issues/2038*issuecomment-3855148789__;Iw!!PRoTsabzKIOu!S4AJL8Y706lPE4W_PNCs9Ct28tXXnGsjNzvnO2pOlk7n3UanIbkJJzzAbpJ6WnmgbDKj4Yxwz9fL8vzR521RHlh2NkI$>
Another Compaction Failure Variant - "Exceed length limit"

Platform: Claude Desktop, Windows
Date: February 5, 2026

New error message variant:

"Your message will exceed the length limit for this chat. Try attaching fewer or smaller files or starting a new conversation"

This is now the fourth distinct failure message for compaction issues on Desktop:

  1. Silent send failure (no message at all)
  2. "This isn't working right now"
  3. "Claude's response could not be fully generated"
  4. NEW: "Your message will exceed the length limit for this chat..."

All result in dead sessions. The system clearly knows it needs to compact but fails to do so, offering no recovery path except "start over."


Reply to this email directly, view it on GitHub<https://urldefense.com/v3/__https://github.com/anthropics/claude-code/issues/2038*issuecomment-3855148789__;Iw!!PRoTsabzKIOu!S4AJL8Y706lPE4W_PNCs9Ct28tXXnGsjNzvnO2pOlk7n3UanIbkJJzzAbpJ6WnmgbDKj4Yxwz9fL8vzR521RHlh2NkI$>, or unsubscribe<https://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/BBIRSJBRLEZR7NEIYWPUV5L4KODO7AVCNFSM6AAAAAB7G4YKLOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTQNJVGE2DQNZYHE__;!!PRoTsabzKIOu!S4AJL8Y706lPE4W_PNCs9Ct28tXXnGsjNzvnO2pOlk7n3UanIbkJJzzAbpJ6WnmgbDKj4Yxwz9fL8vzR521R7M4Df4E$>.
You are receiving this because you commented.Message ID: @.***>

This email and all attachments are for the recipient only and may contain confidential information. If you have received this message in error, we kindly request that you do not use the information in any way, and please let the sender know immediately and delete the email.

gonewx · 4 months ago

This issue highlights a fundamental limitation: when context gets too long, you are stuck in a lose-lose situation. Compact fails, and you cannot continue working.

The real cost here is not just the interrupted session — it is all the context you built up (decisions, file knowledge, debugging steps) that gets lost when you have to start fresh.

One approach I have found helpful: use Mantra to snapshot sessions before they hit the context limit. When compaction fails, you can go back to any earlier point in the session and branch from there — keeping the context that matters without hitting the limit.

It does not fix the compact bug itself, but it means a failed compact no longer means "start over from scratch."

yurukusa · 3 months ago

/tmp/gh-comment-2038.md

ThatDragonOverThere · 3 months ago

v2.1.87 — context limit + rate limit = complete lockout. Two bugs compound into session death.

Reproducing on v2.1.87, Windows, Max plan:

  1. Session hit context limit mid-analysis (exit forensics work — streak analysis cut off)
  2. User tried @"bug-reporter (agent)" to delegate — returned "Context limit reached · /compact or /clear to continue"
  3. User tried /compact — returned "Error: Error during compaction: Error: API Error: Rate limit reached"

The compaction itself is being rate-limited. So the user has:

  • Can't continue (context full)
  • Can't delegate to agent (context full)
  • Can't compact (rate limited)
  • Only option: /clear and lose everything

v2.1.85 fixed /compact failing when the conversation is too large for the compact request to fit. This is the inverse: the compact request fits, but it's being rate-limited at the API layer. Combined with #37394 (rate limits burning 5-10x faster than normal since Mar 16), compaction is now failing not from context size but from rate limiting.

When compaction itself is rate-limited, the context window is a dead end. There is no recovery path that preserves session state.

System: Windows 11, Node.js, v2.1.87, Max plan

ashwin-ant collaborator · 2 months ago

This was fixed in v2.1.85 — /compact now retries with the oldest messages dropped when the compact request itself is too large, instead of failing with 'Conversation too long'. If you're still seeing this in the latest version, please comment with your version and repro and we'll reopen.

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.