Author: Daniel Cavalli

A long session with an AI agent feels like a conversation with someone who has been following along. You explain the problem once, refine it over a few messages, and by the twentieth exchange it seems obvious that the agent knows what you are building and why. That feeling is what makes agents pleasant to work with. It is also behind many of the problems that show up when you start using them for real work.

The agent does not know any of it. The model behind it is stateless: it keeps nothing from one answer to the next. Whatever sense of continuity you feel was put there by something else, every single time.

Taking that seriously changed how I work. I stopped thinking of a session as a place where context piles up and started thinking of it as something I build on purpose and, more often than not, something I need to cut down.

This idea is the foundation of a presentation I put together on how I use AI agents. It goes on to cover planning, knowledge bases, distribution and translation, but everything else in it depends on getting this part right.

The model does not remember. It reconstructs.

Every time we press Enter, the harness (the software layer that sits between us and the model and assembles what the model receives) rebuilds the full context from scratch: the instructions, the tool definitions, the conversation so far, whatever files it decided to include. The model reads all of that, responds, and then forgets everything (setting aside caching, which is only an inference efficiency mechanism). The next message starts the same process again.

So the continuity we experience is not memory. It is reconstruction, built from context that someone, or something, chose to put back. Sometimes that someone is me, pasting a summary or pointing to a file. Most of the time it is the harness making those choices on my behalf.

That distinction matters because it moves the problem. If continuity were something the model gave me, the only lever would be a better model. Since it is something that gets engineered, the lever is the engineering itself: what gets selected, in what form, and what gets left out.

Check our job opportunies

Why long sessions get worse

Seeing sessions as reconstructions also explains a pattern that is easy to miss: sessions accumulate residue. There are dead ends that were explored and abandoned, goals that got mixed together, constraints that were true an hour ago and no longer are. None of it disappears on its own. It is rebuilt into the context on every turn, sitting right next to everything that still matters.

And the model tends to anchor on what came first, not on what came last. The way a problem was framed at the start of a session, often before anyone understood it well, keeps pulling the answers back long after the work has moved on.

This is where the most common instinct works against us. When an agent starts losing the thread, the natural reaction is to keep more history alive, to give it more context so it cannot miss anything. But more context can mean worse output. The model starts hedging, qualifying, trying to reconcile things that no longer matter. In a sense, it is doing exactly what it was asked to do, which is to take everything in the context into account. The problem is that much of what is in the context should not be taken into account anymore.

The real skill is removal

The conclusion I took from this is that the skill that matters is not expanding context. It is removal: knowing what to collapse, what to discard and what to carry forward.

Carrying something forward does not mean keeping the session alive. It means maintaining the latest truth: a living document that represents our best current understanding of the problem, regardless of the path of attempts, discoveries and corrections that led there. Whatever has been superseded is replaced, not piled up next to the correction. Whatever is still uncertain is made explicit, and the history of the process lives in git, not in the project’s active state. When the next session starts, it begins from that current truth and leaves the rest of the conversation behind, along with its dead ends and outdated assumptions.

Closing a session that seems to be going well and starting a fresh one can feel like throwing work away. It is not. The work is in the latest truth. What gets thrown away is the residue.

Four rules for engineering continuity

In practice, this turned into four rules I carry into my day-to-day work. None of them is complicated. What makes them useful is that each one closes a door through which irrelevant context tends to get in.

One session, one responsibility

At first, I split work into research sessions, spec sessions and implementation packets. Over time, I dropped the formal spec sessions and the packets: they were too heavy and went stale quickly. What remained was the separation between discovery and implementation, connected by a lightweight experiment structure, an isolated, versioned space where design, notes and decisions live together.

The separation can still look bureaucratic, but it is what keeps the residue of one kind of work from leaking into the next. Discovery is divergent, full of hypotheses that turn out to be wrong, and that is exactly how it should be. An implementation session that still carries those discarded hypotheses, however, will keep negotiating with them. Starting fresh from the current state of the experiment means the model sees the consolidated design and decisions, not the winding path that led there.

In practice, every experiment starts with the same lean skeleton: a main document (experiment.md) with the goal in one paragraph, a latest truth section (always rewritten, never accumulated) and a few sections that change depending on the nature of the work:

  • Design: Direction, Iterations and Open questions.
  • Code: Approach, Findings and Open questions.
  • Research: Sources, Findings and Open questions.

Next to it lives a short log (record.md) with typed notes (note, decision, todo, done, run), where the most valuable entries are the decisions and the reasoning behind each one. There is also a protocol file (AGENTS.md) that tells any new session what to read first, how to record decisions and when to save state. It all fits in a few short Markdown files, managed with git.

It also turns the boundary between steps into something I can review. If the design direction or the current state is wrong, I can see it before any code exists, without having to sift through past decisions that have already been superseded.

Curate what the model sees

Every tool schema, every instruction from an MCP server (MCP, or Model Context Protocol, is a standard way of connecting agents to external tools and data), every stale fragment of an earlier exchange competes for the model’s attention. It is tempting to treat irrelevant context as harmless, a few extra tokens that cost a little more and do no real damage. That is not how it works. Irrelevant context does not just waste tokens: it actively degrades output.

