Skip to content
Wenlan

Problem

Why AI Coding Agents Lose Context Between Sessions

Resume the right session, check unfinished work, and give the next agent a clear starting point.

Qi-Xuan LuUpdated 4 min read

01

Choose resume or a fresh start.

02

Check the current code and test results.

03

Give the next agent one clear next step.

01

Quick answer

A fresh session lacks the previous conversation; compaction can omit details. Start with the recovery path that matches what went missing.

What you needStart here
The earlier conversationIn Claude Code, resume the native session: claude --continue for the latest eligible session in this project, or claude --resume to choose one.
Standing rulesCheck the project instructions and native memory loaded by your client.
A decision lost during compactionOpen its saved note or transcript. Unrecorded reasoning stays unknown.
To continue in a new session or toolRead the handoff, then check it against the current files using the steps below.
Want a reusable skill? Inspect Session Handoff's create/resume workflow

02

Check what changed

Before editing, compare the handoff with the current repository. These commands inspect your work without resetting, staging or committing it.

Replace src/retry.mjs with a relevant path. For the last command, replace BASE_COMMIT with the handoff's verified commit; skip it if none was recorded.

  • Check every kind of change: diff shows unstaged edits, --cached shows staged edits, and status lists untracked files to read separately. Preserve unrelated work.
  • A clean worktree can still contain commits made after the handoff. Compare its recorded commit with HEAD too.
  • Match test results to the code version they checked. Inspect unfamiliar test commands before rerunning them; missing results are unchecked.
  • Find reasons in decision notes or the handoff, and command history in saved transcripts or terminal logs. A diff cannot reconstruct either.
Inspect current and committed changes
pwd
git branch --show-current
git rev-parse HEAD
git status --short
git diff --stat
git diff -- src/retry.mjs
git diff --cached -- src/retry.mjs
# Also compare any commits since the handoff:
git diff BASE_COMMIT HEAD -- src/retry.mjs

03

Give the next agent this prompt

Replace HANDOFF.md with your actual handoff path. Have the agent report its findings before editing.

Copy into a fresh conversation
Recover the task in HANDOFF.md.
Read project instructions first.
Do not edit, stage, reset, commit,
or push.
Check the branch and HEAD.
Compare commits since the handoff.
Inspect staged, unstaged and
untracked files.
Report:
- Completed and unfinished work.
- Decisions, reasons and sources.
- Test results and tested versions.
- Conflicts with current files.
- One next action.
Mark missing evidence unknown.

Need to write the handoff first?

04

Example: an old test pass no longer applies

We ran a tiny fictional Git project whose goal was to raise a retry limit. The handoff recorded a passing test; then only the implementation changed.

The rerun caught the mismatch. The next step was to reconcile the intended behavior and test, rather than call the task finished.

This was a synthetic Git/Node exercise, without an LLM or Wenlan run. The input files stayed unchanged during inspection and the test rerun.

Version checkedRetry limitActual test result
Saved baseline2Passed: the test expected 2.
Current working tree3Failed: actual 3, expected 2; exit 1.
Inspect the inputs, commands and actual output

05

When Wenlan helps

A handoff file can be enough for one project. Wenlan helps when several configured AI tools need durable decisions, reasons and project status in a shared memory boundary.

The loop below requires Wenlan's Claude Code or Codex plugin. MCP-only clients can use context, recall and capture tools, with an explicit handoff for unfinished work.

Keep code changes in Git and command history in saved transcripts or terminal logs. Wenlan does not replace those records or native resume.

Wenlan continuity loop
/brief
/recall <specific decision or gotcha>
/capture <one durable fact and why it matters>
/handoff

See Claude save a decision and Codex read it back

Carry one decision into the next session

Try the Claude-to-Codex example and compare the saved decision with the retrieved source.

FAQ

Will resuming finish an interrupted command?+
No. Resume restores the recorded conversation. Check what actually completed before rerunning a command; it does not roll back the repository.
What if there is no handoff?+
Give the new agent your goal and ask it to inspect the current files. Mark missing reasons and past test results unknown.

Share this guide