[Bug] Compact command fails with "Conversation too long" error
Bug Description
/compact ⎿ Error: Error during compaction: Error: Conversation too long. Press esc twice to go up a few messages and try again.
Environment Info
- Platform: darwin
- Terminal: Apple_Terminal
- Version: 2.0.21
- Feedback ID: 7831898e-c076-49fc-b910-803864c2e9ab
Errors
[{"error":"SyntaxError: Unexpected token '`', \"```json\n{\n\"... is not valid JSON\n at JSON.parse (<anonymous>)\n at file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:62:719\n at Q (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:8:15093)\n at Zn2 (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1056:20444)\n at process.processTicksAndRejections (node:internal/process/task_queues:105:5)","timestamp":"2025-10-17T20:52:50.132Z"},{"error":"Error: Request was aborted.\n at Yy.makeRequest (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:356:3850)\n at process.processTicksAndRejections (node:internal/process/task_queues:105:5)","timestamp":"2025-10-17T20:53:32.968Z"},{"error":"Error: Request was aborted.\n at Yy.makeRequest (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:356:3850)\n at process.processTicksAndRejections (node:internal/process/task_queues:105:5)","timestamp":"2025-10-17T20:54:56.554Z"},{"error":"SyntaxError: Unexpected token '`', \"```json\n{\n\"... is not valid JSON\n at JSON.parse (<anonymous>)\n at file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:62:719\n at Q (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:8:15093)\n at Zn2 (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1056:20444)\n at process.processTicksAndRejections (node:internal/process/task_queues:105:5)","timestamp":"2025-10-17T20:55:21.536Z"},{"error":"Error: 400 {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"prompt is too long: 201705 tokens > 200000 maximum\"},\"request_id\":\"req_011CUDSLDhB3LuZvNaFyTL3h\"}\n at E4.generate (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:202:83047)\n at Yy.makeStatusError (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:356:2117)\n at Yy.makeRequest (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:356:5330)\n at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n at async Tz1.model (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:3311:19535)\n at async Tz1 (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:2649:39781)\n at async fRQ (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:3311:19689)\n at async file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:3311:13874\n at async Ma0 (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:3311:4494)\n at async aQ1 (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:3311:13844)","timestamp":"2025-10-17T20:55:40.878Z"},{"error":"SyntaxError: Unexpected token '`', \"```json\n{\n\"... is not valid JSON\n at JSON.parse (<anonymous>)\n at file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:62:719\n at Q (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:8:15093)\n at Zn2 (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1056:20444)\n at process.processTicksAndRejections (node:internal/process/task_queues:105:5)","timestamp":"2025-10-17T20:56:36.469Z"},{"error":"Error: 400 {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"prompt is too long: 201722 tokens > 200000 maximum\"},\"request_id\":\"req_011CUDSQKTZD3Xzrz96AocBT\"}\n at E4.generate (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:202:83047)\n at Yy.makeStatusError (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:356:2117)\n at Yy.makeRequest (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:356:5330)\n at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n at async Tz1.model (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:3311:19535)\n at async Tz1 (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:2649:39781)\n at async fRQ (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:3311:19689)\n at async file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:3311:13874\n at async Ma0 (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:3311:4494)\n at async aQ1 (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:3311:13844)","tim
Note: Error logs were truncated.
Losing Context is the worst crime of all.
Found 3 possible duplicate issues:
- https://github.com/anthropics/claude-code/issues/9089
- https://github.com/anthropics/claude-code/issues/9141
- https://github.com/anthropics/claude-code/issues/7594
This issue will be automatically closed as a duplicate in 3 days.
- If your issue is a duplicate, please close it and 👍 the existing issue instead
- To prevent auto-closure, add a comment or 👎 this comment
🤖 Generated with Claude Code
Prevent Auto Close
This should be fixed in 2.0.31.
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.