Your input exceeds the context window 报错 - Claude Code
Quick fix
当会话上下文过长超出模型限制时报错,需手动压缩上下文或设置自动压缩窗口。
Symptom
Section titled “Symptom”API Error: 422 格式转换错误: Your input exceeds the context window of this model. Please adjust your input and try again.当在 Claude Code 或 Codex 中使用中转站(如接入 gpt5.5 或 sonnet 4.6)时,如果单次会话过长,发送的上下文长度可能会超出目标模型的实际限制,从而触发 422 格式转换错误或 502 错误。这通常是因为上下文溢出导致无法通过路由正常转发。
在报错时,手动提前压缩(compact)当前会话的上下文。
自行设置 auto compact window,让工具在上下文达到一定比例时自动进行压缩。
Affected Versions
Section titled “Affected Versions”ToolClaude Code, Codex
Version3.16.1 - 3.16.2
PlatformsWindowsmacOS
Source Issues
Section titled “Source Issues”本页汇总自 2 个真实 issue
- 为什么上下文窗口显示才 54% 就报超出限制的错误?
- 上下文窗口的百分比可能是根据特定模型(如 sonnet 4.6 的 1M context)计算的,此时 54% 即 540k,可能已经超出了你实际调用的中转站模型或路由配置的上下文限制。
- 使用中转站经常遇到 502 上下文过长错误,只能退出重开吗?
- 不需要退出重开,你可以手动提前压缩上下文,或者配置 auto compact window 来避免会话过长导致任务中断。
Claude Code /context 显示 200K 而非 1M在 Claude Code 里执行 /model claude-opus-4-8[1m] 手动切到带 [1m] 后缀的模型,或把 ~/.claude/settings.json 里的 ANTHROPIC_DEFAULT_OPUS_MODEL 改成 claude-opus-4-8[1m]。Error running remote compact task 报错 - Codex升级 cc-switch 至 v3.12.0 或更高版本,该版本在本地代理中新增了对 Codex `/responses/compact` 路由的转发支持,可解决 404 或 502 报错。Request exceeds the context window原帖未提供可验证的解法;该问题已作为与 catalog 配置及自动压缩相关的重复项关闭。
这是一个非官方社区 wiki,与 cc-switch 作者及项目本身无隶属关系。内容整理自项目公开的 GitHub issues。本站不分发任何软件。