Add persistent, per-user memory to a Haystack pipeline as two regular components: a retriever for the read side and a writer for the write side. Both drop into existing pipelines without restructuring.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 Haystack application to build pipelines that:- Retrieve user-scoped memories as standard
Documentobjects in a RAG flow - Persist each conversation turn back to Synap so future runs benefit from it
- Compose freely with any other Haystack component (rerankers, prompt builders, generators)
| Component | Role | Purpose |
|---|---|---|
SynapRetriever | Read | Fetches Synap memories as Document objects |
SynapMemoryWriter | Write | Records conversation turns back to Synap |
Setup
Install the package alongside Haystack:.env
Basic integration
The smallest useful integration plugsSynapRetriever into a pipeline and routes its documents output to a prompt builder:
SynapRetriever emits an empty documents list and logs an error, so the rest of the pipeline keeps running.
To close the loop and persist new turns for future retrievals, add SynapMemoryWriter after the generator.
Core concepts
Retriever
SynapRetriever is a Haystack component that takes a query input and emits a documents output. Each returned Document has:
content— the memory textmeta["type"]— memory type (e.g."fact","preference")meta["confidence"]— relevance score
fast | accurate | |
|---|---|---|
| Latency | 50-100ms | 200-500ms |
| Search | Vector similarity | Vector + graph + re-ranking |
| Best for | Real-time chat | Multi-entity queries |
Document, you can route it through any reranker, prompt builder, or filter that accepts documents.
Memory writer
SynapMemoryWriter is the write side. Place it at the end of a pipeline so each LLM reply is captured as a memory for future retrievals:
replies input (matching the output of standard generators like OpenAIGenerator) and emits a result summary. Write failures surface explicitly — SynapMemoryWriter raises SynapIntegrationError so the pipeline knows if persistence failed.
Complete example: full RAG pipeline with memory loop
The following pipeline retrieves user-scoped memories, builds a prompt, generates a response, and writes the response back to Synap — in one pass:- Memory is just another retriever.
SynapRetrieveremits standardDocumentobjects, so you can mix it with any document store retriever via aDocumentJoinerif you want corpus context too. - The write loop closes itself. Each pipeline run ends by persisting the reply — every subsequent run benefits from accumulating context.
- Scope is bound at construction. The retriever and writer carry the user/customer scope; the pipeline graph never needs to know about user identity.
Advanced patterns
Multi-tenant scoping
Both components 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.
Combining with document retrieval
SynapRetriever’s output is a standard Document list, so it slots into a DocumentJoiner next to your existing document store retriever:
Failure semantics
The integration follows the Synap-wide contract:SynapRetrieverdegrades gracefully — emits an emptydocumentslist and logs an error if Synap is unreachable.SynapMemoryWritersurfaces failures — raisesSynapIntegrationErrorso the pipeline (and caller) know persistence failed.
Next steps
LangChain
Memory and retriever for LangChain.
LlamaIndex
BaseMemory and retriever for LlamaIndex.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 reads.