Codex cli 0.8 – 0.9Model / API
Codex: context_length_exceeded (max 200000 tokens)
BadRequestError: context_length_exceeded — requested 214530 tokens, max 200000
- Affected versions
- cli 0.8 – 0.9
- Fixed in
- —
- Last verified
- Codex CLI 0.9
Root cause
Codex packs too much repo context (large files, node_modules, generated output) into a single request, exceeding the model window.
How to reproduce
Ask Codex to refactor across a large monorepo; it attaches many files and the API rejects the request.
Solutions (2)
Ordered by community votes. Always check the verified version before applying.
63
#1Applies to cli 0.9
Add a `.codexignore` (or use the ignore setting) to exclude node_modules, dist, build and large lockfiles so they are never sent as context.
Last verified: Codex CLI 0.9 · community
38
#2Applies to cli 0.8 – 0.9
Scope the task to specific files/dirs and split large refactors into smaller steps instead of whole-repo prompts.
Last verified: Codex CLI 0.9 · community