Skip to content

HTTP 400 context length exceeded, Codex

Quick fix

Upgrade to cc-switch 4.0. If the issue still recurs, provide the version and reproduction steps, then report it again.

Error output
CC Switch local proxy failed while handling Codex endpoint /responses. Provider: DeepSeek; model: deepseek-v4-pro; upstream_status: HTTP 400; cause: This model's maximum context length is 1048565 tokens. However, you requested 2786093 tokens (2786093 in the messages, 0 in the completion). Please reduce the length of the messages or completion.

When Codex connects to DeepSeek through the local route, a request may exceed the model's context limit, causing the upstream to return HTTP 400. Issue comments say that cc-switch did not correctly set `model_catalog_json` when generating Codex configuration, so Codex could not determine when to trigger context compaction. The comments mention PR #5534, which changes `auto_compact_token_limit` and `truncation_policy.limit` to be generated dynamically from the user-provided `contextWindow`. One user believed this PR had resolved their issue, but there is no evidence that it has been released or resolved all reports. A similar issue was also reported with GLM-5.1 through cc-switch connecting to Claude Code. The maintainer said v4.0 made substantial changes to configuration switching and the interface, and that many related issues no longer occur. They recommended upgrading and reporting again if the issue persists.

  1. Upgrade to cc-switch 4.0. The maintainer said many related issues no longer occur in this version. If the issue still recurs after upgrading, provide the version and reproduction steps, then reopen the issue or report it again.

  2. If you are using an earlier version, check whether Codex's `model_catalog_json` explicitly configures the context window and automatic compaction threshold. Issue comments mention that PR #5534 makes `auto_compact_token_limit` and `truncation_policy.limit` follow `contextWindow` dynamically, but do not confirm that this change is included in your version.

ToolCodex
Version3.16.1 - 3.16.3(报告版本;维护者建议升级到 4.0)
PlatformsmacOS
Is this issue more likely to occur when submitting images?
One user said it seemed easier to reproduce with images, while another said they encountered it without submitting images. A comment also noted that DeepSeek v4.0 does not support vision and recommended trying another model for image-related tasks.
What should I do if the error persists after upgrading to 4.0?
The maintainer recommended providing the version in use and reproduction steps, then reopening the issue or reporting it again.

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.