Research

The Repo Is the Only Thing an AI Agent Actually Knows

Field Note

An agent has exactly three sources of information: the prompt it was given, the files it can read, and whatever a tool returns when it runs. It cannot ask a coworker, remember last Tuesday's meeting or check Slack.

That sounds obvious written down, yet almost every team violates it, because most of what a team "knows" lives in people's heads rather than in files. Once that gap is closed, an agent stops guessing.

Short answer

An AI agent has three inputs: its prompt, the repo's files, and tool output. Anything decided in Slack, in a meeting or in someone's head does not exist for it, and state that isn't written down does not survive the next session.

Chalk illustration of a stick figure pulling open a filing cabinet drawer beside a second faded figure whose thought bubble dissolves into scribbles
One figure has a drawer. The other only has a fading thought. Only one of them can hand off the work.

What Exactly Can an AI Agent See When It Works?

An AI agent sees only three inputs: the system and task prompt, the contents of files it can read, and the output of tools it runs. Everything else, including meetings, chat threads and tribal knowledge, is invisible to it unless someone writes it down.

This is easy to say and hard to internalize, because people on a team constantly fill gaps with context nobody wrote down. A senior engineer knows the payments service can't be touched on Fridays because of a settlement job, and that fact lives in her head, which an agent working the same repo has no access to. If the constraint isn't in a file the agent reads, the agent will touch the payments service on a Friday, and that will be the predictable result of a map with a hole in it rather than an isolated mistake. We treat this as a design constraint on every custom AI agent we build: if a rule matters, it goes in a file the agent actually reads before it acts.

What Is the Fresh-Session Test and How Do You Run It?

The fresh-session test checks whether a brand-new session, given only the repo, can answer five questions: what is this system, how is it organized, how do I run it, how do I verify it, and where are we right now. Any question it cannot answer marks a real gap.

The test is deliberately strict. Don't answer the agent's questions yourself or paste in extra context from your own memory; watch what a cold session can work out from the files on disk alone. Five specific questions decide the grade: what is this system, how is it organized, how do I run it, how do I verify it, and where does the work currently stand. Every blank the agent hits is a guess it will make on your behalf, and wrong guesses turn into bugs as well as wasted time. The test also grades human onboarding, since a repo that fails it is usually the same repo where a new hire spends their first two weeks asking questions nobody wrote down.

Why Does an Instructions File Stop Working Once It Gets Long?

Long instruction files get worse past a few hundred lines, because models use text at the start and end of a long context far more reliably than text buried in the middle. A hard rule at line 300 of such a file is easy to miss entirely.

The natural response to every agent mistake is "add a rule to the instructions file." That works the first few times, but once the file hits four or five hundred lines it becomes worse than useless, because the agent gets measurably worse at following it. Liu and colleagues documented the mechanism directly. Testing how language models use long inputs, they found performance is highest when the relevant information sits at the beginning or end of the context and drops off sharply when it is buried in the middle, a pattern that holds even in models built specifically for long context. A security rule at line 300 of a bloated instructions file is therefore a serious risk, since that is statistically likely to be the spot the model pays least attention to. We cover the layer this problem sits inside, and how it interacts with the rest of an agent's context, in our report on context engineering.

Position of relevant information in the contextRetrieval accuracy pattern observed
Beginning of a long inputHigh, models retrieve it reliably
Middle of a long inputSignificantly degraded, even in models designed for long context
End of a long inputHigh, models retrieve it reliably
Source: Liu et al., "Lost in the Middle: How Language Models Use Long Contexts" (2023), arXiv:2307.03172

Make the entry file a router that points elsewhere. Keep it short (a project overview, hard constraints and pointers to topic docs) and let the agent pull detailed docs on demand rather than scrolling past all of them on every task. A well-organized website works the same way: the homepage points to the other pages instead of holding all their content.

Does More Context Actually Mean More Reliable Work?

No. More context and more tool calls raise cost fast without a matching reliability gain unless the extra information is relevant. Anthropic's own multi-agent research system uses roughly fifteen times the tokens of a single chat turn to earn its performance gain, and that ratio is a deliberate design choice.

