A state file template that survives a dead agent session

Agent sessions end badly more often than you’d like: a quota cut, a dropped connection, a context window that fills up. When that happens, the only thing that matters is what was written down before it died.

A good state file makes the next session start in seconds instead of minutes. Here is a template you can copy.

The template

# State: <project or topic>
Updated: <date and time>

## Done
- <what is finished and verified, one line each>

## Next step (exact)
<One action, unambiguous. Include the file, command or decision involved.>

## Blocked
- <what failed> | tried: <what was already attempted> | ideas: <what is left>

## Rules for this project
- <constraints the next session must not forget>

Why each part exists

Done stops the next session from redoing finished work. Write only what is verified. “Probably works” belongs in Blocked, not here.

Next step (exact) is the most valuable line in the file. “Continue the refactor” forces a rediscovery pass. “Rename load_config to read_config in settings.py, then run the tests in tests/test_settings.py” lets the agent start working immediately.

Blocked saves you from a very common loop: a new session tries the same failed fix the last one already rejected. Recording what was tried is as important as recording what failed.

Rules hold the things a fresh session cannot guess: “never touch the production database”, “ask before sending anything outside”, “use the cheaper model for file edits”.

Habits that keep it honest

  1. Update it after every unit of work, not at the end. A unit is one finished step you could describe in a sentence.
  2. Make reading it the first instruction. Put “read the state file before doing anything” at the top of your instructions file.
  3. Keep it short. If it grows past a screen or two, move history to a separate log and keep the state file for the present.
  4. Let the agent write it, but read it yourself now and then. A state file that drifts from reality is worse than none.

The goal is simple: if a session dies mid-task, the worst case is losing minutes of progress, and the next session knows exactly where to pick up.

Leave a Reply