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
| Scope | Who can write | Who can read |
|---|---|---|
| Global | System / admin | Everyone |
| Agent | This agent | This agent |
| User | JWT-auth user | Same user only |
| Session | Any request | Same session |
| Task | TaskStream API | Same task |
§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
- Background workers for the memory system.
- context_
builder - Pre-prompt memory context builder.
- mcp_
server - In-process memory MCP server for the UAR agent runtime.
- 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.