Description
Claude Code session terminates unexpectedly mid-turn with stop_sequence and the final content entry in the transcript reads API Error: Out of memory. No error is surfaced to the user in the UI — the session just exits.
Steps to Reproduce
- Run a multi-step agentic session with many tool calls accumulating in context
- Session builds up significant context (~280KB transcript) over multiple tool-use rounds
- At some point mid-turn, the session exits with
stop_sequence / API Error: Out of memory
Expected Behavior
Session should surface an error to the user (e.g., "context too large" or "out of memory") and ideally offer to compact/summarize before retrying rather than silently exiting.
Actual Behavior
Session exits without any user-facing error message. The only evidence is in the .jsonl transcript file:
"stop_reason": "stop_sequence"
"content": "API Error: Out of memory"
Environment
- Claude Code version: 2.1.116
- Platform: macOS (Darwin 25.4.0)
- Model:
us.anthropic.claude-sonnet-4-6 via AWS Bedrock (us-west-2)
- Provider: AWS Bedrock (CLAUDE_CODE_USE_BEDROCK=1)
Transcript Evidence
- Session ID:
0a80a98a-2efd-473d-8988-80fe42db6e92
- Transcript size at exit: 284KB
- Session duration: Active multi-turn agentic loop with ~15+ tool calls
- Last stop_reason in transcript:
stop_sequence
- Last content in transcript:
API Error: Out of memory
The session was mid-way through an agentic loop (gathering data via multiple Bash tool calls). The exit occurred after accumulating significant context across many turns.
Additional Notes
- A prior session in the same project (
e49fb48f, 1.2MB) had completed normally — the OOM occurred in a subsequent session, not on the largest transcript
- No
Stop hook fired confirming the exit was not a clean/graceful shutdown
- The error appears to originate at the Bedrock API layer, but Claude Code does not handle or surface it gracefully
Description
Claude Code session terminates unexpectedly mid-turn with
stop_sequenceand the final content entry in the transcript readsAPI Error: Out of memory. No error is surfaced to the user in the UI — the session just exits.Steps to Reproduce
stop_sequence/API Error: Out of memoryExpected Behavior
Session should surface an error to the user (e.g., "context too large" or "out of memory") and ideally offer to compact/summarize before retrying rather than silently exiting.
Actual Behavior
Session exits without any user-facing error message. The only evidence is in the
.jsonltranscript file:Environment
us.anthropic.claude-sonnet-4-6via AWS Bedrock (us-west-2)Transcript Evidence
0a80a98a-2efd-473d-8988-80fe42db6e92stop_sequenceAPI Error: Out of memoryThe session was mid-way through an agentic loop (gathering data via multiple Bash tool calls). The exit occurred after accumulating significant context across many turns.
Additional Notes
e49fb48f, 1.2MB) had completed normally — the OOM occurred in a subsequent session, not on the largest transcriptStophook fired confirming the exit was not a clean/graceful shutdown