Give a LiveKit voice agent long-term memory across calls. Synap preloads the user’s history into theDocumentation Index
Fetch the complete documentation index at: https://docs.maximem.ai/llms.txt
Use this file to discover all available pages before exploring further.
ChatContext before the first turn, records every committed turn during the session, and exposes search/store function tools the LLM can call mid-conversation.
Overview
This guide shows how to add Synap to a LiveKit Agents application to build voice agents that:- Start every call already aware of the user’s history — no warm-up turn needed
- Record every committed turn back to Synap so memory grows with each call
- Search and store memories mid-conversation when the model decides it’s relevant
| Export | Role | Purpose |
|---|---|---|
preload_synap_context | Lifecycle (start) | Injects long-term memory into a ChatContext before the session begins |
attach_synap_recording | Lifecycle (during) | Records every committed turn back to Synap |
synap_search_tool | Function tool | LLM-callable memory search |
synap_store_tool | Function tool | LLM-callable memory storage |
Setup
Install the package alongside LiveKit Agents:.env
Basic integration
The smallest useful integration preloads memory before the session starts and attaches recording during it. The agent now opens with knowledge of the user’s history and grows its memory with every committed turn:Core concepts
preload_synap_context
Loads the user’s long-term memories as system messages in theChatContext before the session starts. This gives the LLM awareness of the user’s history from the very first turn, with no tool call needed.
mode="fast" is the default. Failures degrade gracefully — the session starts with empty context rather than raising.
attach_synap_recording
Subscribes to theAgentSession’s turn-commit events and ingests each committed turn asynchronously. Returns the conversation_id for the session (auto-generated if you don’t pass one):
Function tools
For mid-conversation lookups or saves, expose the search and store tools to the LLM. They are@llm.ai_callable-decorated functions, so the LiveKit LLM bridge picks them up as function calls automatically:
query / content parameters, never user_id.
Complete example: voice agent with full memory loop
The pattern below assembles all four exports into a single entrypoint. The agent preloads context, records turns, and can search or store memories mid-call:- Preload + record + tools form the loop. Preload reads memory in, record writes turns out, and tools let the model do explicit lookups in between.
- Scope is per-call.
user_idandcustomer_idare pulled from room metadata, so each call has its own memory scope without any global state. - Failure modes are voice-friendly. Memory operations never block the audio path; they degrade or retry silently so the caller hears no glitch.
Advanced patterns
Multi-tenant scoping
All four exports accept the standard scoping triple —user_id (required), optional customer_id, optional conversation_id. customer_id is required on B2B Synap instances and ignored on single-tenant ones. See Memory Scopes.
user_id / customer_id from room metadata or JWT claims at entrypoint time — never hardcode them.
Choosing preload vs. tools
- Preload only — the LLM sees the most relevant memories from turn one. Best when memory is small and you want zero per-turn latency overhead.
- Tools only — the LLM searches on demand. Best when memory is large and only a few queries need recall.
- Both — production setups where the opening greeting can reference long-term context AND the model can dig deeper mid-call.
Failure semantics
The integration follows the Synap-wide contract, adapted for voice latency:preload_synap_contextdegrades gracefully — empty context on failure, error logged.attach_synap_recordingretries internally — individual turn write failures are retried; persistent failures log but don’t crash the call.synap_search_tooldegrades gracefully — returns[]and logs on failure.synap_store_toolsurfaces failures — raisesSynapIntegrationErrorso the model (and you) know if persistence failed.
Next steps
Pipecat
Frame processors for Pipecat voice pipelines.
Claude Agent SDK
Hooks and MCP server for the Claude Agent SDK.
Context Fetch
The retrieval API behind
preload_synap_context and synap_search_tool.Memory Scopes
How
user_id, customer_id, and conversation_id interact across reads.