Question-led guide · security
How do I prevent stale or poisoned agent memory?
A memory lifecycle with admission, provenance, scope, expiry, promotion, conflict handling, quarantine, and rollback for production agents.
Direct answer
Prevent stale or poisoned memory by treating every write as an admission decision, not a transcript copy. Store source, actor, scope, valid time, confidence, policy version, sensitivity, expiry, and supersession links. Separate session notes from promoted memory, quarantine untrusted writes, revalidate records at retrieval, expose conflicts, and support deletion and rollback by record lineage. Prompt instructions alone cannot provide these controls.
Scope
Use this lifecycle for persistent agent memory that can influence later sessions, users, tools, or decisions. It covers the platform controls around memory. The separate security guide explains how poisoning survives across sessions; the observability guide covers memory lineage telemetry.
Why it happens
Memory APIs make a write look like a convenience function: extract a preference or lesson and place it in a store. The stored sentence loses the conditions that made it valid. A one-time user instruction becomes a permanent rule, an outdated deployment fact survives a release, or untrusted document text is promoted as an organizational preference.
Retrieval then creates implicit trust. The model sees memory beside system-managed context and may not know which record came from a verified owner, an old session, a tool result, or an attacker-controlled page. Similarity ranking is not an authorization or freshness check.
Diagnosis
Select ten records that influenced recent decisions. For each, answer:
- Who or what proposed the write?
- Which source event or artifact supports it?
- Who authorized its scope and retention?
- When was it valid, observed, and last verified?
- Which users, agents, tasks, and tools may retrieve it?
- What conflicts with or supersedes it?
- Which outputs and effects used it?
- Can the platform quarantine, correct, expire, and delete it transitively?
If these answers cannot be reconstructed, the store is a text cache rather than governed memory.
Solution
Create at least three zones: session scratch, candidate memory, and promoted memory. Session scratch expires quickly and remains scoped to one task. Candidate memory has full provenance but cannot affect high-impact actions. Promotion requires policy checks and, for sensitive or cross-user records, a qualified reviewer.
At retrieval, filter by tenant, subject, task purpose, sensitivity, valid time, expiry, and policy before semantic ranking. Return record IDs and provenance with the text. Surface conflicting active records instead of asking the model to silently choose. Revalidate action-relevant facts against an authoritative source at commit time.
Keep append-only change history for governance while ensuring the serving path honors correction and deletion. Test rollback by seeding a poisoned record, observing where it propagates, and proving that invalidation removes its influence.
Artifact
Apply this checklist to every memory class:
| Lifecycle point | Required control |
|---|---|
| Proposal | Capture proposer, source artifact, task, and exact candidate content |
| Admission | Validate type, authorization, sensitivity, provenance, and prohibited content |
| Scope | Bind tenant, subject, purpose, agent, tools, and audience |
| Time | Record observed, valid-from/to, expiry, review, and supersession |
| Promotion | Separate policy and reviewer for broader or higher-impact reuse |
| Retrieval | Filter scope/time/policy before similarity; return conflicts and lineage |
| Use | Log record version, decision, and resulting effect reference |
| Correction | Append new version and stop serving superseded content |
| Quarantine/rollback | Disable affected lineage and rebuild derived indexes |
| Deletion | Propagate to caches, summaries, embeddings, exports, and backups by policy |
Common mistakes
- Saving a model-generated summary without the source record.
- Treating user-provided text as authorized cross-user memory.
- Ranking by similarity before applying tenant and time filters.
- Overwriting a record and losing the history needed to trace bad effects.
- Testing memory recall while never testing poisoning, expiry, conflict, and deletion.
Evidence
Persistent agent memory creates attack paths when untrusted content is admitted and later retrieved as trusted context.
The memory-poisoning study analyzes write channels, architectural vulnerabilities, attacks, and defenses across the evaluated agent systems.
Primary source · paper · checked Aug 26, 2026
Limit: It is a recent preprint with bounded systems and attacks; prevalence and transfer to a specific production design require local testing.
Generative-AI systems need provenance, monitoring, incident handling, access controls, and risk-proportional data governance.
NIST AI 600-1 identifies risks and actions related to data, privacy, security, monitoring, provenance, and governance.
Primary source · standard · checked Aug 26, 2026
Limit: The profile is broad and voluntary; it does not specify a memory-record schema or validate a particular defense.
Memory safety requires lifecycle controls at write, promotion, retrieval, use, correction, and deletion.
The lifecycle checklist below prevents a record from becoming globally trusted merely because an agent chose to remember it.
Signal Studio author framework · reviewed Aug 26, 2026
Limit: Review thresholds and retention rules must reflect local product semantics, law, threat model, and user expectations.
Limitations
No lifecycle eliminates all poisoning or staleness. Source records may be compromised, validators can miss semantic attacks, clocks and deletion propagation can fail, and legitimate facts can later become wrong. Test admission and rollback paths under realistic adversarial and operational conditions.
FAQ
- Can an LLM classify safe memories before storing them?
- It can assist with classification, but deterministic scope, authorization, provenance, retention, and sensitive-data rules should be enforced outside the model. High-impact promotion needs stronger review.
- Is deleting a vector enough to forget a memory?
- Only if every derived copy, cache, summary, index, backup, and promoted record is linked and handled under the deletion policy. Lineage is necessary to know what must be invalidated.
Related guides
Continue within Context engineering, memory, and state, or use one of these adjacent diagnostics:
Editorial QA: automated native-English, structure, source-presence, and link checks completed . This record is not an independent expert endorsement. Review boundary.
