[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
- Ask Claude to perform any medium complex task, like - refactor this Python FastAPI codebase while using Bedrock API
- Claude will attempt understanding context, then the output tokens start coming through.
- 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_
13 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
I am hitting the same issue too. I am on 2.0.24 and there is no easy way to bypass that.
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.
Same here. But even breaking the tasks sometimes still fail.
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" />
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.
Issue still occurs.
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.
Happens to me also.
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.
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.
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...
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.