Plain Reckoner
English
← The blog

Agent workflows

AI Agent Forgot the Task? Fix Context Loss and Handoffs

AI agent memory needs more than a longer prompt. Preserve decisions, verified results and the next action so interrupted work can resume safely.

By Plain Reckoner Team · Release date: 2026-11-07

Selected source checked:

What helps when an AI agent loses context? Record the goal, constraints, verified changes and next action; then compare that handoff with the current files and test results before continuing.

Imagine an agent has already changed three files. In the next session, it starts the same investigation again and proposes a change that has already failed. Its summary sounds plausible, but the summary is not the working tree. Before it edits anything else, compare its handoff with the files, the latest test results and any running process.

A useful handoff says what the user wants, which constraints still apply, what changed, what was actually checked and what remains to do. The examples in this guide use a fictional coding project. Later, you can inspect an actual feature-list command from Anthropic’s autonomous-coding quickstart and try the local reproduction linked beside it.

Anthropic's November 2025 engineering account describes how its long-running agent leaves artifacts for the next session. It is a useful example of one implementation, rather than evidence that the same handoff will solve context loss in every system.

In this guide
  1. A handoff you can inspect
  2. Separate the goal from the conversation history
  3. Describe the files that actually exist
  4. Keep implementation and verification separate
  5. Record decisions with a reason and a boundary
  6. Give background processes their own state
  7. Preserve constraints without preserving secrets
  8. Avoid a summary that quietly changes the task
  9. Use a small acceptance table
  10. Resume with a verification pass, not a rewrite
  11. Choose memory storage by the job it must do
  12. Test the handoff under a deliberate interruption
  13. End with a next action someone can execute

A handoff you can inspect

Keep the goal, constraints, artifact paths, completed checks and the next action in a short checkpoint. Before resuming, compare that checkpoint with the current files; treat it as a starting point rather than an authoritative substitute for inspection.

Separate the goal from the conversation history

A transcript records what was said. A goal states what must eventually be true. Those are different things. A long conversation may contain abandoned ideas, contradictory drafts and status updates that were accurate only at the time. If the next session treats every sentence as equally current, it can revive an old decision or continue a task the user already changed.

Start the handoff with the present outcome in plain language. For example: add a searchable help page, preserve the existing design, keep search local, and publish only after the required checks finish. Then list the constraints that still apply. A constraint such as keeping private data out of logs should not disappear because the conversation moved on to colors or wording.

Keep the goal short enough to compare with the result. A paragraph full of implementation details can bury the user's actual need. Put file paths, commands and evidence in their own fields below it. The next session should be able to answer two questions quickly: what are we trying to finish, and what must remain true while we do it?

Describe the files that actually exist

A handoff that says the search feature is complete can hide several different states. Perhaps the component exists but is not imported. Perhaps the page builds but the filter returns no matches. Perhaps the feature is deployed only to a preview URL. Record the artifact and its location instead of relying on a broad label such as done.

In the fictional help-page project, a useful note names the page file, the data module and the client-side filter. It states which of those changed and whether the latest build includes them. If version control is available, include the relevant revision and working-tree state. If it is not available, say so and use a dated checkpoint with exact paths.

The next session must inspect that state before editing. A summary can become stale when another person changes the project or a deployment fails after the note was written. Treat the handoff as a map to evidence rather than a substitute for it. Reading a short diff and the current files often resolves uncertainty faster than asking the model to infer what happened.

Keep a handoff the next session can check
01
Goal and constraints
02
Artifact locations
03
Verified results
04
Next concrete action

Keep implementation and verification separate

An agent may correctly report that it wrote code and incorrectly imply that the behavior works. Prevent that ambiguity by giving implementation and verification separate entries. For each required outcome, record what was created, what check ran, its final result and any limitation. A command that was suggested but never executed belongs in the next-action list.

For example, the search input may be implemented and the static build may pass, while keyboard navigation remains untested. That is a useful partial state. It tells the next session where to continue without throwing away the completed work or exaggerating confidence. Combining all those facts into a single green checkbox loses the distinction that matters most.

Also preserve failures. If a test could not start because the server was unavailable, record the infrastructure problem and the exact command. Do not relabel it as a successful application check. A clean handoff is not one with no red entries; it is one where the reader can understand what the evidence actually establishes.

Record decisions with a reason and a boundary

A decision without its reason is easy to reverse accidentally. Suppose the team chose local browser search because the help catalog is small and no private query should be sent to a backend. A later agent may add a hosted search service because it seems more powerful. The new choice could violate both the product scope and the privacy expectation.

Write the decision together with the condition that supports it. In this example: local search is sufficient for the current catalog; reconsider only if measured size or capability needs change. That gives the next session room to improve the design without treating every previous choice as either permanent law or disposable history.

Avoid turning the decision record into a diary. Preserve choices that affect current work, and move superseded choices out of the active checkpoint. If a decision changes, state what replaced it and why. A short current record is easier to use than a long file where the reader must infer which of several competing instructions is still valid.

Give background processes their own state

Long operations are a common handoff trap. A build, export or deployment may still be running when a session ends. The next agent sees that the command started and assumes success, or starts another copy because it cannot find the original result. Both outcomes can create confusion, and duplicate mutations can be worse than duplicate computation.

Record the command, start time, process or tool-session identifier, log location and success condition. State whether the process is running, exited successfully, failed or cannot currently be found. When a process finishes, update the record with the actual exit result. Do not leave a permanent running entry after the operation has completed.

If the process identifier is no longer usable, investigate before retrying. Check whether the expected artifact exists and whether logs show completion. If the result cannot be established, mark it unknown and choose a safe verification step. The principle is simple: an operation being started is evidence of an attempt, not evidence that the required outcome happened.

