Sub topic 11
Starting fresh: handing work to a new session
This chapter assumes you have used a coding agent in a terminal, know basic git, and have seen how compaction and a progress file work. Here you will learn when a fresh session beats another compaction, and how to hand work over without losing the decisions that matter.
When to start fresh instead of compacting
Compaction keeps the same session and replaces its history with a summary. A fresh session discards the history completely. Start fresh when:
- The session contains many dead ends that the summary would still have to describe.
- The agent keeps repeating a rejected idea or contradicting an earlier decision.
- You finished one subtask and the next one touches different files.
- You have compacted more than once. Each summary is built from the previous summary, so details drift.
Continue the same session when the work is close to done and the context still holds mostly relevant material.
What a handoff must carry
A new session knows nothing except what you give it. A good handoff holds the information the code and git history cannot show:
- The goal and the current subtask.
- Decisions and the reasons for them.
- What is finished and what is next.
- Unresolved failures, with the exact command that reproduces each.
Leave out anything the agent can recover cheaply by reading the repository, such as full file contents or old command output.
The handoff routine
Ask the old session to write the handoff into a file, then check the file yourself before you close the session. The file is the only thing that survives.
Update PROGRESS.md for a handoff. Include the goal, decisions with reasons,
files changed with one line each, unresolved failures with the command that
reproduces them, and the next three steps. Do not paste file contents or
raw command output.Then save the code state so the new session starts from a known point:
git add -A
git commit -m "WIP: TOML loader, tests passing except test_legacy_ini"
git log --oneline -n 3Commit messages are part of the handoff. A new session can read git log and git diff cheaply.
Start the new session and point it at the file:
Read PROGRESS.md and run `git log --oneline -n 5`. Then restate the goal
and the next step in two sentences before you change anything.The restatement is a check. If the agent summarizes the goal wrongly, fix the progress file now, before any code changes.
Common errors
| Error | Result | Fix |
|---|---|---|
| Closing the session before reviewing the file | A wrong or missing decision is lost for good | Read the file before you close the session |
| Pasting the whole old transcript into the new session | The new session starts with a full context again | Hand over the file, not the history |
| Leaving out the reasons for decisions | The new session reopens settled questions | Write "decision, because reason" |
| Uncommitted changes | The new session cannot tell finished work from half-done work | Commit, even as WIP |
| A stale progress file | The agent resumes from the wrong step | Update the file at each handoff |
Handoff to a subagent
The same rules apply when you delegate to a subagent. It starts with an empty context too, so give it a precise brief: the question, the files or directories to look at, and the format of the answer you want back. Ask for a short result, not a transcript of its work.
Exercise
You compacted a session twice. The agent now re-proposes an INI fallback that you rejected an hour ago. What do you do, and what must the handoff file contain so the problem does not return?
Show answer
Start a fresh session instead of compacting a third time. Have the old session, or you, write the handoff file, and check it before you close the session. The file must record the decision "no INI fallback" together with the reason for it, plus the goal, finished work, unresolved failures with reproducing commands, and next steps. Commit the code, then start the new session by having it read the file and restate the goal.