Part 2 of 7 · Chapter 1 of 4

What the AI Can and Can't See

Context windows, what actually gets sent with your prompt, and why the model confidently invents functions you never wrote.

Beginner12 min read

Almost every frustrating moment with an AI coding tool traces back to one thing: it answered using less information than you assumed it had. This chapter is about what actually reaches the model, so that its mistakes stop being mysterious.

The model has no memory

Start here, because it explains most of the rest. A language model does not remember your last conversation. It does not remember your project between sessions. Every single time you press enter, the tool assembles a package of text and sends the whole thing — and that package is the entire world as far as the model is concerned.

That package usually contains:

  1. 1
    A system prompt

    Instructions from the tool vendor you never see.

  2. 2
    Your rules file

    AGENTS.md, CLAUDE.md, or .cursorrules, if one exists.

  3. 3
    Some of your code

    The open file, files you referenced, and whatever the tool's search decided was relevant.

  4. 4
    The conversation so far

    Earlier messages in this session, until they get too long and start being dropped.

  5. 5
    Your actual prompt

    The smallest part, and the only one you fully control.

When the model “forgets” something you said twenty minutes ago, nothing mystical happened. That text stopped being included in the package.

The context window is a budget

There is a hard ceiling on how much text can go in that package, measured in tokens — roughly ¾ of a word each, so 1,000 tokens is about 750 words. Modern models take a lot: hundreds of thousands of tokens. That sounds limitless until you notice a mid-sized codebase is millions.

So the tool is constantly choosing what to include and what to leave out. It is usually good at this. It is never perfect. And critically: it will not tell you what it left out.

Why it invents functions you never wrote

This is the behaviour people find most alarming, and it has a mundane explanation. The model predicts plausible text. When it cannot see your actual formatDatehelper, it does not think “I lack information.” It thinks “what would a formatDate helper look like in a project like this?” — and writes that.

The output is confident because plausible text is confident text. There is no internal signal that distinguishes “I read this” from “I inferred this.”

What it feels like

The AI lied to you, or is broken, or is not as capable as advertised.

What actually happened

It filled a gap in what it could see with the most likely thing. Give it the file and the invention stops.

Test what it can see

Rather than guessing, ask. This costs one message and tells you more about your setup than any amount of theory:

Prompt
Before answering anything else: list the files you can currentlysee in this project, and tell me which parts of my codebase youcannot see. Do not guess — if you are unsure, say so.

Run this in each tool you use. A repo-aware agent lists real files. An autocomplete extension names your open file and little else. A browser chat says it sees nothing but what you pasted. All three answers are correct, and knowing which one you are holding changes how you prompt.

Working with the limit instead of against it

  1. 1

    Reference files explicitly

    Do not make the tool guess which of your 200 files matters. Naming two files is faster than any search it can run.

  2. 2

    Start fresh when the thread wanders

    A new conversation with a good opening prompt beats a long one that has drifted. You are not losing progress — the code is on disk.

  3. 3

    Put durable facts in a rules file

    Anything you find yourself repeating every session belongs somewhere the tool loads automatically.

    That is Chapter 15, and it is the highest-payoff thing in this part of the course.

  4. 4

    Paste errors in full

    Your summary of an error drops the stack frame that identified the file. The raw text costs you nothing.

Key takeaways

  • The model has no memory. Every request ships a fresh package of text, and that package is its whole world.
  • The context window is a budget, and the tool silently decides what to drop.
  • Hallucinated functions are gap-filling, not dishonesty. Show it the real file and they stop.
  • Ask a tool what it can see. The answer is often narrower than you assumed.
  • A long, drifting conversation is worse than a fresh one with a good opening prompt.