Expand description
§Agent Memory System
Provides persistent, multi-scoped memory for UAR agents using the
surreal-memory library.
§Architecture
Request (JWT optional)
│
▼
auth_middleware → UserContext { user_id, claims }
│
├──► [pre-call] context_builder::build_context()
│ → hybrid_search over Session→User→Agent→Global
│ → inject ranked block into system prompt
│
├──► LLM Orchestrator
│
└──► [post-stream] auto_capture::capture_from_stream_end()
→ add_memories_from_conversation()§Scoping
Every ordinary operation requires a verified issuer/tenant/subject owner. Scope, agent and session identifiers only narrow that owner’s namespace. Shared knowledge graph and global administration require trusted host proof. Legacy records remain in the unsuffixed database until explicitly mapped.
§MCP Exposure
All memory capabilities are exposed as MCP tools via [mcp_server::MemoryMcpServer].
The server is registered as a native tool with crate::mcp::registry::McpRegistry
and optionally as an HTTP endpoint at /mcp/memory.
Re-exports§
pub use service::MemoryService;
Modules§
- auto_
capture - Post-stream auto-capture of memories from conversation turns.
- background
- Event-driven background work for the memory system.
- context_
builder - Pre-prompt memory context builder.
- controls
- Owner consent and deletion authority. No content is stored in control records.
- mcp_
server - In-process memory MCP server for the UAR agent runtime.
- migration
- Explicit, evidence-backed import from the quarantined legacy database.
- owned
- Host-bound memory access. Payload fields can narrow a query, never grant ownership.
- scopes
- Scope resolution logic for the agent memory system.
- service
MemoryService— the primary facade overSurrealStorage.- workflow_
mirror - Workflow-state mirror helpers for KBD/OpenSpec records.
Structs§
- Memory
- A single memory unit — the core data structure for the mem0-compatible layer.
All optional fields default to
Nonefor migration safety. - Memory
History - Immutable record of a memory mutation — never deleted.
Enums§
- Memory
Scope - Scoping level for a memory — determines who can see and retrieve it.
- Memory
Type - Cognitive memory type — determines storage and retrieval behaviour.