AI Agent Memory Between Sessions: Session Handoff, PROGRESS.md and Bootstrap Contract
How an AI coding agent remembers a project across sessions: compaction vs context reset, session handoff, PROGRESS.md, git checkpoints, decision log, warm start and init.sh. Context recovery cost metric.
- Implement continuity artefacts and reduce re-exploration time to almost zero.
- Design a bootstrap contract that verifies the agent's readiness rather than relying on guesswork.
- Measure recovery cost before and after — and see the difference in hard numbers.
课程开头
Fifteen minutes to remember yesterday
- An engineer arrives each morning with their memory completely wiped
- They're brilliant, but can't recall yesterday's decisions
- They have to re-read the code and piece together the history
- An agent that has lost its context behaves exactly the same way
Picture an engineer who turns up at work every morning with their memory of the previous day completely wiped. They're brilliant, but they don't remember which architecture option was chosen yesterday or why the others were ruled out, which files have already been rewritten, or where the tests stand. They have to re-read the code, reconstruct the history, and only then carry on working. This is exactly how an agent behaves once it's lost its context: fifteen to twenty minutes go on reconnaissance, and decisions get made all over again — often against what was already settled yesterday.
The agent repeats its recon and argues with its past self
- Thirty minutes of work — and the context runs dry
- The new session knows none of the decisions, changed files or test status
- Fifteen minutes go on repeating the reconnaissance
- The cure isn't more memory — it's a logbook
Thirty minutes of work, and the agent is already arguing with itself. It had built most of the feature, then the context ran out, and the new session doesn't remember which decisions were taken, why option B was chosen, which files have been changed, or where the tests stand. It spends fifteen minutes re-running the reconnaissance and, more likely than not, goes against the previous approach. The right mental model here is a brilliant engineer with total amnesia every morning. And the fix isn't giving the agent more memory — it's introducing a logbook: a set of files that capture the state between sessions.
Why growing the context window doesn't solve the problem
- Even a million tokens get exhausted by complex tasks
- Code, decision history, tool output, conversation — it all grows
- Needs grow faster than windows do
- This is an architecture problem, not a capacity question
Think of an exam: no matter how many hours you're given, a genuinely hard question will still eat the time right up to the last minute. It's the same with an agent's context window: give it a million tokens if you like — a complex task will exhaust that too. The agent reads the codebase, accumulates a history of decisions, takes in tool output and holds the whole conversation, and all of it grows faster than model windows do. You can't buy reliability simply by raising the token limit — sooner or later the exam clock runs out, and the question isn't whether that moment arrives, but what you've prepared for when it does.
课程内容
- Fifteen minutes to remember yesterday
- The agent repeats its recon and argues with its past self
- Why growing the context window doesn't solve the problem
- Compaction keeps the 'what' but loses the 'why'
- Context anxiety: the agent rushes like a student racing the bell
- ❓ Checkpoint: compact or reset?
- What compaction keeps — and what a reset wipes clean
- A practical criterion: the sixty percent mark of the window
- 💡 Walkthrough: forty percent and a single session — that's compaction
- The four continuity artefacts
- PROGRESS.md — where we are now
- DECISIONS.md — why we did it this way
- Git commits as free checkpoints
- Fifteen minutes versus three: work out your cost of amnesia
- Fifteen minutes versus three: work out your cost of amnesia
- Four fields that are enough for a complete handoff
- Coming up next: initialisation as a separate phase
- 🛠 'Add search' — and the agent has already spent half an hour getting to grips with the project
- Implementation and initialisation optimise different things
- Pitfalls: code accumulated without verification
- The bootstrap contract: four readiness conditions
- Myth: initialisation is a waste of time at the start
- Myth: initialisation is a waste of time at the start
- Approach A versus approach B: who wins over four sessions
- Approach A versus approach B: who wins over four sessions
- End-to-end project: step three — the payment backend logbook
- From amnesia to discipline — and on to scope
本课时相关文章
- CLAUDE.md 与 AGENTS.md:是什么、该写什么,以及为什么智能体会无视规则
- 什么是 harness engineering:让 AI 智能体成为可靠的工作工具
- 如何让 AI 智能体变得可靠:从度量到自主工作的分步计划
- 智能体报告“完成”,功能却不工作:为什么会这样,以及如何验证智能体的工作
- Harness 与上下文工程:Harness 工程和提示词、上下文工程有什么区别
本课程全部课程
- What Is Harness Engineering? Why AI Coding Agents Fail Because of the Environment
- Error Accumulation in AI Agents: Why 95% Per-Step Accuracy Fails by Step 10
- AI Agent Reliability Metrics: MTBF, MTTR, Blast Radius and Little's Law
- Why AI Agents Fail in Production: Five Failure Layers and a Diagnostic Loop
- What an AI Agent Harness Is Made Of: Instructions, Tools, Environment, State, Feedback Loops
- Repository Map for AI Coding Agents: Project Structure and State Without Memory
- AGENTS.md Best Practices: Why a Giant Instructions File Fails and How to Build a Router
- AI Agent Memory Between Sessions: Session Handoff, PROGRESS.md and Bootstrap Contract
- feature_list.json for AI Agents: WIP=1, Feature Status and verify.sh Verification
- Agent Says 'Done' but the Feature Is Broken: Verification Gap and Definition of Done
- All Tests Pass, Feature Is Broken: E2E Tests and Architecture Rules for AI Agents
- AI Agent Observability: Sprint Contracts, Evaluator Rubrics and Clean Session Exit
- Autonomous AI Coding Agent for Hours: Loop Engineering and Stop Conditions
- Graph Engineering for AI Agents: When a Single Loop Is Not Enough and You Need a Task Graph
- Building an AI Agent Harness From Scratch: AGENTS.md, feature_list.json, verify.sh and an Autonomous Loop