Overview
Entity memory organizes agent knowledge around entities: people, places, organizations, projects, and concepts. Rather than storing isolated facts, this architecture builds a knowledge graph of entities and their relationships, enabling rich contextual understanding.
Entity Types
People
Information about individuals:
Organizations
Companies, groups, institutions:
Projects
Work or personal endeavors:
Concepts
Abstract topics and themes:
Entity Schema
Entity:
├── id: unique identifier
├── type: person | organization | project | concept
├── name: primary name
├── aliases: alternative names
├── attributes: key-value facts
│ ├── [attribute_name]: value
│ └── ...
├── relationships: connections to other entities
│ ├── [relationship_type]: entity_id[]
│ └── ...
├── mentions: interaction history
│ ├── first_mentioned: timestamp
│ ├── last_mentioned: timestamp
│ ├── mention_count: number
│ └── contexts: session_id[]
├── embedding: vector for semantic search
└── updated_at: timestamp
Architecture
┌─────────────────────────────────────────────────────────────┐
│ Conversation │
│ "I had lunch with Sarah from Acme Corp about the Q4 deal" │
└──────────────────────────┬──────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ Entity Extraction │
│ ├── Sarah (person) │
│ ├── Acme Corp (organization) │
│ └── Q4 deal (project) │
└──────────────────────────┬──────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ Entity Resolution │
│ ├── Sarah → existing entity #123 (Sarah Chen) │
│ ├── Acme Corp → existing entity #456 │
│ └── Q4 deal → new entity created │
└──────────────────────────┬──────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ Entity Update │
│ ├── Sarah: add relationship to Acme Corp │
│ ├── Sarah: update last_mentioned │
│ ├── Acme Corp: add relationship to Q4 deal │
│ └── Q4 deal: create with Sarah, Acme relationships │
└──────────────────────────┬──────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ Entity Store │
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
│ │ Sarah │────▶│ Acme │────▶│ Q4 Deal │ │
│ │ (person)│ │ Corp │ │(project)│ │
│ └─────────┘ └─────────┘ └─────────┘ │
└─────────────────────────────────────────────────────────────┘
Entity Extraction
From Conversations
Use NLP to identify entities:
Input: "Meeting with John about the website redesign tomorrow"
Extraction:
Extraction Prompt
Extract entities from this text:
[TEXT]
For each entity, provide:
Return as JSON array.
Entity Resolution
The Challenge
Same entity, different references:
Resolution Strategy
5. **Recency match**: Recently mentioned similar entity
Disambiguation
When uncertain:
Relationship Types
Person-to-Person
Person-to-Organization
Entity-to-Project
General
Retrieval Patterns
Entity Lookup
When entity is mentioned:
User: "What do you know about Sarah?"
Lookup:
5. Get recent mentions
Contextual Retrieval
For relevant context:
User: "Schedule a meeting about the website"
Retrieval:
Graph Traversal
For complex queries:
User: "Who at Acme Corp have I worked with?"
Query:
Storage Options
Document Store + Index
Simple approach:
Graph Database
For complex relationships:
Hybrid
Best of both:
Maintenance
Merging Duplicates
When duplicates are detected:
Pruning Stale Entities
Over time: