glimfly
ai updated

What is a context window? Why your AI forgets what you were doing

In one sentence:A context window is the fixed amount of conversation and code your AI can actually see at once. Once it's full, older stuff quietly falls off.

What it actually is

A context window is the total amount of text your AI can “hold in view” at once: your messages, its replies, the code files it has read, tool output, all of it. Think of it as a desk. You can spread out a lot of papers, but the desk has an edge. Once you’re out of room, something has to go to make space for the next thing you put down. Once it’s off the desk, the AI can’t see it anymore, even though it wrote it an hour ago.

That capacity is measured in tokens, roughly chunks of a word (Claude models currently work with context windows in the hundreds of thousands of tokens). Every file your agent opens, every past message in the thread, every command output it reads back, all of that eats into the same budget. Nothing is stored “in the AI’s head” between requests; the entire window gets sent again each time, and it can only be so big.

Why your AI just did this

Your agent isn’t being careless when it reintroduces a variable you already defined, or asks where a function lives that it wrote three prompts ago. It can’t see that part of the conversation anymore. As a project grows, the agent has been reading more files, running more commands, and producing more output, all of which competes for the same fixed space. When the window fills up, older parts of the conversation get dropped or condensed to make room for new ones.

Some tools handle this by “compacting”: summarizing the earlier conversation into a shorter version so the thread can keep going. That summary is lossy by design: exact code, specific variable names, and small decisions from early on can get flattened or lost entirely, even though the general plan survives.

When you’ll run into it

This shows up as very specific, recognizable moments: the agent writes an import statement for a library it already imported ten messages ago, producing a duplicate-declaration or “already defined” error. It reintroduces a function you asked it to delete. It asks a question you answered earlier in the same session. In Claude Code you may see a message about the conversation being compacted or summarized once you’re deep into a long session. That’s the tool trying to survive running out of room. That’s not carelessness or a bug in your code. It’s the window filling up, the same way papers fall off a full desk.

What to check

  • Start a new session for a new feature instead of piling everything into one marathon thread. A fresh session means a full context window again
  • Keep a project notes file (like a CLAUDE.md or README) with the facts that matter (current file structure, key decisions, naming conventions) so the agent can re-read it instead of relying on memory of the conversation
  • Before a long session wraps up or right after a compaction notice, ask the agent to write down what it just built and why, so nothing important is only living in the vanishing part of the thread
  • Break large projects into smaller files and modules. A leaner file is cheaper to re-read in full than a 2,000-line one
  • If your agent starts contradicting earlier decisions or re-adding removed code, treat it as a signal the context window is full, not as random forgetfulness

Say it like a dev

Instead of: “You already know this, why are you asking again?” Say: “We’re deep into this session, so some earlier context may have dropped. Re-read app.py before you continue.”

Instead of: repeating the same instructions every few messages and hoping they stick Say: “Can you add this rule to the project notes file so it survives future sessions?”

Instead of: continuing to pile a huge new feature onto an already long thread Say: “Let’s start a new session for this next feature. This one’s context window is getting full.”

People actually ask

“My project became so big that Claude cannot properly remember, forgetting basic stuff like imports. What's happening?”

The conversation and files you've been working with have filled up the model's context window, so earlier parts (like the import you added a while back) have been dropped or summarized to make room for new ones. It's not losing focus. It can no longer see that part of the exchange. Starting a fresh session or keeping key facts in a project notes file helps.

“Why does my AI forget things we talked about earlier in the same chat?”

Long chats eventually exceed the context window, so the tool has to trim or compact older messages to keep going. Anything specific from early on (exact variable names, small decisions) can get flattened in that process even though the general idea survives.

“Is context window the same as memory?”

No. The context window is temporary and tied to one working session. It resets when you start a new conversation. Persistent memory has to be built deliberately, usually by saving important facts to a file the agent reads back in, like a project notes or CLAUDE.md file.

Related terms

Go deeper

Glim can explain your sessions, live.

The app watches your coding agent and narrates it in plain words. Waitlist is open.

Join the waitlist