Skip to content

feat: memory staleness caveats #721

@kokevidaurre

Description

@kokevidaurre

Context

Claude Code appends a staleness caveat when injecting memories older than 1 day:

"This memory is N days old. Memories are point-in-time observations, not live state — claims about code behavior or file:line citations may be outdated. Verify against current code before asserting as fact."

This prevents agents from acting on stale information — a root cause of duplicate issues and contradicting fixes in our system.

From Claude Code Source

memoryAge.ts:

memoryAgeDays(mtimeMs) = floor((Date.now() - mtimeMs) / 86_400_000)
memoryFreshnessText(mtimeMs) = age > 1 day ? staleness caveat : ''

The caveat is injected as a <system-reminder> before the memory content.

Current State

Our state.md files have no age signal. An agent reads state.md written 3 days ago and treats it as current truth. This causes:

  • Acting on resolved blockers
  • Re-filing closed issues
  • Contradicting decisions made in intervening runs

Proposed Changes

In run-context.ts, when loading state.md or topic files:

  1. Check file mtime
  2. If > 24 hours old, prepend caveat:
    ⚠️ This memory is {N} days old. Verify against current state before acting on it.
    
  3. If > 7 days old, stronger caveat:
    ⚠️ This memory is {N} days old and likely outdated. Check git log and current issues before relying on it.
    

Files to change

  • src/lib/run-context.ts — add staleness check when reading memory files (~3 lines)

Expected impact

Minimal code change, significant quality improvement. Agents will verify stale state instead of blindly acting on it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions