Skip to main content
Add persistent memory to a Pipecat voice pipeline as frame processors: one that injects the user’s relevant memories into the shared LLM context before each reply, and one that records each completed turn, with its tool calls, after the response and replaces a long call’s earlier turns with Synap’s compaction.
Requires Python 3.11+ and pipecat-ai 0.0.80 or later, with the universal context aggregators (LLMContext).

Overview

This guide shows how to add Synap to a Pipecat application to build voice pipelines that:
  • Inject the most relevant memories as a system message before the LLM responds
  • Record each completed user + assistant turn, and each tool call, back to Synap
  • Send the LLM Synap’s compaction in place of a long call’s earlier turns
  • Compose with any other Pipecat frame processor without changing the pipeline shape
The Synap Pipecat integration ships three frame processors and one helper. They follow Pipecat’s processor contract, so they slot into any pipeline alongside STT, LLM, and TTS. All of them work on the shared LLMContext that your aggregators use, so pass it in as context=.

Setup

Install the package alongside Pipecat. It also installs maximem-synap (0.5.3 or later) and maximem-synap-integrations-common (0.2.3 or later):
The pip package is maximem-synap-pipecat, but the import drops the maximem- prefix and uses underscores: from synap_pipecat import ....
Configure your API key. Generate one from the Synap Dashboard.
.env
Initialize the SDK once at the worker’s startup:
See SDK Initialization for the full lifecycle and configuration options.

Basic integration

The smallest useful integration shares one LLMContext between the aggregators and the Synap processors: memory injection before the user aggregator, recording after the assistant aggregator:
Memory injection failures degrade gracefully: the frame passes through unmodified if context retrieval fails. A turn that cannot be written is logged and reported as an ErrorFrame pushed upstream; it does not stop the pipeline.

Core concepts

Memory processor

SynapMemoryProcessor acts on each TranscriptionFrame. It fetches the user’s relevant memories for the transcribed text and puts them in the shared LLMContext as one system message, then passes the frame on unchanged so the user aggregator still sees it. Each turn replaces the previous memory block, so the context never accumulates stale blocks over a long call.
Without context= the processor is inert: frames pass through and nothing is injected. You can attach the context later with memory.set_context(context). The default is mode="accurate" with max_results=10. Voice latency is tight, so pass mode="fast" when the added wait before the reply matters. The two retrieval modes trade latency against comprehensiveness: fast is lower-latency and suited to the hot path; accurate adds LLM-driven query decomposition and reranking for relationship-aware queries at a higher latency cost. Failures degrade gracefully: if context retrieval fails, the frame passes through and the context is left as it was.

Recorder

SynapRecorder records the completed user and assistant turn at the end of each response. Pass the shared context=: behind the universal aggregators the user’s TranscriptionFrame never reaches the recorder, so it reads the user turn back from the context.
  • Where it sits decides what it sees. After the assistant aggregator (the standard position), the recorder gets one end-of-turn frame carrying the assistant text as stored in the context, and records both turns from that. It also reads the turn’s tool calls and results back out of the context and reports them, just before the reply they led to. Reasoning is not recoverable there. To get each tool call at the moment it is dispatched, and reasoning from models that emit it, put the recorder before the assistant aggregator, for example right after the LLM service.
  • Real-time stream. You do not call listen(). The first turn opens the stream, and the turns go out on it. If the stream cannot open, each turn is written over REST instead, never both; tool calls and reasoning exist only on the stream and are dropped in that case. Set SYNAP_AUTO_LISTEN=false to stay on REST, or open the stream yourself and the recorder uses it as is. See gRPC vs REST.
  • Failures. A turn that cannot be written is logged, and an ErrorFrame carrying a SynapIntegrationError is pushed upstream so observability hooks see it. The recorder never raises inside process_frame.
On pipecat-ai 1.7 and later the assistant aggregator lets one end-of-turn frame through, and the recorder uses it. On earlier versions the recorder ends the turn on LLMFullResponseEndFrame. Left out, conversation_id is a new random UUID for each session (0.2.3 or later; earlier versions generated an id that was not a UUID, which Synap rejected for reads and REST writes). Pass your own UUID to continue one conversation across sessions.

