Skip to main content

Module memory

Module memory 

Source
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

ScopeWho can writeWho can read
GlobalSystem / adminEveryone
AgentThis agentThis agent
UserJWT-auth userSame user only
SessionAny requestSame session
TaskTaskStream APISame 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 over SurrealStorage.
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 None for migration safety.
MemoryHistory
Immutable record of a memory mutation — never deleted.

Enums§

MemoryScope
Scoping level for a memory — determines who can see and retrieve it.
MemoryType
Cognitive memory type — determines storage and retrieval behaviour.