Skip to main content
Make LangGraph state graphs durable and aware of long-term context. Synap stores thread checkpoints so conversations survive restarts, and exposes a cross-thread BaseStore that any graph node can read and write.
Requires Python 3.11+.

Overview

This guide shows how to plug Synap into a LangGraph application to build graphs that:
  • Persist their thread state across processes and restarts
  • Resume any conversation by its thread_id without losing context
  • Share long-term memory (user preferences, facts, episodes) across all threads belonging to the same user
The Synap LangGraph integration ships two drop-in components. Each one implements a native LangGraph interface, so you do not have to wrap or re-implement anything.

Setup

Install the package alongside LangGraph:
The pip package is maximem-synap-langgraph, but the import drops the maximem- prefix and uses underscores: from synap_langgraph import ....
Configure your API key. Generate one from the Synap Dashboard.
.env
Initialize the SDK once at application startup:
See SDK Initialization for the full lifecycle and configuration options.

Basic integration

The smallest useful integration replaces LangGraph’s in-memory checkpointer with SynapCheckpointSaver. Compile your graph with the saver, then invoke it as usual: every node transition is persisted, and the next invocation with the same thread_id resumes from the last checkpoint:
Restart your process, call ainvoke again with the same thread_id, and the graph picks up where it left off. Checkpoint retrieval failures degrade gracefully. The graph starts from an empty state and the error is logged. This covers per-thread durability. To give your graph access to memories outside a single thread, layer in SynapStore below.

Core concepts

Thread checkpoints

SynapCheckpointSaver implements LangGraph’s BaseCheckpointSaver interface. Every state transition the graph commits is sent to Synap and tagged with the active thread_id:
Each thread_id you pass through config.configurable.thread_id maps one-to-one to a Synap conversation. Replaying a thread is just another ainvoke with the same thread_id: Synap returns the stored checkpoint and LangGraph rehydrates state from it. In addition to exact-thread replay, the saver supports fuzzy retrieval: when no checkpoint exists for a thread_id, Synap can return the closest semantically-similar thread for the user. This is useful for “continue where I left off”-style flows that do not pin a thread ID up front.

Cross-thread memory

SynapStore implements BaseStore and gives every node in the graph access to long-term memory that spans all of the user’s threads:
Inside a graph node, access the store through the store keyword argument that LangGraph injects:
The namespace tuple (("user", "alice") above) scopes reads and writes to a particular memory partition. Use ("user", user_id) for per-user memory and ("customer", customer_id) for tenant-wide memory. Read Memory Scopes for the full hierarchy.

Complete example: agent that remembers across threads

The following graph wires both components together. Each thread is durable on its own, and the assistant can recall facts from earlier conversations the same user had under a different thread_id:
Three things to notice in this pattern:
  1. SynapCheckpointSaver lets the graph resume mid-conversation by thread_id, even after a restart.
  2. SynapStore is read in recall and written in remember, so each thread enriches a shared user-level memory pool.
  3. Memory and thread state are independent. You can drop the store and keep just the checkpointer (or vice versa) and the graph still works.

Advanced patterns

Multi-tenant scoping

Both components accept the same scoping triple (user_id, optional customer_id, optional conversation_id) and namespace store entries with tuples like ("user", user_id) or ("customer", customer_id). customer_id is required on B2B Synap instances and ignored on single-tenant ones. See Memory Scopes.

Streaming with persistence

The checkpointer is fully compatible with astream, so token-by-token streaming and durable state are not mutually exclusive:
Each emitted event corresponds to a node transition that is also persisted by SynapCheckpointSaver.

Failure semantics

SynapCheckpointSaver and SynapStore follow the Synap integration contract:
  • Read failures degrade gracefully: aget, asearch, and checkpoint loads return empty results and log an error, so the graph keeps running.
  • Write failures surface explicitly: aput and checkpoint commits raise SynapIntegrationError so callers know if persistence failed.
This is by design: a transient outage should never break a user-facing turn, but a silent checkpoint loss would be invisible and dangerous.

Going further


Next steps

LangChain

Memory, retriever, and tools for LangChain chains and agents.

Memory Scopes

How user_id, customer_id, and namespaces interact across stores.

Context Fetch

The retrieval API that powers SynapStore.asearch.

Ingestion

Direct ingestion API for pipelines that need finer control than the store.