How We Keep an AI Agent From Losing the Plot Across Sessions
Long sessions eventually exceed the context window, and anything that only ever lived in conversation is at risk of being thinned out. A living plan file on disk is what survives that, and what lets a new session pick up cold, days later, without re-deriving context that already existed, no matter which agent opens it.
Every AI coding session has a limit on how much it can hold in view at once. When a long session eventually exceeds that limit, older turns get summarized or dropped so the session can continue, a process usually called compaction. That's not a bug, it's how these tools stay usable over a long working session. But it has a real cost: anything that only ever lived in the conversation itself, and never made it to a file, is at risk of being thinned out or lost the moment that happens.
Why a file on disk is different
A living plan file is not subject to compaction at all. It's read back in fresh at the start of every session, which is what makes it the actual source of continuity, not the conversation history sitting behind it. Whether a session ends normally, gets interrupted, or runs long enough to compact twice over, the plan file is what's still there afterward with an accurate account of what's done, what's in progress, and what's still missing. This holds regardless of which agent you're running, and it's the one piece of continuity that's genuinely portable if your team uses more than one.
What the file needs to carry
- Status tiers: what is actively being worked now, what is decided but not started next, and what is lower priority and not yet scheduled, in a backlog.
- For each item: the literal fact or decision, the reasoning behind it so a future session can judge whether it's still relevant, and its current status, done, in progress, or explicitly still missing.
- Named people, dollar figures, and decisions from conversation, not just code or build work, captured the moment they come up rather than deferred to the end of a session.
We call ours PROJECT_PLAN.md, name it whatever fits your own workflow, the convention matters more than the filename.
Where automated enforcement fits in
Without a technical check, "update the plan proactively" is itself just advisory, easy to skip under a run of fast tool calls, and exactly the kind of gap that lets a real decision or contact go uncaptured for days without anyone noticing. A session-start check, or an on-demand audit run the same way, can compare the plan file's last-modified timestamp against other recent activity in the project and flag it as stale before any other work happens, catching the drift instead of relying on memory.
What the file carries
- NOW, NEXT, and BACKLOG status tiers
- The fact, the why, and the current status for each item
- Names, figures, and decisions, captured as they come up
Where enforcement helps
- A session-start check for staleness against recent activity
- A checkpoint before context gets thinned, to write conversation-only facts to disk first
- An audit routine that runs the same check on demand
How this looks in the tools we actually use
Both tools now ship some form of native memory on top of whatever plan file discipline you bring yourself. Neither one replaces it, and neither one's memory reaches the other tool.
Claude Code
Auto memory is written by the agent itself as it learns preferences and project context, one memory location per project, read back in at the start of every session. A living plan file on disk sits alongside it, our own convention, not a built-in feature, and is what actually survives a compaction event mid-session since it's read fresh rather than reconstructed from a summarized transcript.
ChatGPT Codex
Every session is saved as a full transcript, timestamped and structured for replay. Reopening a session reconstructs context from that transcript rather than resuming an actual saved model state, so a task interrupted mid-step still requires the agent to reorient. As of 2026, Codex also runs a native memory-consolidation pass roughly six hours after a session closes, merging recent sessions into a persistent memory store the next session reads back automatically.
Even with that native layer, a plan file kept on disk still matters: transcripts and consolidated memory are local to Codex, they don't transfer to any other agent, and they aren't structured as a NOW/NEXT/BACKLOG record a human can scan in ten seconds.
The point of maintaining it
A plan file is what keeps an AI agent working from what is done, what is in progress, and what is still missing, instead of quietly re-deriving or re-asking for context that already existed. That's the whole reason it's worth the discipline of updating it as things happen, not at the end of a session when half of what happened is already gone, and it's the one habit that pays off no matter which agent you hand the file to next.