[BUG] Claude Code with Bedrock API often hits 4096 max output token limit on moderate complex tasks

Status Closed — not planned
Maintainer reply None cached
Activity 13 comments · opened Oct 21, 2025 · closed Jan 17, 2026

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?

Claude Code often hits the Bedrock API's max_token limit and doesn't retry/continue the task, it keeps breaking at "_API Error: Claude's response exceeded the 4096 output token maximum. To configure this behavior, set the CLAUDE_CODE_MAX_OUTPUT_TOKENS environment variable._". This is very evident on moderate to large tasks. The situation doesn't get any better even with multiple sub-agents configured breaking down the task into smaller ones with each agent having it's own context.

What Should Happen?

Claude Code should continue retrying even when it hits the Bedrock API limit without breaking out with the error

Error Messages/Logs

⎿ API Error: Claude's response exceeded the 4096 output token maximum. To configure this behavior, set the CLAUDE_CODE_MAX_OUTPUT_TOKENS environment 
    variable.

Steps to Reproduce

  1. Ask Claude to perform any medium complex task, like - refactor this Python FastAPI codebase while using Bedrock API
  2. Claude will attempt understanding context, then the output tokens start coming through.
  3. Terminal shows the error, although parts of the refactor are completed

Claude Model

Sonnet (default)

Is this a regression?

No, this never worked

Last Working Version

_No response_

Claude Code Version

2.0.24 (Claude Code)

Platform

AWS Bedrock

Operating System

macOS

Terminal/Shell

Warp

Additional Information

_No response_

View original on GitHub ↗

13 Comments

github-actions[bot] · 10 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/7927
  2. https://github.com/anthropics/claude-code/issues/7869
  3. https://github.com/anthropics/claude-code/issues/9365

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

rahanar · 10 months ago

I am hitting the same issue too. I am on 2.0.24 and there is no easy way to bypass that.

david-murray-ugle · 10 months ago

I have the same issue regularly. I will tell Claude to break the task down into smaller pieces of work and achieve it incrementally by maintaining a checklist of subtasks.

That works, but even if I add this to my Claude.md it always results a system halt with no recovery based on my instruction the next time CLAUDE_CODE_MAX_OUTPUT_TOKENS is hit.

jmanteau · 10 months ago

Same here. But even breaking the tasks sometimes still fail.

adrianarandac · 9 months ago

Same here, but after I hit the bug once, doesn't matter if I restart the terminal and run claude again, I hit the maximum output limit instantly:

<img width="1154" height="79" alt="Image" src="https://github.com/user-attachments/assets/b2581b15-5980-4e08-919b-6a634e0b7986" />

github-actions[bot] · 8 months ago

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

npikepltsci · 8 months ago

Issue still occurs.

jacoboreilly · 8 months ago

I'm still getting this on 2.0.51 (MacOS)

I should add that this is getting fairly frustrating, having to keep nudging Claude to try again, work iteratively, etc.

technotronic12 · 8 months ago

Happens to me also.

github-actions[bot] · 7 months ago

This issue has been automatically closed due to 60 days of inactivity. If you're still experiencing this issue, please open a new issue with updated information.

marcindulak · 7 months ago

This issue was closed incorrectly despite recent human comments. This behavior of the bot is reported at https://github.com/anthropics/claude-code/issues/16497. Please upvote that issue, so maybe it gets noticed.

JWThewes · 7 months ago

This is near to unusable right now. Is there ANYTHING I can do to get back to this. Seems to be particularly bad with CSS and larger MD files...

github-actions[bot] · 7 months ago

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.