Stale Context Retention

Goal Context Lifecycle Frequency Common Category Operations Published View source on GitHub ↗

Issue: Outdated Information Kept While Current Information Discarded

Frequency: Common

Symptoms

  • Agent references outdated information
  • Recent corrections ignored
  • Old versions of facts used
  • Updates don’t take effect
  • Agent contradicts recent statements

Root Cause Context management may retain old information while discarding newer updates. If a user corrects information or provides updates, FIFO truncation keeps the old (incorrect) version longer. Without staleness tracking, the agent uses outdated context.

Example

Turn 1: User: "My address is 123 Main St"
        Agent: "Got it, 123 Main St"

Turn 15: User: "Actually, I moved. New address is 456 Oak Ave"
         Agent: "Updated to 456 Oak Ave"

Turn 40 (context near limit, FIFO truncation):
  [TRUNCATED] Turn 15: Address update to 456 Oak Ave
  [KEPT] Turn 1: Address is 123 Main St
  
Turn 41: User: "Send the package to my address"
         Agent: "Sending to 123 Main St"
         
Failure: Old address used, recent update truncated

Contributing Factors

  • No timestamp-based prioritization
  • Updates don’t invalidate old versions
  • FIFO keeps first mention, not latest
  • No semantic deduplication
  • No fact versioning
  • Corrections not specially handled

Eval Recipes

Test Cases

TestInputExpectedFailure Indicator
Fact updateUpdate value, query laterNew valueOld value
Correction handlingCorrect mistakeCorrection usedMistake repeated
Version conflictMultiple versions existLatest usedOld used

Metrics

MetricTargetHow to Measure
Update retention100%Updates survive truncation
Fact freshnessLatestMost recent version used
Correction compliance100%Corrections applied

Mitigation Strategies

Prevention

  1. Fact versioning: Track versions of key facts
  2. Update precedence: Updates replace, not append
  3. Semantic dedup: Remove old versions of same fact
  4. Recency weighting: Prioritize recent over old
  5. Explicit correction handling: Mark and prioritize corrections
  6. Key-value memory: Structured fact storage with updates

Architecture Pattern

Facts memory:
{
  "user.address": {
    "value": "456 Oak Ave",
    "updated": "turn 15",
    "previous": ["123 Main St"]
  }
}

On truncation: Keep latest value, discard history

Production Signals

Key Metrics

MetricAlert Threshold
fact.version_conflicts>0
update.retention_rate<100%
correction.applied_rate<100%

Alerts

AlertConditionSeverity
Stale Fact UsedOld version in responseP2
Update LostRecent update truncatedP2
Correction IgnoredCorrection not appliedP2

References