When an AI coding session starts going sideways — the assistant forgets a decision you made twenty minutes ago, contradicts itself, or starts reintroducing a bug you already fixed — the instinct is to blame the model's intelligence. Usually that's not it. Usually you've run out of context. Understanding this one constraint changes how you work with these tools more than any prompt trick.
The context window is working memory
Everything an AI assistant "knows" during a session — your instructions, the files it's read, the commands it ran and their output, the whole back-and-forth — lives in a single finite space called the context window. Think of it as the model's working memory. It is not a database it can page through; it's a desk, and the desk has an edge. When the desk fills, something has to come off it.
Crucially, the model's underlying training gives it general knowledge (how to write a loop, what a REST API is), but everything specific to your task lives only in the context window. Lose it from the window and, as far as the session is concerned, it never happened.
How sessions fill up
The window fills faster than people expect, because everything counts:
- Long conversations — every message, yours and the model's, stays on the desk.
- Large files it reads — a single big file can eat a big slice of the window.
- Tool output — test runs, logs, search results, directory listings. Verbose command output is a major, underappreciated consumer.
- The model's own lengthy responses.
A session that's been running for an hour on a meaty task can have a window packed with old tool output and stale conversation, leaving less and less room for the thing you actually care about right now.
What happens at the edge
When the window fills, the session doesn't just crash — it compacts. Older context gets summarized down to make room, which is a lossy operation: the gist survives, the details don't. This is why a long session can suddenly "forget" a specific decision or a particular constraint. It didn't get dumber; the sentence where you told it that got compressed into a summary that dropped the specifics. The degradation feels like a loss of intelligence but it's really a loss of memory.
Managing the window like the resource it is
Once you see context as a scarce resource, a handful of practices follow naturally, and the best AI users do them almost reflexively:
Keep sessions focused. One task per session. When you switch to something unrelated, start fresh rather than dragging an hour of irrelevant context along. A clean window is a sharp assistant.
Put durable facts in a memory file. Anything the assistant needs to know every time — your conventions, your architecture, your commands — belongs in a persistent project instructions file that gets loaded fresh each session, not re-explained into a window that will eventually compact it away. Standing rules should live outside the conversation.
Offload the noisy work to subagents. The single biggest context saver: delegate high-output tasks — searching the whole codebase, reading forty files, running a big test suite — to a subagent. The subagent burns through all that noise in its window and hands back only a short summary. Your main window stays clean, holding the summary instead of the fifty files that produced it.
Don't dump what you don't need. Resist pasting an enormous log or an entire large file when a relevant slice would do. Every token you put on the desk is a token of room you don't have for something else.
The mental model
The reframe is simple but it sticks: the assistant's effective intelligence in a session is bounded less by the model and more by how well the right information fits in its window at the moment it's reasoning. A weaker model with a clean, well-curated context often outperforms a stronger one drowning in an hour of stale logs.
So the highest-leverage skill isn't writing clever prompts. It's context management — deciding what deserves a place on the desk, keeping the clutter off, and knowing when to sweep it clean and start over. Treat the window as the constraint it actually is, and a lot of "the AI got confused" problems simply stop happening.