[BUG] Claude Code with Bedrock API often hits 4096 max output token limit on moderate complex tasks
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_
This issue has 13 comments on GitHub. Read the full discussion on GitHub ↗