It is tempting to assume that giving an agent more information is always safer than giving it less. Anthropic's writeup of their multi-agent research system is a useful check on that, because they measured the tradeoff directly instead of assuming it. A single agent uses roughly four times the tokens of a normal chat exchange, and a multi-agent system, where separate agents each carry their own context window, uses roughly fifteen times as many. In their case the extra cost bought a real performance gain, with a multi-agent architecture outperforming a single agent by over 90% on their internal evaluation. But they were explicit that token usage alone explained about 80% of the variance in outcome, meaning most of what mattered was whether the agent had access to the right information, structured well, rather than just more of it stacked on top.

System architectureToken usage relative to a single chat turn
Single chat exchange1x baseline
Single agent using tools~4x
Multi-agent system, separate context windows~15x
Source: Anthropic, "How We Built Our Multi-Agent Research System", anthropic.com/engineering/multi-agent-research-system
Information that is not in the repo does not exist for the agent, so what matters is whether you drew a good enough map to the context you have.
Chalk illustration of a stick figure reading a long unrolled scroll with bold text at the top and bottom and a blurry smudged gap in the middle
Recall is clear at the start and end of a long context and blurs in the middle, where the hard constraint always seems to land.

What Does a Repo That Passes the Fresh-Session Test Actually Look Like?

A repo that passes has a short entry file with hard constraints and pointers, topic docs next to the code they describe, a progress file updated every session, and a decisions file recording what was chosen and why. Nothing important lives only in a person's memory.

In practice this is four ordinary kinds of file working together. A short entry file at the root carries the overview, the run commands and the non-negotiable constraints. Topic docs sit next to the code they govern instead of in a wiki nobody updates. A progress file, updated at the end of every session, records what is done, what is in flight and what is blocked. A decisions file records what was chosen, why, and what was rejected, because the code shows what was built but not the reasons for it. With that structure in place, a new session (human or agent) can get its bearings in a few minutes instead of guessing its way through the first hour. We put the same backbone under every automation build before letting an agent touch it unsupervised, and it is worth doing on projects a human will pick back up too, because the fresh-session test works the same way whether the next reader is a person or an agent.

What Happens When a Team Skips This and Relies on Memory Instead?

When a team relies on memory, rules that live only in chat threads, a stale wiki or one engineer's head are by definition invisible to the agent. It cannot tell a rule that still matters from one that stopped applying last quarter, because neither appears anywhere it can read.

Across the client builds we have run, this failure is consistent enough to recognize on sight. Protocol decisions live in old Slack threads that search can't surface, a wiki page describes an API that changed two quarters ago, and one senior engineer is the only person who remembers why a particular service can't be redeployed on a Friday. An agent dropped into that environment has no way to distinguish a rule that still matters from one that has lapsed, because neither is written anywhere it reads. Fixing this does not take a heroic documentation sprint. Close the specific gaps the fresh-session test exposes, one blank at a time, and then keep the habit by updating the relevant file in the same commit as the code change it describes, instead of in a separate pass that is easy to skip under deadline pressure.

Common Questions

Is the fresh-session test only useful for AI agents?
No. A repo that fails it usually onboards new human hires badly too. The test is really a proxy for whether the project's knowledge lives in durable files or in specific people's heads.
How often should an instructions file be audited?
Roughly monthly on an active project. Rules accumulate faster than anyone deletes them, and a rule that stopped mattering months ago is still burning attention every time an agent reads the file.
Does a bigger context window make the repo-as-truth problem go away?
No. A bigger window changes how much text fits, not how reliably a model uses the middle of it. The lost-in-the-middle effect shows up even in models built specifically for long context.
What's the minimum viable version of this for a small project?
A short root file with the overview, run commands, and hard constraints, plus a progress note updated at the end of a session. That alone catches most of the value.
How do state files interact with WIP limits and feature lists?
They're complementary. State files answer "what's true right now"; a feature list with a locked verification step answers "what counts as finished." Both live in the repo for the same reason: nothing durable lives only in a session's memory.

Sources

SourcePublisherLink
Lost in the Middle: How Language Models Use Long ContextsLiu et al. (arXiv)arxiv.org
How We Built Our Multi-Agent Research SystemAnthropicwww.anthropic.com
Building Effective AI AgentsAnthropicwww.anthropic.com

Questions to explore next

Keep Exploring

Chalk stick figure in a hard hat presenting a little machine of blue gears it just built

Bring us the bottleneck.
We’ll build the system.

Building What's Next.