Skip to main content
Plug Synap into NVIDIA NeMo Agent Toolkit (NAT) as a first-class MemoryEditor. NAT workflows that declare a memory backend in YAML (or instantiate one programmatically) now get persistent, semantically searchable, per-user memory.
Requires Python 3.11+.

Overview

This guide shows how to add Synap to a NAT workflow to build pipelines that:
  • Persist MemoryItem objects across workflow executions
  • Retrieve memories via semantic search inside any NAT step
  • Be declared in NAT’s YAML config without writing additional integration code
The Synap NAT integration ships three exports: the editor itself, a registration decorator, and a one-shot factory.

Setup

Install the package alongside NAT:
The pip package is maximem-synap-nemo-agent-toolkit, but the import drops the maximem- prefix and uses underscores: from synap_nemo_agent_toolkit import ....
Configure your API key. Generate one from the Synap Dashboard.
.env
Initialize the SDK once at application startup:
Alternatively, use the synap_memory_client factory below to skip the SDK setup; it initializes Synap internally. See SDK Initialization for the full lifecycle and configuration options.

Basic integration

The smallest useful integration constructs a SynapMemoryEditor and uses it directly:
Notice that user_id is supplied per item and per query: a single SynapMemoryEditor instance serves all users in the workflow. customer_id is set once at construction.

Core concepts

MemoryEditor interface

SynapMemoryEditor implements the full MemoryEditor protocol. NAT workflows that accept a MemoryEditor work without modification:
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. Reads degrade gracefully: search and get_items return empty results and log an error on Synap outages. Writes surface failures: add_items and update_items raise SynapIntegrationError so workflows know if persistence failed.

Registration for YAML configs

NAT lets you declare memory backends in YAML. Use @register_memory to make SynapMemoryEditor resolvable by name:
After registration, reference it in any NAT workflow config:
NAT resolves type: synap to the registered class and instantiates it with the config block.

Factory function

For programmatic setups outside YAML, synap_memory_client builds a ready-to-use editor and initializes the SDK internally, with no separate lifecycle to manage:
Use this when you want a single function call to produce a configured editor; especially useful in scripts and notebooks.

Complete example: NAT workflow with persistent memory

The pattern below sets up a workflow with Synap-backed memory at startup, ingests a batch of memories, and runs a recall query:
Three things to notice in this pattern:
  1. One editor, many users. user_id travels on each MemoryItem and each search call, so the editor is shared.
  2. customer_id is the tenant boundary. All users sharing an editor are inside the same customer_id, so build a separate editor per tenant for multi-tenant services.
  3. Mode is fixed at construction. Set mode="fast" for low-latency NAT steps; "accurate" for higher-recall lookups.

Advanced patterns

Multi-tenant scoping

SynapMemoryEditor takes customer_id at construction; user_id is supplied per call. customer_id is required on B2B Synap instances and ignored on single-tenant ones. See Memory Scopes.

Choosing between SDK-managed and factory-managed lifecycles

  • Use SynapMemoryEditor(sdk=...) when your application owns the SDK lifecycle (recommended for production, since you control init/shutdown).
  • Use synap_memory_client(api_key=...) for scripts, notebooks, or YAML-driven workflows where you’d rather not manage the SDK explicitly.

Failure semantics

The integration follows the Synap-wide contract:
  • search and get_items degrade gracefully: return empty lists and log an error if Synap is unreachable.
  • add_items and update_items surface failures: raise SynapIntegrationError so the workflow and caller know persistence failed.
This is by design: read failures shouldn’t break a workflow step mid-flight, but silent write failures would corrupt the memory pool.

Going further


Next steps

Semantic Kernel

Plugin for Microsoft Semantic Kernel.

Pydantic AI

Type-safe deps and tools for Pydantic AI.

Memory Scopes

How user_id and customer_id interact across reads and writes.

Ingestion

Direct ingestion API for pipelines that need finer control than add_items.