Your input exceeds the context window error - Claude Code
Quick fix
The session context is too long for the model limit. Compact the context by hand or set an auto compact window.
Symptom
Section titled “Symptom”API Error: 422 格式转换错误: Your input exceeds the context window of this model. Please adjust your input and try again.API Error: 422 format conversion error: Your input exceeds the context window of this model. Please adjust your input and try again.
Using a relay in Claude Code or Codex (connecting gpt5.5 or sonnet 4.6, for instance), a single long session can send a context longer than the real limit of the target model, triggering a 422 format conversion error or a 502. It usually means the context overflowed and could not be forwarded through the routing normally.
When the error appears, compact the context of the current session by hand, ahead of time.
Set an auto compact window yourself so the tool compacts automatically once the context reaches a given proportion.
Affected Versions
Section titled “Affected Versions”Source Issues
Section titled “Source Issues”This page is distilled from 2 real issues
- Why does it report exceeding the limit when the context window shows only 54%?
- The context window percentage may be calculated against a particular model (the 1M context of sonnet 4.6, for instance), where 54% is 540k — already beyond the context limit of the relay model or routing configuration you actually call.
- I keep hitting 502 context-too-long errors on a relay. Is quitting and reopening the only option?
- No need to quit and reopen. You can compact the context by hand ahead of time, or configure an auto compact window to keep a long session from interrupting the task.
Related problems
Section titled “Related problems”This is an unofficial community wiki with no affiliation to the cc-switch authors or the project itself. Its content is compiled from the project's public GitHub issues. This site distributes no software.