PROJECT · SESSION STATE

Session State and Resumption: How Coding Agents Keep Track of Work

An AI coding agent can save its work and reopen it later. That is useful when nothing has changed, and a quiet source of wrong answers when it has. A beginner-friendly walkthrough of resume, fork and fresh-start-with-summary, why a saved tool result is a photograph rather than a live view, and how to decide between the three, with heavily commented Python that fingerprints every file read and audits a session before you trust it.

An AI coding agent can save its work and reopen it later. That is useful when nothing has changed, and a quiet source of wrong answers when it has.

Imagine an engineer inspects a house on Monday.

They take notes, photograph the wiring, and write down what needs repair.

On Tuesday, three rooms are renovated.

If the engineer comes back on Wednesday and only reads Monday's notes, they may give bad advice. Not because they are careless, but because their notes describe the house before the renovation.

AI coding agents have the same problem. They can save prior work, reopen it later, and continue from where they stopped. That is useful when nothing has changed. But if the code changed between sessions, the saved context may now contain old information.

When an agent reads a file, the contents of that file are written into the session as text, together with everything else it did. That saved text is a tool result, and it is a snapshot from one moment in time. It does not update itself. If the agent read auth.ts at 2:00pm and you changed auth.ts at 4:00pm, the 2:00pm version is still sitting in the session, indistinguishable from a fact.

THE SAVED SESSIONTHE FILE, NOWuserAudit the auth module.modelI'll inspect the files.toolcontents of src/auth.tsread 2:00pm · #a3f9c1modelFound three issues.src/auth.tsedited 4:00pm#7c21b8same pathdiffers
Fig. 1 · A session is a list, and one entry is a photograph. The saved session holds the file as text, exactly as it read at 2:00pm, together with a fingerprint of those contents. The file on disk has moved on. Nothing in the session notices, because a tool result is a record of one moment and has no mechanism for updating itself.

This project explains how session resumption works, when to use it, when not to use it, and why a clean restart with a good summary is often safer than simply continuing an old session. It builds a working session_manager.py that fingerprints every file an agent reads, audits a saved session against what is on disk now, and recommends whether to resume, fork, or start over.

Sign in to view this build.

Create a free account to access the full build walkthrough on kevinsomany.com.

Loading…

Sign in or create an account.

Enter your email and we will send you a sign-in link. No password needed.

or continue with