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

Claude Code: Session-Destroying Failures from Compaction Timeouts

Open vanman2024 opened this issue 7 months ago • 4 comments

🐞 Critical Bug Report: Claude Code Unusable Due to Compaction Lockups & tool_use 400 Crashes

Environment

  • Platform:

    • [x] Claude CLI (Claude Code)
  • Claude CLI version: <!-- output of claude --version -->

  • OS: Windows 11 (via WSL)

  • Terminal: VS Code Integrated Terminal


❗ Summary

Claude Code is currently unusable for long-form or agent-based work due to two severe, session-breaking bugs:


🚫 1. Compaction Lockup (Unrecoverable Timeout)

  • When sessions exceed ~2,400 tokens, Claude triggers automatic compaction.

  • This process retries up to 10 times with:

    API Error (Request timed out.) · Retrying in X seconds… (attempt 1/10 to 10/10)
    
  • After the 10th retry, the session completely freezes.

  • Manually clearing the session results in:

    404: conversation not found
    
  • All progress is lost. The user must restart the conversation from scratch, breaking all continuity and flow.


❌ 2. tool_usetool_result Desync (400 Error Crash)

  • In active coding sessions, Claude may invoke a tool:

    tool_use: toolu_01RF5sCUUx9nbB3zCTHNqvCm
    
  • This fails with a 400 invalid_request_error:

    "messages.135: `tool_use` ids were found without `tool_result` blocks immediately after"
    
  • Once this error occurs, the session is permanently broken. Claude cannot continue, and user interaction is blocked.

  • The only solution is to clear and restart the entire session, losing all context and history.


Steps to Reproduce

Compaction Issue:

  1. Start session and interact until token count ~2,400
  2. Wait for auto-compaction
  3. Observe retry loop (10 attempts)
  4. Session becomes unresponsive
  5. Clearing shows 404, session dead

tool_use Error:

  1. Claude triggers a tool (e.g., from UI interaction)
  2. Fails to follow with tool_result
  3. CLI returns 400 error
  4. Session must be cleared and restarted

Expected Behavior

  • Compaction should run smoothly or recover gracefully
  • Every tool_use must be immediately followed by a tool_result
  • Session context must be preserved — crashes should never require wiping everything

Actual Behavior

  • Compaction stalls → session freezes → unrecoverable 404
  • tool_use desyncs → 400 error → session permanently crashes
  • Both require full restart, breaking continuity
  • Makes Claude Code impossible to use for sustained or structured development

Severity

🔥 Critical — Full Session Loss These bugs completely prevent serious usage. They:

  • Break long sessions
  • Block agent workflows
  • Destroy continuity
  • Force manual restarts multiple times per day

vanman2024 avatar Jun 21 '25 21:06 vanman2024

Update Todos ⎿  ☒ Diagnose and resolve Claude Code session issues ☒ Test MCP specialists systematically to identify issues ☐ Fix session-intelligence specialist coroutine error in line 308 ⎿ API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.53: tool_use ids were found without tool_result blocks immediately after: toolu_01R83qd4dLX3KxQUS2ADCQrb. Each tool_use block must have a corresponding tool_result block in the next message."}}

vanman2024 avatar Jun 21 '25 22:06 vanman2024

Just contirially having issuses with conversations compacting so frustration I hope you fix this ⎿ API Error (Request timed out.) · Retrying in 1 seconds… (attempt 1/10) ⎿ API Error (Request timed out.) · Retrying in 1 seconds… (attempt 2/10) ⎿ API Error (Request timed out.) · Retrying in 2 seconds… (attempt 3/10)

✽ Compacting conversation… (307s · ↓ 363 tokens · esc to interrupt)

vanman2024 avatar Jun 21 '25 22:06 vanman2024

this is still going ont today just does not seem to consistently compact
⎿ API Error (Request timed out.) · Retrying in 1 seconds… (attempt 1/10) ⎿ API Error (Request timed out.) · Retrying in 1 seconds… (attempt 2/10) ⎿ API Error (Request timed out.) · Retrying in 2 seconds… (attempt 3/10) ⎿ API Error (Connection error.) · Retrying in 4 seconds… (attempt 4/10) ⎿ TypeError (fetch failed) ⎿ API Error (Request timed out.) · Retrying in 8 seconds… (attempt 5/10) ⎿ API Error (Request timed out.) · Retrying in 17 seconds… (attempt 6/10) ⎿ API Error (Request timed out.) · Retrying in 37 seconds… (attempt 7/10) ⎿ API Error (Request timed out.) · Retrying in 33 seconds… (attempt 8/10)

✶ Compacting conversation… (610s · ↓ 442 tokens · esc to interrupt)

vanman2024 avatar Jun 23 '25 00:06 vanman2024

I've had this problem for a week. Claude suggested me to try with a different network, indeed going though my phone worked! So I ended up getting a VPN and now it's all smooth. So check if your ISP may be blocking traffic to https://api.anthropic.com/

thenikso avatar Jun 29 '25 14:06 thenikso

Thanks for the report! Both of these are fixed in more recent versions. Please claude update to the latest.

bcherny avatar Aug 22 '25 18:08 bcherny

Thanks Boris.


From: Boris Cherny @.> Sent: Friday, August 22, 2025 11:29:57 AM To: anthropics/claude-code @.> Cc: vanman2024 @.>; Author @.> Subject: Re: [anthropics/claude-code] Claude Code: Session-Destroying Failures from Compaction Timeouts (Issue #2423)

[https://avatars.githubusercontent.com/u/1761758?s=20&v=4]bcherny left a comment (anthropics/claude-code#2423)https://github.com/anthropics/claude-code/issues/2423#issuecomment-3215253363

Thanks for the report! Both of these are fixed in more recent versions. Please claude update to the latest.

— Reply to this email directly, view it on GitHubhttps://github.com/anthropics/claude-code/issues/2423#issuecomment-3215253363, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BLWU4RZQUTGUDKMQRZUMIYD3O5OSLAVCNFSM6AAAAAB72R6YUWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTEMJVGI2TGMZWGM. You are receiving this because you authored the thread.Message ID: @.***>

vanman2024 avatar Aug 22 '25 19:08 vanman2024

Looks like this is back...

⎿ API Error (api.anthropic.com | 504: Gateway time-out) · Retrying in 4 seconds… (attempt 4/10) ⎿ API Error (api.anthropic.com | 504: Gateway time-out) · Retrying in 10 seconds… (attempt 5/10) ⎿ API Error (api.anthropic.com | 504: Gateway time-out) · Retrying in 17 seconds… (attempt 6/10) ⎿ API Error (api.anthropic.com | 504: Gateway time-out) · Retrying in 33 seconds… (attempt 7/10) ⎿ API Error (api.anthropic.com | 504: Gateway time-out) · Retrying in 39 seconds… (attempt 8/10) ⎿ API Error (api.anthropic.com | 504: Gateway time-out) · Retrying in 35 seconds… (attempt 9/10) ⎿ API Error (api.anthropic.com | 504: Gateway time-out) · Retrying in 35 seconds… (attempt 10/10)

uberspeck avatar Aug 29 '25 01:08 uberspeck

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.

github-actions[bot] avatar Sep 05 '25 14:09 github-actions[bot]