Claude Code · tool · fg-0608

Behind a gateway, requests fail with a max_tokens error after upgrading to 2.1.329 because the automatic retry is gone

If you see API error mentioning max_tokens exceeding the model's output limit, the cause and the fix for Claude Code are below, last verified 2026-11-20.

Verified Nov 2026trust 50/100
Symptom
API error mentioning max_tokens exceeding the model's output limitRequests that worked on 2.1.326 through 2.1.328 now fail on a gateway whose model allows fewer output tokens
Cause
Version 2.1.326 added an automatic retry that read the limit from a max_tokens error and resent with it. Version 2.1.329 removed that retry, so the oversized max_tokens value is sent and rejected every time.
Fix
Set CLAUDE_CODE_MAX_OUTPUT_TOKENS to the output token limit of the model behind the gateway.
Apply
export CLAUDE_CODE_MAX_OUTPUT_TOKENS=8192 # use your gateway model's real output limit
Affected
Claude Code 2.1.329 and later, with gateways or custom base URLs whose model accepts fewer output tokens than the default
Sources

Last verified 2026-11-20 · Confirmed by 0 builders

Related traps

Have your agent know this before it fails

$ /plugin marketplace add getfootgun/footgun
$ /plugin install footgun@footgun