API Request Size Exceeds Context Window Limit

Status Closed — not planned
Maintainer reply None cached
Activity 15 comments · opened Aug 22, 2025 · closed Jan 4, 2026

Bug Description
Getting LOTS of API Error 413 errors around request size exceeding model context windows.

Environment Info

  • Platform: darwin
  • Terminal: Apple_Terminal
  • Version: 1.0.86
  • Feedback ID: 1b1ebf10-8583-4dcf-84e3-2432ff630322

Errors

[{"error":"Error: Language not supported while highlighting code, falling back to markdown: \n    at NX (file:///Users/dew/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1761:1184)\n    at file:///Users/dew/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1761:912\n    at Array.map (<anonymous>)\n    at IW (file:///Users/dew/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1761:903)\n    at kgB (file:///Users/dew/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:3053:9071)\n    at gR (file:///Users/dew/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:330:19859)\n    at Qf (file:///Users/dew/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:332:42835)\n    at Af (file:///Users/dew/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:332:38356)\n    at Pj (file:///Users/dew/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:332:38284)\n    at DO (file:///Users/dew/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:332:38138)","timestamp":"2025-08-22T04:22:20.203Z"},{"error":"Error: Language not supported while highlighting code, falling back to markdown: \n    at NX (file:///Users/dew/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1761:1184)\n    at file:///Users/dew/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1761:912\n    at Array.map (<anonymous>)\n    at IW (file:///Users/dew/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1761:903)\n    at kgB (file:///Users/dew/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:3053:9071)\n    at gR (file:///Users/dew/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:330:19859)\n    at Qf (file:///Users/dew/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:332:42835)\n    at Af (file:///Users/dew/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:332:38356)\n    at Pj (file:///Users/dew/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:332:38284)\n    at DO (file:///Users/dew/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:332:38138)","timestamp":"2025-08-22T04:22:20.214Z"},{"error":"Error: Language not supported while highlighting code, falling back to markdown: \n    at NX (file:///Users/dew/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1761:1184)\n    at file:///Users/dew/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1761:912\n    at Array.map (<anonymous>)\n    at IW (file:///Users/dew/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1761:903)\n    at kgB (file:///Users/dew/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:3053:9071)\n    at gR (file:///Users/dew/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:330:19859)\n    at Qf (file:///Users/dew/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:332:42835)\n    at Af (file:///Users/dew/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:332:38356)\n    at Pj (file:///Users/dew/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:332:38284)\n    at DO (file:///Users/dew/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:332:38138)","timestamp":"2025-08-22T04:22:20.260Z"},{"error":"Error: Language not supported while highlighting code, falling back to markdown: \n    at NX (file:///Users/dew/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1761:1184)\n    at file:///Users/dew/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1761:912\n    at Array.map (<anonymous>)\n    at IW (file:///Users/dew/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1761:903)\n    at kgB (file:///Users/dew/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:3053:9071)\n    at gR (file:///Users/dew/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:330:19859)\n    at Qf (file:///Users/dew/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:332:42835)\n    at Af (file:///Users/dew/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:332:38356)\n    at Pj (file:///Users/dew/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-

Note: Error logs were truncated.

View original on GitHub ↗

15 Comments

github-actions[bot] · 1 year ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/6357
  2. https://github.com/anthropics/claude-code/issues/6362
  3. https://github.com/anthropics/claude-code/issues/6364

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

msassa · 1 year ago

I have this problem too!
API Error: 413 {"type":"error","error":{"type":"invalid_request_error","message":"Request size exceeds model context
window"},"request_id":"req_011CSsPS2svAdeZmQyMi3Css7pJPX"}

sahildhankhad · 1 year ago

Same here, I'm also getting the same error since updated to the newer version. Tried a couple of things to solve this but always ended up with this error.

danielraffel · 1 year ago

absolutely unusable

andrewvink · 1 year ago

Also getting a lot of these now - you can /compact manually and then carry on but its really annoying

API Error: 413 {"type":"error","error":{"type":"invalid_request_error","message":"Request size exceeds model context
window"},"request_id":"req_011CSPWAmhJTdqpqxCEJ31mD"}

t-e-lawrence · 1 year ago

same here. even running /compact doesn't do anything:

/compact
⎿ Error: Error during compaction: Error: API Error: 413
{"type":"error","error":{"type":"invalid_request_error","message":"Request size
exceeds model context window"},"request_id":"req_011CSPX46bGYvf1fxDs61SR5"}

looks like the cutoff is 10% cca

/context
⎿  ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁
⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁
⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ Context Usage
⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ claude-opus-4-1-20250805 • 131k/200k tokens (65%)
⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁
⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ System prompt: 2.8k tokens (1.4%)
⛁ ⛁ ⛁ ⛁ ⛁ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ System tools: 11.5k tokens (5.7%)
⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ Messages: 116.6k tokens (58.3%)
⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ Free space: 69.1k (34.6%)
⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶

Context left until auto-compact: 10%

t-e-lawrence · 1 year ago

QUICK tip/workaround:
run /export and export your current chat into a file, then using @ make claude read it in a new convo and get all the context back hopefully

lior-balabite · 1 year ago

I switched the /model to sonnet only and it works

lukebelz · 1 year ago

getting the same... Just started a few hours ago. Compact works to some degree. But comes back quickly.

ANogin · 1 year ago
same here. even running /compact doesn't do anything: /compact ⎿ Error: Error during compaction: Error: API Error: 413 {"type":"error","error":{"type":"invalid_request_error","message":"Request size exceeds model context window"},"request_id":"req_011CSPX46bGYvf1fxDs61SR5"} looks like the cutoff is 10% cca /context ⎿  ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ Context Usage ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ claude-opus-4-1-20250805 • 131k/200k tokens (65%) ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ System prompt: 2.8k tokens (1.4%) ⛁ ⛁ ⛁ ⛁ ⛁ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ System tools: 11.5k tokens (5.7%) ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ Messages: 116.6k tokens (58.3%) ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ Free space: 69.1k (34.6%) ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ Context left until auto-compact: 10%

Just hit it with "Context left until auto-compact: 11%" :(. But then I quit claude, restarted it with -r, and /compact worked!!!

intenex · 1 year ago

Did the context window for Opus change recently to induce this behavior? It sounds like there's a change in the underlying context limit for Opus that Claude Code isn't picking up on that's causing it not to trigger auto-compact when necessary?

danielraffel · 1 year ago

the only reliable solution I've found is to switch models to sonnet for now. this seems to be opus model specific.

github-actions[bot] · 8 months ago

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

github-actions[bot] · 7 months ago

This issue has been automatically closed due to 60 days of inactivity. If you're still experiencing this issue, please open a new issue with updated information.

github-actions[bot] · 7 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.