claude-code - 💡(How to fix) Fix Interactive session turns hang intermittently on all models (Opus 4.8, Sonnet 4.6) — headless calls fast

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

In an interactive Claude Code session, inference turns frequently hang (stall for 30s–several minutes, or indefinitely until interrupted) on all models tested, including claude-opus-4-8 and claude-sonnet-4-6. The same API path works fine from a headless claude -p call.

Root Cause

In an interactive Claude Code session, inference turns frequently hang (stall for 30s–several minutes, or indefinitely until interrupted) on all models tested, including claude-opus-4-8 and claude-sonnet-4-6. The same API path works fine from a headless claude -p call.

Code Example

claude-code-20250219, context-1m-2025-08-07, interleaved-thinking-2025-05-14,
thinking-token-count-2026-05-13, context-management-2025-06-27,
prompt-caching-scope-2026-01-05, mid-conversation-system-2026-04-07,
advisor-tool-2026-03-01, advanced-tool-use-2025-11-24, effort-2025-11-24,
cache-diagnosis-2026-04-07

---

[log_ad9e50, request-id: "req_011CbVeji1QK5bZFDKXM3FsK"] post https://api.anthropic.com/v1/messages?beta=true succeeded with status 200 in 1542ms
anthropic-ratelimit-requests-remaining: 49
anthropic-ratelimit-input-tokens-remaining: 486000
RAW_BUFFERClick to expand / collapse

Summary

In an interactive Claude Code session, inference turns frequently hang (stall for 30s–several minutes, or indefinitely until interrupted) on all models tested, including claude-opus-4-8 and claude-sonnet-4-6. The same API path works fine from a headless claude -p call.

Environment

  • Claude Code version: 2.1.156
  • Node.js: v25.8.1
  • OS: macOS Darwin 25.3.0, arm64 (Apple Silicon)
  • Model(s) tested: claude-opus-4-8, claude-sonnet-4-6
  • Context size: ~77k tokens (well under 1M limit)

Behaviour

  • Interactive turns hang intermittently — sometimes for tens of seconds, sometimes until the user interrupts
  • Occurs on both claude-opus-4-8 (newly rolled out) and claude-sonnet-4-6, ruling out a single-model issue
  • Occurs in fresh sessions as well as long ones, ruling out context size
  • Starting a new session does not resolve it
  • The hang looks like waiting for first token (no output at all), not a slow stream

What works fine

Headless claude -p "reply OK" call in the same terminal:

  • Opus 4.8: 200 in 1542ms, zero retries
  • No overload, no 429/529 in debug logs
  • Rate limits barely touched: 49/50 requests, 486k/500k input tokens remaining

Suspected cause

The interactive session sends a much larger set of beta headers than headless:

claude-code-20250219, context-1m-2025-08-07, interleaved-thinking-2025-05-14,
thinking-token-count-2026-05-13, context-management-2025-06-27,
prompt-caching-scope-2026-01-05, mid-conversation-system-2026-04-07,
advisor-tool-2026-03-01, advanced-tool-use-2025-11-24, effort-2025-11-24,
cache-diagnosis-2026-04-07

Headless uses a much smaller set. One of these beta flags may be triggering a slow/stalled server-side code path intermittently.

Debug output (working headless call for reference)

[log_ad9e50, request-id: "req_011CbVeji1QK5bZFDKXM3FsK"] post https://api.anthropic.com/v1/messages?beta=true succeeded with status 200 in 1542ms
anthropic-ratelimit-requests-remaining: 49
anthropic-ratelimit-input-tokens-remaining: 486000

Reproduction

  1. Open an interactive Claude Code session (claude in terminal)
  2. Ask any question that triggers an inference turn
  3. Observe: ~50% of turns hang with no output until interrupted
  4. Run claude -p "reply OK" in a separate terminal — returns in ~1.5s

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING