[BUG] Interactive CLI fails after tool calls while Desktop Code and claude -p work reliably
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Interactive Claude Code sessions consistently fail immediately after one or more tool calls with:
API Error: An error occurred while processing the request.
The same machine, account, models, and network work correctly in Claude Desktop's Code tab and in headless claude -p mode.
I reproduced this with both Opus 5 and Sonnet 5, with Headroom/Bedrock/custom ANTHROPIC_BASE_URL completely bypassed.
In some cases the interactive CLI fails after only a single Read or Bash tool call.
With normal fallback behavior enabled, the error sometimes appears as:
API Error: API returned an empty or malformed response (HTTP 200)
with diagnostics saying the initial streaming request received 0 stream events and the non-streaming retry unexpectedly received an event-stream.
With CLAUDE_CODE_DISABLE_NONSTREAMING_FALLBACK=1, the misleading fallback error disappears, but the underlying request still fails with Anthropic api_error.
What Should Happen?
After a Read, Bash, Search, MCP, or other tool completes, Claude Code should successfully send the tool result back to the model and continue the interactive turn.
Interactive CLI sessions should behave consistently with Claude Desktop Code and claude -p on the same machine/account.
Error Messages/Logs
Interactive error:
API Error: An error occurred while processing the request.
Debug log from a direct Anthropic/Claude Max session:
2026-08-18T02:34:53.908Z [DEBUG] [API REQUEST] /v1/messages source=repl_main_thread
2026-08-18T02:35:23.910Z [WARN] Slow first byte: no stream chunk 30.0s after request sent (attempt 1)
2026-08-18T02:35:31.237Z [ERROR] Error streaming (non-streaming fallback disabled): {"type":"error","error":{"type":"api_error","message":"An error occurred while processing the request."}}
2026-08-18T02:35:31.238Z [ERROR] Error in API request: {"type":"error","error":{"type":"api_error","message":"An error occurred while processing the request."}}
2026-08-18T02:35:31.266Z [ERROR] [engine] turn ended in error: API Error: An error occurred while processing the request.
Without CLAUDE_CODE_DISABLE_NONSTREAMING_FALLBACK=1 I also received:
API Error: API returned an empty or malformed response (HTTP 200) — check for a proxy or gateway intercepting the request.
Response: content-type event-stream, body is an event stream (the non-streaming request was answered with a stream), request-id req_011Ce9Ykomb88Rn3EhCciHaf, server cloudflare. This was the non-streaming retry of streaming request, which failed with: other; 0 stream events received.
Steps to Reproduce
- On macOS, start a clean Claude Code interactive session directly against Claude Max:
env \
-u ANTHROPIC_BASE_URL \
-u CLAUDE_CODE_USE_BEDROCK \
-u CLAUDE_CODE_USE_MANTLE \
claude --model sonnet
- Ask Claude to perform a coding task that requires reading/searching the local repository.
- Claude successfully performs a Read/Bash/Search tool call.
- The subsequent interactive model request fails with:
API Error: An error occurred while processing the request.
- Repeat with Opus 5. The same failure occurs.
- As a control, run headless Claude Code from the same terminal:
for i in {1..5}; do \
env -u ANTHROPIC_BASE_URL \
-u CLAUDE_CODE_USE_BEDROCK \
-u CLAUDE_CODE_USE_MANTLE \
claude -p "Reply exactly OK" --model sonnet; \
done
- All 5 headless requests return
OK.
- Claude Desktop Code also works normally on the same Mac, account, network, and repository.
I reproduced the interactive failure on both Claude Code 2.1.226 and 2.1.234.
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.234
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
Control tests performed:
- Claude Desktop Code on the same machine/account: WORKS
claude -pheadless mode: 5/5 successful- Interactive Claude Code + Sonnet 5: FAILS
- Interactive Claude Code + Opus 5: FAILS
- Opus 5 standard context: FAILS
- Opus 5 1M context: FAILS
- Claude Code 2.1.226: FAILS
- Claude Code 2.1.234: FAILS
- high and xhigh effort: FAIL
- Headroom/custom ANTHROPIC_BASE_URL completely bypassed: FAILS
- CLAUDE_CODE_DISABLE_NONSTREAMING_FALLBACK=1: removes the malformed HTTP 200 fallback error, but the underlying Anthropic api_error remains
This appears specific to the interactive CLI continuation after tool results rather than general connectivity or model availability.
Possibly related to existing reports involving interactive streaming stalls / slow first-byte behavior, but this report adds a reproducible comparison where Desktop Code and headless claude -p work reliably on the same machine while interactive CLI fails.