Claude Code Stops Gateway Sessions Failing on Context Length and Honors a Context Cap for Unknown Models
Claude CodeView original changelog
Claude Code 2.1.325 fixes sessions on many third-party gateways and Foundry stopping with a context length error on every turn instead of compacting. CLAUDE_CODE_MAX_CONTEXT_TOKENS now also sets the context window of unrecognized model IDs that start with claude-, such as a gateway's claude-sonnet-latest.
Key Takeaways
- Gateway and Foundry sessions now compact instead of failing every turn.
CLAUDE_CODE_MAX_CONTEXT_TOKENSnow applies to unknownclaude-model IDs.- Example: a gateway's
claude-sonnet-latest. - It builds on the 2.1.323 change assuming a 1M window.
- Users can cap the window when the assumed size is too large.
- The fix removes a hard stop in long sessions.
Context length errors
Sessions on many third-party gateways and Foundry could stop with a context length error on every turn instead of compacting. Claude Code now compacts instead.
Setting the window for unknown models
CLAUDE_CODE_MAX_CONTEXT_TOKENS now also sets the context window of unrecognized model IDs that start with claude-, such as a gateway's claude-sonnet-latest. This builds on the 2.1.323 change that assumes a 1M window for unrecognized model IDs.