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

🚨 BUG: Persistent Unnecessarily Auto-Compact Triggered in an INFINITE LOOP - MAKING CLAUDE CODE USELESS!

Open LarsArtmann opened this issue 6 months ago • 5 comments

Bug Description "Context left until auto-compact: 169%" CLAUDE IS COMPACTING AGAIN and AGAIN and AGAIN GETTING DONE ABSOLUTELY NOTHING!!!!!!!!!!!!! :angry:! It makes ZERO sense! This project had a empty CLAUDE.md, and I deleted it. BOTH no difference! RESTARTING DOESN'T WORK EITHER!!! EVEN A fucking /init triggers auto-compact right away!!!

Environment Info

  • Platform: darwin
  • Terminal: intellij
  • Version: 1.0.29
  • Feedback ID: 7b078624-922c-4a2e-817b-a133a96795dc

Errors

[{"error":"Error: Command failed: security find-generic-password -a $USER -w -s \"Claude Code\"\nsecurity: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.\n\n    at genericNodeError (node:internal/errors:983:15)\n    at wrappedFn (node:internal/errors:537:14)\n    at checkExecSyncError (node:child_process:882:11)\n    at execSync (node:child_process:954:15)\n    at EZ (file:///Users/larsartmann/.bun/install/global/node_modules/@anthropic-ai/claude-code/cli.js:659:3921)\n    at file:///Users/larsartmann/.bun/install/global/node_modules/@anthropic-ai/claude-code/cli.js:582:9014\n    at Q (file:///Users/larsartmann/.bun/install/global/node_modules/@anthropic-ai/claude-code/cli.js:526:17199)\n    at QX (file:///Users/larsartmann/.bun/install/global/node_modules/@anthropic-ai/claude-code/cli.js:582:8160)\n    at qS (file:///Users/larsartmann/.bun/install/global/node_modules/@anthropic-ai/claude-code/cli.js:582:7241)\n    at L9 (file:///Users/larsartmann/.bun/install/global/node_modules/@anthropic-ai/claude-code/cli.js:582:11408)","timestamp":"2025-06-19T03:30:30.454Z"},{"error":"Error: Request was aborted.\n    at so._createMessage (file:///Users/larsartmann/.bun/install/global/node_modules/@anthropic-ai/claude-code/cli.js:1306:6810)\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)","timestamp":"2025-06-19T03:37:26.804Z"},{"error":"Error: Request was aborted.\n    at Ow.makeRequest (file:///Users/larsartmann/.bun/install/global/node_modules/@anthropic-ai/claude-code/cli.js:1315:3597)\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)","timestamp":"2025-06-19T03:37:26.836Z"}]

Note: I did not edit my feedback from what /bug created.

LarsArtmann avatar Jun 19 '25 03:06 LarsArtmann

Hi, could you try running /status to see what additional memory files might be getting included in the context?

levpopov avatar Jun 20 '25 21:06 levpopov

Hi, could you try running /status to see what additional memory files might be getting included in the context?

~/.claude/CLAUDE.md is included. It's 202 lines, 6867 characters, and 6.867 bytes. This is very unlikely the root cause.

vis: @levpopov

LarsArtmann avatar Jun 20 '25 21:06 LarsArtmann

[!TIP] WORK AROUND: Disable auto-compact via claude config set -g autoCompactEnabled false and /compact manually.

I managed to get Claude Code working again by disabling auto-compact (which is not nice, but at least it works). Currently I get stuff like this: Context low (214% remaining) or directly after a manual compact: Context low (100% remaining)

LarsArtmann avatar Jun 20 '25 21:06 LarsArtmann

I just updated to the latest version of Claude Code, and restarted a conversation. It seemed to not respect the global config. Try:

[!TIP] /config and then disable Auto-compact directly in Claude Code.

LarsArtmann avatar Jun 21 '25 01:06 LarsArtmann

Another person managed to get it working after a restart. See: https://github.com/anthropics/claude-code/issues/2391#issuecomment-2993237142

LarsArtmann avatar Jun 21 '25 01:06 LarsArtmann

Found a workaround. Not sure how detrimental it is to context awareness, but deleting/renaming the settings.local file in the .claude folder fixed the context issues for me. I am guessing the file just got too large for Claude to be able to effectively read because of all the bash commands it stored away that weren't reusable in most cases.

if you want to YOLO it, you can use "claude --dangerously-skip-permissions" to bypass permission prompts (the ones that when saved to the project, fill up the setting.local.json file and ultimately cause the context issue)

But that is absolute last resort and very dangerous to do. Hence the flag name....

Codewow avatar Aug 25 '25 12:08 Codewow

I'm in the exact same loop and my settings.local is only 38 lines. I don't think that's the root cause.

timkjr avatar Aug 25 '25 20:08 timkjr

I'm in the exact same loop and my settings.local is only 38 lines. I don't think that's the root cause.

I don't think it's the root cause either, but it's worth trying the workaround to see if it gets you out of it.

Codewow avatar Aug 25 '25 20:08 Codewow

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

github-actions[bot] avatar Dec 04 '25 10:12 github-actions[bot]