Context Windows for Coding Agents, Explained
Published September 24, 2026 · by the AQ team
A context window is the maximum number of tokens a model can read and write in a single request: your instructions, every file the agent has opened, every command output, and the model's own replies all have to fit inside it. For coding agents like Claude Code, Codex, and Cursor, the context window is the session's working memory, and it fills far faster than chat, because tool output (file contents, diffs, test logs) lands in it alongside what you typed. As of September 2026 the models these agents run advertise windows from 200K to 2 million tokens, but two facts matter more than the headline number: the harness often runs the model at a smaller effective window than the API advertises, and output quality degrades well before any window is full.
What fills a coding agent's context window
A token is the unit models read text in, roughly three to four characters of code. Your own messages are usually the smallest item in the window. The rest is machinery:
- The system prompt and tool definitions. The harness's own instructions plus a schema for every tool. MCP servers add their definitions on top; Cursor's January 2026 dynamic context discovery research reported that loading MCP tools selectively instead of all at once cut token usage by 46.9 percent.
- Memory and instruction files. CLAUDE.md, AGENTS.md, rules files, and loaded skills ride along on every turn.
- Tool output. Every file read, every grep result, every build log, every failing test trace. This is the bulk of a real session.
- The conversation itself. Prior turns accumulate, and each new request resends everything so far, which is also why long sessions cost disproportionately more; coding agent token costs for teams works through that math.
Why long sessions degrade before the window is full
Context rot is the measured decline in model output quality as input context grows, and it starts long before the window limit. Chroma's context rot study (published July 2025) tested 18 frontier models, including GPT-4.1, Claude Opus 4, and Gemini 2.5, and found every one performed worse as input length grew, even when the window was nowhere near full. Two mechanisms compound in coding sessions. Models attend most reliably to the beginning and end of context and least to the middle (the lost in the middle effect), which is where a long session buries the constraint you stated at the start. And distractors accumulate: even one near-miss passage in context measurably reduced accuracy in the study, and a coding session generates near-misses constantly, in the form of stale file versions, abandoned approaches, and error output from paths already left behind.
In practice this shows up as an agent that re-reads files it already saw, forgets an instruction from an hour ago, or confidently edits a version of a function that no longer exists. That is not a broken model; it is a full, noisy window.
What compaction actually does in Claude Code, Codex, and Cursor
Compaction (some vendors say summarization) replaces the transcript with a model-written summary, freeing the window so the session can continue. It is lossy by design: the summary keeps what the summarizer judged important, and everything else is gone. As of September 2026, per each vendor's own documentation:
- Claude Code compacts automatically as the conversation nears the window limit, replacing older messages with a summary. The /compact command compacts on demand and takes instructions (for example, /compact focus on the auth bug), the /rewind menu can summarize from or up to a chosen message, and the threshold at which the automatic pass fires is configurable in settings or via an environment variable.
- Codex CLI compacts once tokens cross a threshold, producing a handoff summary that frames the next turn; a /compact command triggers it manually. Notably, Codex runs the GPT-5.6 family at a 272K effective window even though the models advertise 1M at the API level: OpenAI's own harness chose a smaller, denser window over a bigger, noisier one.
- Cursor summarizes older messages when the window fills, and its documentation is candid that the agent's knowledge can degrade after summarization. Its mitigation is writing the chat history to files the agent can search afterward: when the summary lacks a detail, the agent greps its own past instead of guessing. Long tool outputs are converted to files rather than held in the window.
Memory files are the other half of the story, and they are not session memory. CLAUDE.md and AGENTS.md are standing instructions loaded fresh into every session: conventions, build commands, review rules. They persist because they live outside the window, in the repository. What they do not hold is anything the agent learned mid-session; that lives only in the transcript, survives compaction only if the summary kept it, and dies with the session. Durable rules go in memory files; anything a future session will need gets written to a file or a commit, not left in conversation.
Context windows of the models coding agents run (September 2026)
Advertised windows, verified on each vendor's documentation as of September 2026; where the harness uses a different number, the notes say so.
| Model | Vendor | Context window | Notes (as of September 2026) |
|---|---|---|---|
| Claude Opus 5.5 / Sonnet 5 | Anthropic | 1M tokens | 1M is the default at standard pricing; 128K max output. Haiku 4.5 has 200K. |
| GPT-6 Astra | OpenAI | 1.05M tokens | Released September 3, 2026; the bundled Codex CLI default; 128K max output. |
| GPT-5.6 (Sol, Terra, Luna) | OpenAI | 1M tokens (API) | Codex CLI runs the family at a 272K effective window by default. |
| Gemini 3.5 Pro | 2M tokens | Generally available since late June 2026; the largest production window. | |
| Grok 4.7 | xAI | 500K tokens | Per-token pricing steps up above 200K prompt tokens. |
| Kimi K2.7 Code | Moonshot AI | 256K tokens | 262,144 tokens; the coding-tuned release of the K2 line. |
| DeepSeek V4 Pro | DeepSeek | 1M tokens | Up to 384K output tokens; MIT-licensed open weights. |
| GLM-5.3 | Z.ai | 1M tokens | Released August 14, 2026; 128K max output. |
| MiMo-V2.6-Pro | Xiaomi | 1M tokens | Released September 22, 2026; omnimodal input; MIT-licensed weights. |
Read the table with the Codex row in mind: OpenAI deliberately caps a million-token model at roughly a quarter of its window inside its own harness, Claude Code's auto-compaction fires well before the limit, and Grok's pricing step above 200K prompt tokens makes the economics explicit. The harness treats the advertised window as a ceiling to stay under, not a budget to spend.
The operating habits that follow
If quality decays with context length and compaction is lossy, the goal is not a bigger window. It is keeping each window small, clean, and on one subject:
- One task per session. Finish the bug fix, land it, and start the refactor in a fresh session with a clean attention pattern; carrying it into the bug fix's leftover context imports every one of its distractors.
- A fresh session in a fresh worktree per task. Session isolation and file isolation solve the same problem at two layers. Git worktrees for AI coding agents covers the file layer: each task gets its own checkout and branch, so parallel work never collides.
- Parallel sessions instead of one long one. Three agents on three scoped tasks in three worktrees beat one agent grinding through a nine-hour transcript. Running multiple Claude Code sessions in parallel shows the mechanics.
- Compact deliberately, at boundaries. A /compact with instructions after a milestone keeps what you choose; an auto-compact firing mid-task keeps what the summarizer guessed.
- Keep standing context lean. Memory files, MCP servers, and skills ride in every window. Prune the servers you do not use and keep CLAUDE.md to rules the agent actually needs.
- Externalize state the next session will need. A plan file, a progress note, a commit message. Files survive compaction; transcripts do not.
Where AQ fits
AQ is the multiplayer coding harness where engineering teams run AI coding agents like Claude Code and Codex together: shared live terminals, a code editor, and app previews, in your own cloud. The habits above are AQ's workspace model. Each workspace is one task in its own isolated git worktree (branch ai/{id}-{slug}, dependencies installed automatically, one-click rebase onto main), so a fresh session per task in a fresh checkout is the default rather than a discipline, and running several scoped sessions in parallel is just opening several workspaces. The agents are the real CLIs (Claude Code, Codex, Cursor Agent, Kimi, Grok, or plain shells) in persistent tmux sessions on your team's VM, streamed live to the browser, so a long run survives a closed laptop and resumes from any device, and teammates can open the same workspace and watch the same live session. Everyone logs into the CLIs with their own Claude or OpenAI account, and AQ never marks up usage on your own subscriptions.
Pricing is two plans: Free is a personal sandbox for one person (AQ creates a private machine in an isolated network, nothing to install, no time limit), and Team is $50 per user per month early access (standard $200, billed monthly), covering VMs you connect from your own cloud or a dedicated always-on AQ-managed VM, with your rate locked for your first 12 months.
Frequently asked questions
How do I check how much context my coding agent session has used?
Claude Code shows remaining context in its status area and the /autocompact command reports the active window; Codex CLI displays the percentage of context left in its interface; Cursor surfaces context usage in the chat panel. As of September 2026 all three compact automatically near the limit, so the number to watch is not distance from zero but whether you are approaching a compaction you would rather run yourself, with instructions, at a task boundary.
Does a bigger context window make a coding agent better?
Not by itself. Chroma's 2025 context rot study found every one of the 18 frontier models tested got worse as input grew, even far from the window limit, and OpenAI's own Codex CLI runs the million-token GPT-5.6 family at a 272K effective window as of September 2026. A larger window raises the ceiling for genuinely long inputs (a big log, a wide refactor), but a small, clean context beats a large, noisy one on most coding tasks.
What is context rot?
Context rot is the measured decline in LLM output quality as input context grows longer. Chroma's July 2025 study documented it across 18 frontier models: accuracy fell as input length rose at every increment tested, with the middle of the context attended to worst and even single misleading passages reducing accuracy. In coding sessions it appears as forgotten instructions, re-read files, and edits against stale versions of code.
Should I turn off auto-compaction in Claude Code or Codex?
Usually no: without it the session simply dies at the window limit. The better move is to make auto-compaction rare by keeping sessions scoped to one task, and to compact deliberately at milestones with /compact and instructions about what to keep. Both Claude Code and Codex CLI expose the command; Claude Code also lets you tune the threshold at which the automatic pass fires.
Is a 1 million token context window enough to load my whole repository?
Often yes mechanically, and usually no practically. A million tokens holds roughly 3 to 4 million characters of code, so mid-size repositories fit. But loading everything maximizes context rot and cost on every turn: you pay to resend the whole window per request, and accuracy degrades as it fills. Agents work better retrieving the files a task needs (search, then read) than starting with the repository preloaded, which is how the harnesses themselves behave.