Give LlamaIndex chat engines and RAG pipelines persistent memory backed by Synap. Conversations survive restarts, and Synap-stored memories sit alongside your document retrieval as first-class context.Documentation Index
Fetch the complete documentation index at: https://docs.maximem.ai/llms.txt
Use this file to discover all available pages before exploring further.
Overview
This guide shows how to add Synap to a LlamaIndex application to build pipelines that:- Maintain chat history across sessions and processes
- Retrieve user-scoped memories alongside document chunks in a RAG flow
- Fuse memory-based and document-based retrieval into a single ranked result set
| Component | LlamaIndex interface | Purpose |
|---|---|---|
SynapChatMemory | BaseMemory | Persistent chat history per conversation_id |
SynapRetriever | BaseRetriever | Returns NodeWithScore objects for RAG pipelines |
Setup
Install the package alongside LlamaIndex:.env
Basic integration
The smallest useful integration plugsSynapChatMemory into any LlamaIndex chat engine. Past turns are loaded automatically on each call, and new turns are persisted on the way out:
SynapChatMemory loads prior messages on get() and writes new turns back to Synap on put(). Failed reads return an empty buffer and log an error; failed writes surface explicitly so callers know if persistence failed.
To make user-specific memories retrievable inside the chat engine (alongside or in place of documents), layer in SynapRetriever below.
Core concepts
Persistent chat memory
SynapChatMemory implements BaseMemory. Every LlamaIndex chat engine accepts a memory object — drop this one in to make the conversation durable:
conversation_id maps one-to-one to a Synap conversation. Restart your process, instantiate SynapChatMemory again with the same conversation_id, and the chat engine resumes with the prior history.
Semantic retrieval
SynapRetriever implements BaseRetriever and returns NodeWithScore objects — the same shape every LlamaIndex RAG component expects. Use it as the retriever of a RetrieverQueryEngine, or as a sub-retriever inside a RouterRetriever / QueryFusionRetriever:
fast | accurate | |
|---|---|---|
| Latency | 50-100ms | 200-500ms |
| Search | Vector similarity | Vector + graph + re-ranking |
| Best for | Real-time chat | Multi-entity queries |
Complete example: support assistant with memory + docs
The following pipeline gives a chat engine both Synap-backed conversation memory and a fused retriever that blends user-specific memories with document chunks:SynapChatMemoryis constructed per-conversation so multiple sessions can run side-by-side without interfering.SynapRetrieveris fused with the document retriever viaQueryFusionRetriever, so user-specific facts and corpus documents come back as one ranked list.- Memory and retrieval are independent — drop either and the pipeline still works; together they cover both the “what did we say” and “what do I know about this user” axes.
Advanced patterns
Multi-tenant scoping
Both components accept the same 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.
Tuning retrieval mode per query
SynapRetriever takes a default mode at construction, but you can swap it temporarily for a single high-recall lookup:
Composing with other retrievers
SynapRetriever is a regular BaseRetriever, so it composes cleanly with LlamaIndex’s RouterRetriever, QueryFusionRetriever, or any custom retriever you build. Combine it with a document retriever (as in the example above), or route between Synap memories and a vector store based on the query.
Failure semantics
The integration follows the Synap-wide contract:- Retrieval failures degrade gracefully —
SynapRetriever.aretrievereturns[]and logs an error - Memory reads degrade gracefully —
SynapChatMemory.getreturns an empty buffer and logs an error - Memory writes surface failures —
SynapChatMemory.putraisesSynapIntegrationErrorso callers know persistence failed
Next steps
LangChain
Memory, retriever, and tools for LangChain chains and agents.
Haystack
Retriever and memory-writer pipeline components for Haystack.
Context Fetch
The retrieval API that powers
SynapRetriever — modes, scopes, and response shapes.Memory Scopes
How
user_id, customer_id, and conversation_id interact across retrievals.