lockstep
Updated 7 min readNaman Jain

Why coding agent memory files go stale - and what teams should do instead

Memory files turn dangerous when old tasks, proposals, and decisions still look current. Scope, owners, status, and replacement links stop the drift.

A coding agent reads a memory file that says the checkout migration is blocked on database approval.

The approval landed last week. The migration shipped. The task closed. Nobody removed the note.

The agent now plans around a blocker that no longer exists.

This failure is easy to misdiagnose as weak retrieval. The agent retrieved the exact memory the team gave it. The problem is lifecycle: temporary state survived without an owner, status, or expiry, so old context still looked current.

The short answer

Memory files go stale when they mix information with different lifetimes:

  • stable instructions
  • personal preferences
  • unfinished task state
  • changing operational facts
  • proposals
  • accepted decisions

Fix the structure:

  1. Keep stable instructions in version-controlled project files.
  2. Keep temporary work in a handoff tied to a task and close it with the task.
  3. Query changing facts from live systems.
  4. Keep proposals separate from accepted decisions.
  5. Give durable records an owner, status, scope, date, and replacement link.
  6. Test retrieval from a fresh agent after changes.

Do not solve stale memory by adding more memory.

Why one memory file becomes a junk drawer

A file often starts with a few useful notes:

- use pnpm
- tests need local Redis
- checkout migration blocked on approval
- team considering event sourcing
- retries capped at two

These lines have different meanings.

  • use pnpm is a stable instruction.
  • tests need local Redis is a project requirement.
  • blocked on approval is temporary task state.
  • considering event sourcing is a proposal.
  • retries capped at two may be an accepted decision, but lacks scope and reason.

When every line looks identical, the agent cannot tell which one is current or authoritative.

Staleness has several forms

The fact changed

A deployment, owner, ticket, or customer configuration moved on. A copied note did not.

The task ended

A blocker or next step survived after the branch merged.

A proposal was rejected

Search retrieves the idea without the verdict.

A decision was superseded

The old record remains useful history but no longer governs current work.

The scope changed

A rule written for one provider or service gets applied everywhere.

The instruction conflicts

Root, nested, personal, and team rules disagree. The agent may pick one arbitrarily.

The maintenance strategy depends on which form you have.

Split memory by lifecycle

Use separate homes:

CategoryHomeMaintenance
Stable project ruleCLAUDE.md, AGENTS.md, scoped rulesReview with code changes
Personal learninglocal auto memoryPerson reviews or deletes
Task statehandoff linked to taskClose or archive at completion
Live factsource tool or MCPQuery when needed
Proposalproposal queue or draft decisionAccept, reject, or expire
Accepted decisionADR or shared decision systemSupersede with links

A tool may store several categories, but the records still need distinct fields and lifecycle rules.

Add fields that let an agent judge freshness

A durable record should answer:

owner: Payments team
scope: services/checkout, Provider A
status: accepted
created: 2026-04-12
review_by: 2026-10-12
supersedes: PAY-09
superseded_by: null
source: customer-contract-17

Not every note needs every field. Significant team decisions do. Temporary handoffs need task and status. Live facts need a verifiable source and observation time.

A timestamp alone is weak. The newest note may still be an unapproved proposal. Status and ownership establish meaning.

Mark replacement instead of rewriting history

When a decision changes, keep the old record but mark it superseded and link the replacement.

Status: Superseded by PAY-24

The new record should name what it replaces. This lets an agent follow an old search result to the current answer and preserves the reason the system used to behave differently.

Deleting history removes useful context. Leaving old history unmarked creates false current context.

Query changing facts live

Do not persist facts that the source can answer better:

  • current production version
  • incident state
  • ticket owner
  • feature flag value
  • deployment health
  • customer configuration

Persist the instruction to check the source. Retrieve the fact when it becomes action-driving.

This reduces duplicates and keeps freshness tied to the system that owns the state.

Make task handoffs expire with tasks

Every handoff should include:

  • task or issue ID
  • branch or worktree
  • owner
  • status
  • updated time
  • done and next
  • blockers
  • cleanup rule

When the task completes, remove .handoffs/current.md or mark it closed and move it to history. Add cleanup to the definition of done so it does not depend on memory.

A simple CI or review check can flag a current handoff that points to a closed task or has not changed for a chosen period.

Keep instruction files short and referenced

Cursor recommends focused rules and referencing source files rather than copying their content. Claude Code recommends concise CLAUDE.md files and warns that conflicting instructions may be followed arbitrarily.

Instead of pasting a decision into three rules:

Before changing payment retries, read the current payment decision index.

Then maintain one record. A pointer can still become stale, but it is easier to check than several duplicated explanations.

Sources: Cursor Rules and Claude Code memory

Build maintenance into the workflow

On task close

  • archive or delete temporary handoff
  • resolve blockers
  • promote reusable learning into the right project rule
  • discard intermediate guesses

On decision acceptance

  • mark the new record accepted
  • mark replaced records superseded
  • update the index
  • link affected code, tasks, and documents

On code review

  • check whether instructions still match the implementation
  • check whether the PR changes an accepted decision
  • require a decision update when necessary

On a schedule

  • review records past their review_by date
  • find current records with missing owners
  • find conflicting active decisions in the same scope
  • find handoffs attached to closed tasks

Automation should surface candidates. Owners still decide whether the context is wrong.

Test for staleness from a fresh agent

Ask a clean session:

  • What is currently blocking checkout migration?
  • Which retry decision is active for Provider A?
  • Which record did it replace?
  • Who owns the decision?
  • What live source confirms the deployed version?

Then change one fact, close one task, and supersede one decision. Ask again.

The setup passes when the agent retrieves the current answer, follows replacement links, and does not treat closed task state as active.

Common bad fixes

Append-only memory with no status

History accumulates, but nothing tells retrieval what wins.

Automatic deletion by age

Old decisions may remain valid for years. Lifecycle and ownership matter more than age alone.

One current summary rewritten in place

This removes history and makes old code harder to understand. Keep replacement links.

Trusting semantic search ranking

Similarity cannot establish approval or current status.

Copying live data into every repository

Duplicates drift at different times. Query the owning source.

For the full map of memory layers and how they fail, start with the AI coding agent memory guide. For the wider market, see the best tools for AI coding agent context and best MCP memory servers for teams. For exact storage boundaries, use CLAUDE.md vs agent memory.

For managed choices, compare decision log tools for product and engineering. For repository decision lifecycle, see ADRs for AI coding agents.

Where Lockstep fits

Lockstep gives team decisions the lifecycle fields generic memory files often miss: accepted choice, rationale, rejected options, owner, scope, status, and explicit replacement.

Agents retrieve the current record through MCP. Product and engineering can review or supersede the same decision outside the coding session. Temporary task state stays in handoffs, changing facts stay in live systems, and instruction files point to the current decision instead of copying it.

The goal is not a memory file that never changes. It is a context system that makes change visible before stale information changes the code.

Keep reading