Cognitive Memory for AI Agents: Beyond RAG
RAG retrieves documents. It doesn't remember.
A RAG system stores chunks in a vector database and fetches the most similar ones at query time. That's search, not memory. Human memory is fundamentally different: it decays, drifts emotionally, gets suppressed by competing memories, and consolidates during sleep. None of that happens in a vector DB.
AgentOS implements 8 cognitive mechanisms from published cognitive science research to give agents something closer to actual memory. This post explains each mechanism, why it matters, and how to use it.
The Problem with RAG-as-Memory
Consider a customer support agent that's been running for three months. With RAG:
- Every interaction is stored with equal weight, regardless of importance
- A complaint from day 1 has the same retrieval probability as one from yesterday
- There's no concept of "forgetting" irrelevant details
- The agent can't distinguish between what it observed directly and what it inferred
With cognitive memory:
- Unimportant interactions naturally fade (Ebbinghaus decay)
- Critical moments are locked in permanently (flashbulb memory)
- Retrieving one memory suppresses similar competing ones (retrieval-induced forgetting)
- Each memory tracks its source type and confidence level (source monitoring)
The 8 Mechanisms
1. Ebbinghaus Decay (Ebbinghaus, 1885)
Memories decay over time following a forgetting curve:
strength(t) = (importance / 10) × e^(-t/stability)
Where t is age in days and stability starts at 3.0 days. Each retrieval increases stability through spaced repetition (Cepeda et al., 2006):
stability' = min(stability × 1.8^n, 180)
This means frequently-accessed memories persist while unused ones naturally fade — the same mechanism that makes flashcards work.
Reference: Ebbinghaus, H. (1885). Über das Gedächtnis. Duncker & Humblot.
2. Reconsolidation (Nader, Schafe & Le Doux, 2000)
Every time a memory is retrieved, its emotional context drifts 5% toward the agent's current mood:
trace.valence += 0.05 × (currentMood.valence - trace.valence);
trace.arousal += 0.05 × (currentMood.arousal - trace.arousal);
A negative memory recalled during a positive mood gradually becomes less negative. This models the well-established finding that memory reconsolidation is influenced by the retrieval context — memories aren't static records, they're reconstructed each time they're accessed.
Reference: Nader, K., Schafe, G. E., & Le Doux, J. E. (2000). Fear memories require protein synthesis in the amygdala for reconsolidation after retrieval. Nature, 406(6797), 722-726.
3. Retrieval-Induced Forgetting (Anderson, Bjork & Bjork, 1994)
Retrieving memory A actively suppresses competing memories B and C (those with high content overlap). Competitors receive a 0.12 stability penalty:
competitor.stability *= (1 - 0.12);
This sharpens recall by inhibiting similar alternatives. Without it, an agent with thousands of memories about "customer complaints" would retrieve a random mix. With RIF, the most-retrieved complaint memories dominate while others fade.
Reference: Anderson, M. C., Bjork, R. A., & Bjork, E. L. (1994). Remembering can cause forgetting. Journal of Experimental Psychology: Learning, Memory, and Cognition, 20(5), 1063-1087.
4. Involuntary Recall (Berntsen, 2009)
On 8% of retrieval calls, a random old memory surfaces unprompted — weighted by emotional intensity (|valence| × arousal). The memory must be older than 14 days and have strength above 0.15.
This creates unexpected connections that pure relevance-based retrieval can't produce. An agent discussing project deadlines might spontaneously recall a similar situation from months ago, adding conversational depth.
Reference: Berntsen, D. (2009). Involuntary Autobiographical Memories: An Introduction to the Unbidden Past. Cambridge University Press.
5. Temporal Gist Extraction (Reyna & Brainerd, 1995)
Memories older than 60 days with low retrieval counts are compressed to their core assertions. The full content is replaced with a gist — the emotional context and entities are preserved, but verbatim detail is lost.
This models Fuzzy Trace Theory: verbatim traces decay faster than gist traces. An agent remembers "that was a frustrating conversation with Alex about the API" without retaining every word.
Reference: Reyna, V. F., & Brainerd, C. J. (1995). Fuzzy-trace theory: An interim synthesis. Learning and Individual Differences, 7(1), 1-75.
6. Source Confidence Decay (Johnson, Hashtroudi & Lindsay, 1993)
Each memory's stability is multiplied by a source-type factor during consolidation:
| Source Type | Multiplier | Rationale |
|---|---|---|
user_statement | 1.0 | Directly observed |
tool_result | 1.0 | Externally verified |
observation | 0.95 | Perceived but grounded |
agent_inference | 0.80 | Self-generated |
reflection | 0.75 | Meta-cognitive |
After 10 consolidation cycles, an agent_inference retains ~10.7% of its original stability while a user_statement retains 100%. This prevents the agent from confusing its own guesses with observed facts.
Reference: Johnson, M. K., Hashtroudi, S., & Lindsay, D. S. (1993). Source monitoring. Psychological Bulletin, 114(1), 3-28.
7. Schema Encoding (Bartlett, 1932; Ghosh & Gilboa, 2014)
New memories are compared against existing memory cluster centroids:
- Schema-congruent (cosine > 0.75): encoded with 0.85x strength (efficient but less distinctive)
- Schema-violating (below threshold): encoded with 1.3x strength (novel = attention-worthy)
Schema-congruent traces also get a 1.1x stability boost during consolidation, modeling the finding that schema-matching information integrates faster (Tse et al., 2007).
References:
- Bartlett, F. C. (1932). Remembering. Cambridge University Press.
- Ghosh, V. E., & Gilboa, A. (2014). What is a memory schema? Neuropsychologia, 53, 104-114.
8. Metacognitive FOK (Nelson & Narens, 1990; Hart, 1965)
When a query activates memories below the retrieval threshold but above noise level (partial activation zone), the system generates a "feeling of knowing" signal:
interface MetacognitiveSignal {
type: 'tip_of_tongue' | 'low_confidence' | 'high_confidence';
feelingOfKnowing: number; // 0-1
partialInfo?: string; // entities, approximate time
}
This lets the agent say "I have a vague memory about this but can't fully recall the details" — more honest than either hallucinating or saying nothing.
Reference: Nelson, T. O., & Narens, L. (1990). Metamemory: A theoretical framework and new findings. Psychology of Learning and Motivation, 26, 125-173.
HEXACO Modulation
All 8 mechanisms are modulated by the agent's HEXACO personality traits:
| Trait | Mechanism Effect |
|---|---|
| Emotionality | Controls reconsolidation drift rate |
| Conscientiousness | Influences retrieval-induced forgetting strength |
| Openness | Affects involuntary recall probability and novelty boost |
| Honesty-Humility | Modulates source confidence skepticism |
| Agreeableness | Shapes emotion regulation strategy |
| Extraversion | Influences FOK threshold (extraverts report higher FOK) |
A high-conscientiousness agent has stronger RIF (sharper recall, more suppression). A high-openness agent has more involuntary recalls (more creative connections). These aren't arbitrary mappings — each is grounded in personality psychology research.
Using Cognitive Memory
Enable in Config
{
"memory": {
"enabled": true,
"cognitiveMechanisms": {
"reconsolidation": { "enabled": true, "driftRate": 0.05 },
"retrievalInducedForgetting": { "enabled": true },
"involuntaryRecall": { "enabled": true, "probability": 0.08 },
"metacognitiveFOK": { "enabled": true },
"temporalGist": { "enabled": true, "ageThresholdDays": 60 },
"schemaEncoding": { "enabled": true },
"sourceConfidenceDecay": { "enabled": true },
"emotionRegulation": { "enabled": true }
}
}
}
Programmatic API
import { agent } from '@framers/agentos';
const assistant = agent({
provider: 'anthropic',
memory: {
enabled: true,
decay: 'ebbinghaus',
cognitiveMechanisms: {}, // all mechanisms with defaults
},
personality: {
openness: 0.85,
conscientiousness: 0.9,
},
});
All mechanisms are optional and independently configurable. When cognitiveMechanisms is undefined, the memory system works without cognitive mechanisms — standard encoding and retrieval with Ebbinghaus decay only.
Why This Matters
RAG gives agents access to information. Cognitive memory gives them the ability to selectively remember, naturally forget, and honestly report when they're unsure. For agents that run for days, weeks, or months, the difference between "retrieves everything equally" and "remembers what matters, forgets what doesn't" determines whether the agent remains useful or drowns in noise.
References
- Anderson, M. C., Bjork, R. A., & Bjork, E. L. (1994). Remembering can cause forgetting. JEPLMC, 20(5), 1063-1087.
- Bartlett, F. C. (1932). Remembering. Cambridge University Press.
- Berntsen, D. (2009). Involuntary Autobiographical Memories. Cambridge University Press.
- Cepeda, N. J., et al. (2006). Distributed practice in verbal recall tasks. Review of Educational Research, 76(3), 354-380.
- Ebbinghaus, H. (1885). Über das Gedächtnis. Duncker & Humblot.
- Ghosh, V. E., & Gilboa, A. (2014). What is a memory schema? Neuropsychologia, 53, 104-114.
- Hart, J. T. (1965). Memory and the feeling-of-knowing experience. JEPLMC, 56(3), 208-216.
- Johnson, M. K., Hashtroudi, S., & Lindsay, D. S. (1993). Source monitoring. Psychological Bulletin, 114(1), 3-28.
- Nader, K., Schafe, G. E., & Le Doux, J. E. (2000). Fear memories require protein synthesis. Nature, 406, 722-726.
- Nelson, T. O., & Narens, L. (1990). Metamemory: A theoretical framework. Psychology of Learning and Motivation, 26, 125-173.
- Reyna, V. F., & Brainerd, C. J. (1995). Fuzzy-trace theory. Learning and Individual Differences, 7(1), 1-75.
- Tse, D., et al. (2007). Schemas and memory consolidation. Science, 316(5821), 76-82.
AgentOS cognitive memory is open-source (Apache 2.0). GitHub · Documentation · npm
