Authors: Park, O'Brien, Cai, et al. (Stanford)
Generative Agents introduces believable simulacra of human behavior by combining LLMs with a comprehensive memory and reflection architecture. The key innovation is a retrieval algorithm that balances recency, importance, and relevance to determine which memories should influence agent behavior.
Awareness uses the Generative Agents formula directly:
```
Score = α₁ × Recency + α₂ × Importance + α₃ × Relevance
```
- Exponential decay: `decay_factor ^ hours_since_access`
- Default decay: 0.995 per hour
- Recent memories naturally score higher
- LLM scores each memory 1-10 on creation
- "On a scale of 1-10, how important is this information?"
- Normalized to 0-1 range for scoring
- Cosine similarity of embeddings
- Current query vs. stored memory
- Semantic matching ensures topical relevance
- Default: 1.0 for each factor (equal weighting)
- Tunable based on use case
- Can emphasize recency or importance as needed
// Generative Agents scoring in Awareness
function calculateRetrievalScore(
memory: Memory,
query: string,
currentTime: Date
): number {
const hoursSinceAccess =
(currentTime - memory.lastAccessedAt) / (1000 * 60 * 60);
const recency = Math.pow(0.995, hoursSinceAccess);
const importance = memory.importanceScore / 10; // Normalize to 0-1
const relevance = cosineSimilarity(
memory.embedding,
embedQuery(query)
);
return (
RECENCY_WEIGHT * recency +
IMPORTANCE_WEIGHT * importance +
RELEVANCE_WEIGHT * relevance
);
}Foundational algorithm for scoring recency, importance, and relevance in memory retrieval
Virtual context management, heartbeat mechanism, OS-inspired memory paging
Cognitive architecture framework with 4 memory types (working, episodic, semantic, procedural)
Two-phase memory pipeline, conflict resolution (ADD/UPDATE/DELETE/NOOP), graph-enhanced variant