System Overview¶
Sonality runs on one memory architecture only:
Neo4jfor graph structure (episodes, derivatives, topics, segments, beliefs)PostgreSQL + pgvectorfor semantic/vector retrieval- one OpenAI-compatible provider for both chat and embeddings
Legacy Chroma/EpisodeStore flow is removed from runtime.
Runtime Loop¶
SonalityAgent.respond() orchestrates:
- Route and retrieve memory context (vector + graph + semantic features)
- Build markdown system prompt
- Generate response via provider chat completion
- Run ESS classification
- Store episode in dual store (atomic graph write, then pgvector write with rollback)
- Update beliefs/insights, run optional reflection, persist sponge state
Core Components¶
sonality/agent.py- orchestration and lifecyclesonality/provider.py- OpenAI-compatible chat/embedding transportsonality/memory/dual_store.py- dual-store write + consistency checkssonality/memory/graph.py- graph operations and traversalsonality/memory/semantic_features.py- background semantic feature ingestionsonality/memory/sponge.py- personality state, staged updates, persistence
Retrieval Model¶
Query routing is LLM-first (QueryRouter) and supports:
TEMPORAL/AGGREGATION->ChainOfQueryAgentMULTI_ENTITY->SplitQueryAgentBELIEF_QUERY-> belief-edge traversal + topic traversal + vector retrieval- other categories -> vector retrieval + topic traversal
All paths can use listwise reranking. Semantic feature lookup is included when the
router sets semantic_memory="SEARCH".
Reflection and Health¶
Reflection is periodic or event-driven. It performs:
- LLM-guided belief decay decisions
- entrenchment detection
- optional segment consolidation and forgetting passes
- snapshot rewrite with validation guardrails
Health diagnostics are logged every interaction, with reflection-level checks for coherence and consistency.