Preserve constraints without preserving secrets

A useful checkpoint can describe configuration without copying sensitive values. State which environment variables are required, where an authorized credential is loaded from and whether the expected binding exists. Do not paste API keys, private prompts, customer records or confirmation tokens into a summary merely because the next agent might need context.

For the help-page project, the checkpoint could say that deployment uses an existing hosting account and that credentials stay in the environment. It does not need to contain the credential itself. If a failure depends on a particular input, create a sanitized reproduction that preserves the relevant structure without carrying unrelated private information.

Remember that handoff files may be committed, shared or included in a future prompt. Their audience can grow beyond the current session. Write them as durable project records, with references to authorized sources of sensitive configuration rather than copied secrets. If a detail is not needed to resume the work, leaving it out often makes both the record and the privacy boundary clearer.

Avoid a summary that quietly changes the task

Summarization is not neutral when it drops a requirement. A request for ten complete guides can become a note saying expand the blog, which later becomes publish several articles. Each summary sounds reasonable, but the measurable requirement has disappeared. Preserve explicit counts, minimum lengths, delivery targets and user exclusions exactly enough that they remain testable.

The same applies to negative instructions. If the user said not to restore an old account system, a migration summary must retain that boundary. Otherwise a later agent may copy a helpful component together with the unwanted backend it depends on. The handoff should describe both the reusable feature and the parts deliberately excluded from migration.

After writing a checkpoint, compare it with the latest accepted request. Look for missing quantities, changed nouns and vague completion language. This is a small review step with a large practical benefit: it catches task drift before the next session spends time implementing the wrong interpretation. The goal is faithful continuation, not a shorter story at any cost.

Use a small acceptance table

A compact acceptance table can make the state visible without repeating the entire conversation. Give each required outcome an identifier, current artifact, verification result and next action. Use plain states such as missing, implemented, checked and published. Avoid one ambiguous status that mixes code completion with production delivery.

For example, the help-page row might say that the source exists and the build passed, but the live URL has not been checked. The search row might say that empty queries and no-result behavior were tested, while a visual review remains unavailable. A reader can then choose the next useful action without rereading every earlier tool result.

Keep the table current when requirements change. Do not leave a removed feature as an unfinished obligation, and do not erase a failed check simply because another check passed. Where two tasks depend on each other, make the dependency explicit. Publishing a page before its referenced assets exist is not progress just because the deployment command succeeds.

Resume with a verification pass, not a rewrite

The first action in a new session should usually be a bounded check of the current state. Read the active instructions, inspect relevant files and compare them with the checkpoint. If the note says the search handles punctuation, examine that code path or run the focused check. Do not begin by rewriting the component to match a remembered design.

A good resume prompt identifies the goal, the checkpoint and the next unresolved outcome. It can ask the agent to distinguish confirmed facts from assumptions before changing anything. That does not require a lengthy planning ceremony. A short, evidence-based orientation is enough when the project state is clear and the next task is narrow.

If the checkpoint and files disagree, resolve the disagreement explicitly. Perhaps the note is old, the working tree contains a newer change, or a generated artifact was not rebuilt. Record the resolution so the next handoff does not repeat the same confusion. The value comes from reducing uncertainty, not from forcing the model to trust whichever text was loaded first.

Choose memory storage by the job it must do

Not every project needs a vector database or a complex memory framework. A small coding task may need only a current checkpoint, a decision record and a clear test result. A larger system may need structured state with ownership and versioning. Start by naming the retrieval problem you need to solve before selecting a memory tool.

Ask what information must survive, how it changes and who can update it. A current acceptance list needs reliable replacement semantics. An experiment history needs an append-only record. A private user preference needs a different access boundary from public project documentation. Putting all of those into one undifferentiated memory store makes correctness harder to reason about.

Evaluate memory behavior with concrete scenarios. Change a requirement and check whether the agent uses the new version. Remove a permission and check whether the old permission resurfaces. Resume after a failed deployment and check whether the agent reports it accurately. These tests are more useful than a broad claim that the system now has better memory.

Test the handoff under a deliberate interruption

You can assess a handoff without waiting for a real failure. Stop at a safe point, write the checkpoint and ask a fresh session to explain the current state before continuing. Compare its understanding with the artifacts. Did it recover the goal, preserve constraints and identify the next unresolved task? Those are observable questions.

Use a small noncritical example first. In the help-page project, interrupt after the page exists but before the build finishes. A successful handoff should not mark the feature published, should find the pending process and should wait for or investigate its final result. If the next session launches a duplicate build automatically, the process record may be too vague.

Repeat the exercise after changing one requirement. This checks whether the active record overrides obsolete history. Document the mismatch you observed and improve the record structure, rather than merely telling the agent to pay more attention. The handoff itself is part of the workflow and can be tested like any other interface.

End with a next action someone can execute

A useful checkpoint ends with a concrete next step and the condition for finishing it. Run the focused search tests and inspect their exit result is actionable. Keep improving the site is not. If a decision is blocked, state the missing evidence or user choice and identify independent work that can continue safely.

The final handoff should let another person resume without guessing whether to trust a claim of completion. Preserve the small set of facts that matter: the intended result, the current artifacts, completed checks, remaining gaps and any running operations. Link the supporting evidence instead of filling the active note with every historical detail.

Better AI agent memory does not mean keeping every word forever. It means carrying forward the right state and checking it when the workflow resumes. That approach will not eliminate every model mistake, but it makes lost context easier to detect and recovery easier to explain. The next session begins with a verifiable task, not a confident recollection of one.