[Bug] Anthropic API not respecting MAX_THINKING_TOKENS limit, exceeds configured threshold
Bug Description
I have these set:
export MAX_THINKING_TOKENS=5120
export CLAUDE_CODE_MAX_OUTPUT_TOKENS=16384
But thinking often uses far more tokens than the MAX_THINKING_TOKENS limit. See below for the proof.
In the error response below, it did not perform any output, only thinking, and the thinking exceeded the 16k token limit when thinking is supposed to be limited to 5K tokens. Clearly the API is not respecting this, but it used to, so I think this is a regression when you started producing the Opus 4.6 changes. I have not had a problem with this until about one or two weeks ago.
It just started happening; I think the problem is on your API side because I've been running the same version of Claude Code for months and haven't had this problem until recently.
Questions for Anthropic that I cannot answer:
- Did Anthropic's API backend stop respecting the
budget_tokensAPI flag? - Is this a model-specific problem, or is it systemic?
- Did you change the name or the structure such that my old version of Claude Code is not sending the correct API request for budget token handling?
"thinking": {
"type": "enabled",
"budget_tokens": 5120 // <<< ??
},
Here's the error that proves that while thinking it's capable of thinking beyond the max thinking tokens setting; This is true because in the example it never produced any output besides thinking. The response just got stuck spinning forever on whatever it was thinking about, and then it did this:
⎿ API Error: Claude's response exceeded the 16384 output token maximum. To configure this behavior, set the
CLAUDE_CODE_MAX_OUTPUT_TOKENS environment variable.
It tells me to set the environment variable which it is, and it is respecting the max token output for the environment variable, but it is definitely not respecting the max thinking tokens limit.
Environment Info
- Platform: linux
- Terminal: vte-based
- Version: 2.0.69
- Feedback ID: fbb43c1d-a5dc-49bf-9f8a-5d0fed55f19d
Errors
⎿ API Error: Claude's response exceeded the 16384 output token maximum. To configure this behavior, set the
CLAUDE_CODE_MAX_OUTPUT_TOKENS environment variable.This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