Beyond that, much of the mechanical work should never reach the model’s context window at all. A hook, a small script that runs automatically at a given moment, can format code every time a file is saved or validate a YAML file before anything else happens. It costs zero tokens, and it prevents problems the model would otherwise spend dozens of messages fixing.

The same logic led to codemode: instead of exposing dozens of tools to the model and letting each call dump raw data, huge lists or intermediate errors into the conversation, the model writes a small piece of code that calls those tools programmatically. The code itself filters, transforms and validates what comes back, returning to the session only the final result that matters.

The principle behind both practices is the same: keep noise and mechanical execution out of the context window. Every error the model debugs and every raw payload it inspects inside a session becomes part of that session: the failed attempts, the error messages, the irrelevant data. That is residue again, created by work that deterministic code handles better, outside the conversation. Keeping that noise out preserves the context for what actually needs the model’s judgment.

Real evidence, not assertion

Agents write with conviction even when they are wrong. Confidence, plausibility and well-written text are no substitute for proof. If a claim enters the latest truth without being verified against the real system, it is not just wrong in that session: it goes on to contaminate every following session that starts from it.

In practice, this means working with real systems, not comfortable abstractions. Instead of accepting deliveries that rely on mocks or isolated validations that create a false sense of progress, a task is only done when it works end to end, fully integrated. Commands run against the real environment, their logs and exit codes are recorded outside the conversation, and whatever has not been proven yet shows up explicitly as a hypothesis or uncertainty, never as fact.

The rule is simple: every conclusion that enters the active state has to come from observable evidence, logical deduction or a stated premise. When the model checks the source instead of assuming, the continuity built across sessions rests on reality, not on what the previous session said.

Delegate execution, never understanding

For a while, the next step seemed obvious: if every task deserves its own clean context, it should be enough to multiply agents in parallel and coordinate them from above. In practice, I abandoned that path. Orchestrators and chains of subagents hide intermediate reasoning, fragment context and tend to leave the hardest part of the work, integration, without an owner. When a subagent investigates a problem and returns only a summary, you lose touch with the evidence behind that conclusion. For anyone who doubts this compression, it is worth opening a finished subagent and comparing its full answer with what the main agent chose to pass along. It becomes clear that each layer of subagents adds lossy compression to the context.

Delegating cognitive work does not mean delegating intellectual responsibility. An engineer can use agents to investigate, test hypotheses, plan and implement, but needs to truly understand the conclusions and the evidence their decisions rest on. The highest-value activity is still understanding the problem, defining what needs to exist and making decisions. Execution is the part agents accelerate.

Today I prefer to run focused sessions directly, without opaque layers of delegation in between. Each session has a clear responsibility, a curated context and an explicit verification point. Parallelism still exists when it makes sense, but the one who keeps the whole coherent and answers for the result is never an orchestrator: it is me.

What stays with the human

Agents are remarkably good at single-domain work. Give one a well-defined problem in a single area, with the right context, and it will execute it well. But the moment the work requires connecting the dots across multiple domains in the same argument, they fall apart.

That is why I don’t think the human advantage is “thinking” in general. It is cross-domain synthesis: holding three different contexts in your head, cross-referencing them, and knowing which constraints are real and which were inherited from a conversation that no longer applies.

That last part connects back to everything above. Deciding what to discard, what to carry forward and what each agent should see is itself an act of synthesis. It requires knowing which constraints are still true, and that is exactly the kind of judgment that does not survive inside a long session. The agent executes. Our job is deciding what it should execute.

Continuity is still the job

Agents have advanced quite a bit since I first put these ideas together, and some of the details here will need revisiting in the near future. That has already happened a few times: the first version of my way of working with agents, from February 2025, relied on concepts I now consider harmful to productivity:

AspectFirst versionHow I work today
Continuity across sessionsHandoff artifacts assembled at the end of the conversationA living latest truth: superseded beliefs are replaced, uncertainties stay explicit and history lives in git
Moving from discovery to codeSeparate research and spec sessions, plus implementation packetsDiscovery and implementation connected by lightweight experiments (experiment.md, record.md, AGENTS.md)
Tools and contextMCP schemas exposed directly in the context windowAggressive curation, deterministic hooks and codemode to filter data outside the conversation
VerificationErrors isolated in a sandbox and local validationsReal end-to-end evidence in the actual system, with no mock-based deliveries
Scale and coordinationMulti-agent setups with orchestrators and parallel subagentsFocused sessions run directly, delegating execution without giving up understanding

The premise underneath the rules, though, is not a detail. As long as the model is stateless, whatever continuity exists has to be built by someone, and whoever builds it decides what the model gets to work with. Assume the agent knows nothing. Give each session a well-defined responsibility. End it with something worth handing off and keep out what does not belong. Catch what you can before it ever reaches the model.

Continuity is not something the model gives you. It is something you engineer.

Check our job opportunies