Long tasks rarely finish in one agent session. Context fills up, the session ends, or you stop for the night, and the next session starts cold.
What I keep losing in that handoff is not the code. It is the why: which approach was tried and dropped, what is half done, and what the agent was about to check next.
So I'm curious how other people do it:
- Do you have the agent write a handoff note before it stops, or do you write it yourself?
- Where does it live: a file in the repo, the PR description, an issue, or just the chat history?
- How do you catch a note that is out of date because work kept going after it was written?
Would love to hear what actually works for you, and what you tried that didn't.
Top comments (2)
The pattern that has held up best for us is treating the handoff note as a SHA-stamped sidecar, not prose written at the very end:
current_head,dirty_files, andlast_verified_cmd(exact command + exit code) at the top, followed byruled_out(approach -> exact failure). Keeping rejected paths explicit stops the next session from re-trying the same dead end.git rev-parse HEADplus a hash ofgit diff(stored in.git/agent-handoff.mdor a draft PR comment so it doesn't pollute commits). On resume, the first step checks whetherHEADor the working-tree hash moved since the stamp; if it did, the agent readsgit diff <stamped_sha>..HEADbefore trusting any claim in the note.I think the most valuable part of a handoff is making the next session understand not just the current state, but the reasoning that led there.
I'd want the agent to leave three things behind:
I'd keep that in a handoff file inside the repository rather than relying on chat history. The repo is where the actual work lives, and the note should travel with it.
One extra safeguard I'd use is to update the handoff at the end of the session, not just when the agent first announces it's running out of context. Otherwise, the note can describe a project that no longer exists in that state.
The interesting challenge is that an AI agent can summarize what it did, but it doesn't always recognize which decisions will matter to the next session.
What's your most reliable way of preserving that missing context — especially the reasoning behind decisions that aren't obvious from the code?