Compacted history

A Pipecat LLMContext only grows unless you turn on Pipecat’s own auto-summarization, which is off by default. When you pass context= to the recorder, then after it records each turn, and once Synap has compacted the conversation, it replaces every turn before the current one in the shared context with Synap’s compaction block (in <synap_conversation_history> tags) and the turns after it. The next LLM request carries that instead of every turn so far. The current turn is untouched. This runs one turn later than a fetch before each request, and off the latency path, because it happens after the turn has been recorded. Before the first compaction, or when Synap cannot answer, the context is left as the aggregators built it, and Pipecat’s own summarization, if you turned it on, stays the fallback. A voice call cannot wait on a slow read: if Synap takes longer than 1.5 seconds, the read is skipped and not tried again for 30 seconds. splice_synap_history(context, sdk, conversation_id=...) does the same replacement on demand, in place, and returns whether it changed anything.

Short-term context

SynapShortTermProcessor goes in the same position as the memory processor, before the user aggregator. On each user turn it reads Synap’s short-term context for the conversation. Once Synap has compacted the conversation, it replaces the context’s earlier turns with the compaction, as above, but before the request rather than after the previous turn. Before that, it keeps one tagged system message in the context with the turns the context does not already hold.
Without context= it is inert. On an SDK error it leaves the context untouched; pass on_error="raise" to get SynapIntegrationError instead. The read adds to the wait before each reply, so prefer the recorder’s replacement unless you need the context current on the very next request.

Positioning in the pipeline

The processors expect specific positions:
SynapMemoryProcessor must be between STT and the user aggregator, because it acts on the TranscriptionFrame the aggregator consumes. SynapRecorder goes after the assistant aggregator, or before it if you want dispatch-time tool calls and reasoning (see above).

Complete example: full voice pipeline with memory

The pattern below sets up an end-to-end voice pipeline with Synap-backed memory. Scope is pulled per-call, so the same worker can serve multiple users:
Three things to notice in this pattern:
  1. Memory injection happens once per user turn, not once per audio frame; the processor only acts on the final TranscriptionFrame.
  2. Recording is async and non-blocking. The audio path never waits on a Synap write.
  3. Scope is per-call. Each run_call invocation gets its own processor instances with the right user_id / customer_id.

Advanced patterns

Multi-tenant scoping

The memory processor and the recorder take user_id (required) and customer_id (B2B instances only); the recorder also takes an optional conversation_id, and the short-term processor requires one. customer_id is required on B2B Synap instances and not accepted on B2C (single-tenant) ones, where a call carrying it is rejected with HTTP 400. See Memory Scopes.
For multi-tenant deployments, build processors per call rather than caching them globally; each call should have its scope baked in.

Tuning retrieval mode

mode="accurate" is the default. For most voice flows pass mode="fast" to keep the wait before each reply short, and switch to "accurate" only for use cases where missing relevant memory is worse than the additional pre-LLM latency that LLM-driven query decomposition and reranking add.

Failure semantics

The integration follows the Synap-wide contract, adapted for voice latency:
  • SynapMemoryProcessor degrades gracefully: the frame passes through unmodified and the context is left alone if retrieval fails.
  • SynapRecorder reports failures as frames: a turn that cannot be written is logged and pushed upstream as an ErrorFrame carrying a SynapIntegrationError; Pipecat’s contract is frames, not raised exceptions.
  • The compacted-history replacement leaves the context alone whenever Synap has no compaction, is slow or errors.
This is by design: a voice call should never break because of a transient memory glitch, but write failures must be visible to monitoring.

Going further


Next steps

LiveKit Agents

Context preloading and recording for LiveKit voice agents.

Claude Agent SDK

Hooks and MCP server for the Claude Agent SDK.

Context Fetch

The retrieval API behind SynapMemoryProcessor: modes, scopes, and response shapes.

Memory Scopes

How user_id, customer_id, and conversation_id interact across reads.