Skip to content

Context window errors and /compact will not run - Claude Code / Codex

Quick fix

Set the correct model_context_window for the model by hand in cc-switch, so a wrong default does not break compaction or cause a 422.

Error output
实际上下文窗口在117.9k就出现了报错且无法/compact
English translation

The actual context window errors at 117.9k and /compact will not run

When switching model or generating a model catalogue, cc-switch falls back to a wrong default context window size (1M or 128000) if none is specified explicitly. Claude Code or Codex then cannot calculate the remaining context correctly, so automatic compaction (/compact) fails, it reports full early, or it sends an oversized context upstream and triggers a 422.

The related issues are all still open, so there is no automatic context window sync fix yet — you have to override the default in the config by hand.

  1. In the cc-switch model config, set the correct model_context_window explicitly for the model you use (272000 for GPT-5.6, for example) to override the wrong fallback default.

    // cc-switch-model-catalog.json
    {
    "models": [
    {
    "id": "gpt-5.6-sol",
    "model_context_window": 272000
    }
    ]
    }
ToolClaude Code, Codex
Version3.16.3 - 3.18.0
PlatformsWindowsmacOS
Why does the context still show 1M after switching model?
A known cc-switch problem: the context window config is not updated automatically after a model switch, so it still calculates against 1M. Set the correct size by hand.
Do all models support automatic compaction?
Not all of them. But if the context window is configured correctly and the model itself supports it, compaction should work — a wrong config breaks it outright.

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.