Skip to content

[BUG] Session exits with 'API Error: Out of memory' mid-turn on Bedrock (stop_sequence) #51754

@haulino

Description

@haulino

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

  1. Run a multi-step agentic session with many tool calls accumulating in context
  2. Session builds up significant context (~280KB transcript) over multiple tool-use rounds
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    api:bedrockIssue relates to AWS BedrockbugSomething isn't workinghas reproHas detailed reproduction stepsplatform:macosIssue specifically occurs on macOS

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions