Copilot “prompt token count exceeds the limit of 128000”: fix
Sorry, your request failed. CAPIError: 400 prompt token count of 153269 exceeds the limit of 128000
Your chat's prompt is larger than the cap Copilot's API sets for that model (often 128,000 tokens, sometimes below the model's own window), after history, attached files, tool output and tool definitions add up. Start a new chat or run /compact, attach less and trim terminal output. It is a size limit on one request, so waiting won't help.
What causes it
- Copilot enforces a per-model prompt cap (error code
model_max_prompt_tokens_exceeded) that can be lower than the model's native context window. - Agent mode keeps adding to the prompt: earlier turns, large files, terminal and log output, and the definitions of every enabled MCP tool.
- Client bugs: the cloud agent was stuck at a 128K cap on every model (microsoft/vscode issue #293419), and large terminal output got pulled into context (issue #331786).
- Other clients that sign in with Copilot (Zed, OpenCode, Goose) may not know the real cap and send too much; Zed users have hit “exceeds the limit of 72000”.
How to fix it
- Start a new chat, or run
/compactto summarize the conversation and free context. - Keep
github.copilot.chat.summarizeAgentConversationHistory.enabledswitched on (it is the default) so long agent sessions get summarized. - Attach fewer files, paste only the relevant part of logs and terminal output, and disable MCP tools you don't use in this chat.
- Pick a model with a bigger window: the 1M-token context option for supported models in VS Code and Copilot CLI, which uses more AI credits.
- In third-party clients, set the model's context limit to Copilot's cap so the client compacts before it sends too much.
Running an agent? Every tool result in agent mode re-enters the prompt, so a session that reads a few big files and runs a test suite can cross 128,000 tokens long before the conversation feels long.
Sources: microsoft/vscode issue #288204; microsoft/vscode issue #293419; zed issue #51443; GitHub Docs: supported models; VS Code: Copilot settings
Keep working on a fixed monthly plan
If your agent work keeps outgrowing Copilot's cap, run Cline, Roo Code or Kilo Code in the same VS Code window on Standard Compute (base URL https://api.stdcmpt.com/v1) and pin a model from the catalog, so the limit is that model's own context window. Plans cost a fixed $19 to $249 a month for a set compute budget, with no 5-hour or weekly windows. Each key gets 300 to 2,000 requests a minute by plan, and at 100% of the budget new requests return HTTP 402 until renewal, with no overage charge.
Plans from $19 a month with $20 of compute. Eligible new accounts can try $0.25 of compute first, no card. Trial terms
FAQ
Why is the limit 128,000 when the model supports more?
Copilot sets its own maximum prompt size per model, and the default context in the model picker is often 128K. The 1M-token option, where offered, raises it at a higher credit cost.
Will it go away if I wait?
No. The 400 is about the size of the prompt as sent, so it repeats until the prompt is smaller or the model's window is larger.