Research Foundations
Academic papers and design influences that shaped the AI Assistant architecture.
Core Influences
Generative Agents (Park et al., 2023)
Paper: "Generative Agents: Interactive Simulacra of Human Behavior" Authors: Joon Sung Park, Joseph C. O'Brien, Carrie J. Cai, Meredith Ringel Morris, Percy Liang, Michael S. Bernstein Link: https://arxiv.org/abs/2304.03442
Key Concepts Adopted
-
Reflection System
- Cumulative importance threshold (default: 150)
- Automatic reflection during sleep/dreaming phase
- Insight generation from recent experiences
- Implementation:
generative_reflection.py:run_reflection()
-
Importance Scoring
- Heuristic scoring with LLM upgrade during sleep
- Keyword-based initial scores
- Batch LLM scoring in
score_pending_entries() - Implementation:
importance_scoring.py
-
Episodic Memory Pruning
- Age + importance based pruning
- Default: prune entries with importance ≤ 3, older than 30 days
- Preserves consolidated entries
- Implementation:
helpers/episodic_index.py:prune_low_importance_entries()
-
Memory Retrieval
- Hybrid scoring: recency + importance + relevance
- Time decay for recency weighting
- Implementation:
helpers/episodic_index.py:search_episodic_memory()
O-Mem: Observation Memory (Zhang et al., 2024)
Paper: "O-MEM: Observation Memory for Continual Learning in Streaming Data" Concept: Separating raw observations (Pf) from consolidated attributes (Pa)
Key Concepts Adopted
-
Entity Profiles Structure
entity_profiles[entity_id] = { "observations": [...], # Pf - raw experiences "attributes": {...}, # Pa - consolidated knowledge "relationship": {...} # Derived from observations } -
Observation → Attribute Consolidation
- LLM synthesizes multiple observations into stable attributes
- Runs during sleep/dreaming phase
- Min 5 observations before consolidation
- Implementation:
helpers/entity_context.py:run_entity_consolidation_batch()
-
Dunbar Relationship Thresholds
State Favorability Range stranger < 0.25 acquaintance 0.25 - 0.50 friend 0.50 - 0.75 ally ≥ 0.75
A-MEM: Agentic Memory (2024)
Concept: Memory link generation for associative recall
Key Concepts Adopted
-
Memory Links
- Semantic connections between related memories
- Generated during dreaming phase
- Links stored in
character.db.memory_links - Implementation:
sleep/dreaming.py:run_dreaming_tick()
-
Orphaned Link Cleanup
- Removes links to deleted memories
- Prevents unbounded growth
- Implementation:
sleep/dreaming.py:prune_orphaned_memory_links()
ReAct Pattern (Yao et al., 2022)
Paper: "ReAct: Synergizing Reasoning and Acting in Language Models" Authors: Shunyu Yao, Jeffrey Zhao, Dian Yu, Nan Du, Izhak Shafran, Karthik Narasimhan, Yuan Cao Link: https://arxiv.org/abs/2210.03629
Key Concepts Adopted
-
Reasoning + Acting Loop
- LLM reasons about task, then selects action
- Iterates until terminal condition
- Implementation:
tool_execution.py:execute_react_loop()
-
Multi-Action Execution
- Chain multiple tool calls in single tick
- Termination conditions: TERMINAL tool, DANGEROUS tool, noop, max iterations
- Implementation: See Data-Flow-02-ReAct-Loop
Design Patterns
Three-Layer Execution Pattern
Original design for restrictive composition:
Layer 1 (Static Config) ⊇ Layer 2 (Context Config) ⊇ Layer 3 (LLM Assessment)
Each layer can only restrict, never expand limits set by higher layers.
Influences:
- Unix permission inheritance
- Kubernetes RBAC
- Principle of least privilege
Sleep/Wake Cycle
Biological inspiration combined with computer science concepts:
-
Sleep Phases
- Compacting (memory consolidation) → Dreaming (reflection, cleanup)
- Inspired by human REM/non-REM cycles
-
Light vs Deep Sleep
- Light: wake on urgent events (interrupts)
- Deep: timer-only wake (batch processing)
-
Cooldown Period
- Prevents rapid cycling
- Inspired by circuit breaker patterns
Tool Categories
Security-influenced design for tool safety:
| Category | Behavior | Rationale |
|---|---|---|
SAFE_CHAIN |
Chain freely | Information gathering, no side effects |
TERMINAL |
Ends loop | Awaits human response, prevents overtalking |
DANGEROUS |
Single per tick | State modification requires deliberation |
ASYNC_REQUIRED |
Special handling | Network calls need timeout management |
Token Advisory System
Graceful degradation pattern for context limits:
| Level | Threshold | Action |
|---|---|---|
| MODERATE | 50-70% | Suggest wrapping up |
| HIGH | 70-80% | Complete current task |
| CRITICAL | 80%+ | Force termination |
Influences:
- Disk space warnings
- Memory pressure handlers
- Garbage collection triggers
Academic Context
Relevant Fields
-
Human-Computer Interaction (HCI)
- Generative Agents work from Stanford HCI Group
- Focus on believable, interactive AI characters
-
Cognitive Architecture
- Working memory, long-term memory separation
- Episodic vs semantic memory distinction
-
Multi-Agent Systems
- Sub-agent delegation patterns
- Principal-delegate relationships
-
Software Architecture
- Event sourcing for auditability
- Circuit breaker for resilience
- Mixin patterns for modularity
Implementation Mapping
| Research Concept | Implementation File | Key Function/Class |
|---|---|---|
| Generative reflection | generative_reflection.py |
run_reflection() |
| Importance scoring | importance_scoring.py |
score_pending_entries() |
| Entity profiles | helpers/entity_profiles.py |
create_entity_profile() |
| Observation consolidation | helpers/entity_context.py |
run_entity_consolidation_batch() |
| Episodic pruning | helpers/episodic_index.py |
prune_low_importance_entries() |
| Hybrid memory search | helpers/episodic_index.py |
search_episodic_memory() |
| Memory links | sleep/dreaming.py |
run_dreaming_tick() |
| ReAct loop | tool_execution.py |
execute_react_loop() |
| Sleep phases | operating_mode.py |
transition_mode() |
| Sleep tick orchestration | sleep/__init__.py |
run_sleep_tick() |
| Context compaction | sleep/compaction.py |
compact_conversation_history() |
| Memory consolidation | sleep/consolidation.py |
run_sleep_consolidation() |
| Tool categories | tools/base.py |
ToolCategory enum |
Further Reading
Papers
- Park et al. (2023) - Generative Agents arXiv:2304.03442
- Yao et al. (2022) - ReAct arXiv:2210.03629
- Wei et al. (2022) - Chain of Thought arXiv:2201.11903
Books
- Kahneman, D. (2011) - Thinking, Fast and Slow (dual-process theory)
- Dunbar, R. (1998) - Grooming, Gossip, and the Evolution of Language (relationship limits)
Technical
- OpenAI Function Calling Documentation
- Anthropic Claude Tool Use Documentation
- Mem0 Project Documentation
Last updated: 2025-12-09