Topic 3 of 4 · 5 min read
Starting fresh versus continuing a session
Goal: Decide from a session's state whether to continue, compact or restart, and write the handoff note for a restart.
Continue a session while the agent is accurate and on task, compact it when it is on task but the history is long, and restart with a written handoff when it repeats mistakes, forgets rules or carries a rejected approach. A fresh session with a good note beats a long one that has gone stale.
Check yourself · 1 of 3
An agent has now twice re-applied a fix you rejected earlier in a long session. What is the best response?
Why it matters
An agent only knows what is in its context window: your messages, its replies, file contents and command output. As that fills, older details get less reliable, and the transcript collects dead ends, failed attempts and your corrections. Models can then repeat an approach you rejected, or quietly ignore a rule you gave an hour ago. This drift is sometimes called context rot. It is not a bug you can argue away. It is a property of long, cluttered context.
How to do it
- Check for signs. The agent repeats a fix that failed before. It forgets a constraint from the start. It contradicts an earlier decision. It answers more slowly or with less detail. You have corrected the same thing twice.
- Choose the least costly option that works.
- Continue if it is accurate and the context is short.
- Compact (summarise the history in place) if the work is on track but the transcript is long. Give it a focus, for example "keep the decisions, the failing test names and the file list". Check the summary, because compaction can drop details you needed.
- Clear or restart if the context contains a wrong approach, a tangle of failed attempts, or a different task. Start of a new task always deserves a new session.
- Write the handoff note before you leave. Ask the old session to draft it, then read and fix it yourself. It should hold the goal, the decisions made and why, what is done, what is next, the files involved, the commands to run the checks and the dead ends to avoid.
- Start the new session from the note. Paste it or save it in the repository and point the agent at it. Let it read the files itself instead of trusting a summary of them.
Before and after
Weak: "Continue from where we left off, you know the plan." In a fresh session the agent knows nothing.
Better:
## Handoff: add rate limiting to /api/export
Goal: 10 requests/min per API key, 429 with Retry-After.
Decided: token bucket in src/middleware/rateLimit.ts; no Redis (single node).
Done: middleware + unit tests (tests/rateLimit.test.ts, passing).
Next: wire into routes/export.ts; add integration test.
Avoid: express-rate-limit package (rejected: no per-key config).
Check with: npm test -- rateLimit
What goes wrong
- Never restarting. You keep correcting a polluted session because restarting feels like losing progress.
- Restarting with no note. The new session redoes work or repeats a rejected idea.
- Trusting a compacted summary blindly. A summary can omit a constraint. Read it.
- Mixing tasks. A second unrelated task in the same session inherits the first one's assumptions.
Examples
Choosing from the session state
| Situation | Choice |
|---|---|
| 20 minutes in, accurate, small context | Continue |
| 3 hours in, on track, long transcript | Compact with a focus on decisions and open tests |
| It re-applies a fix you rejected twice | Restart with a handoff note |
| Task finished, next ticket is unrelated | New session |
Prompt to produce the handoff
Write a handoff note for a new session: goal, decisions and the reason
for each, what is done, what is next, files involved, the exact commands
to verify, and approaches we tried and rejected. Keep it under 30 lines.
Read the result, fix anything wrong, and save it as docs/handoff.md before you clear the session.
Key points
- Repeated mistakes, forgotten rules and contradictions of earlier decisions are the signs that a session has gone stale.
- Continue when accurate and short, compact when on track but long, restart when the context holds a rejected approach or a different task.
- A handoff note holds the goal, decisions with reasons, done, next, files, check commands and dead ends.
- Have the old session draft the note, then read and correct it before you rely on it.
- Start each new, unrelated task in a fresh session.
Common mistakes
- Pushing on with a polluted session because restarting feels like throwing away progress.
- Restarting without a handoff note, so the new session redoes finished work or retries a rejected idea.
- Accepting a compaction summary without reading it, then losing a constraint that was only in the old transcript.
- Using one long session for several unrelated tasks, so later work inherits assumptions from earlier work.
Check yourself · 2 of 3
Which item is most useful in a handoff note for a new session?
Check yourself · 3 of 3
The work is on track, but the transcript is very long. You want to keep the decisions and the failing test names. What do you do?
Practice items, not counted towards your mastery.
Start here
- Checkpointing (Claude Code docs) (opens in a new tab)DocsFree
Rewind menu, what is tracked, and the stated limits: shell changes and external edits are not restored.
- Review AI code edits (VS Code docs) (opens in a new tab)DocsFree
How an editor-based agent shows edits and lets you keep or undo them one by one.
- Effective harnesses for long-running agents (Anthropic) (opens in a new tab)ArticleFree
Progress files and clean commits that let each new session continue where the last stopped.