nat-memorysync
MemorySync memory backend for the NVIDIA NeMo Agent Toolkit (nvidia-nat).
Registers a memorysync_memory client that plugs into workflow YAML as a
memory: section entry — usable from the toolkit's built-in add_memory /
get_memory tools, from the automatic auto_memory_agent wrapper, and from
any custom function that requests a memory client from the Builder.
pip install nat-memorysync
Requires Python 3.11+ (the toolkit's own floor). Installing this package pulls
nvidia-nat-core; install nvidia-nat (or the plugin subpackages you need)
for the full toolkit.
Why this instead of the in-repo editors?
The toolkit ships example editors for Mem0 and Zep. Both have sharp edges we designed against:
| Behavior | Mem0 (in-repo) | Zep (in-repo) | nat-memorysync |
|---|---|---|---|
search() without user_id |
bare KeyError |
n/a (thread-scoped) | ValueError naming the kwarg |
| Multi-user isolation with no conversation id | per-call user_id |
all users share "default_zep_thread" |
rows always keyed by item user_id — bleed impossible |
Your metadata dict after add_items |
mutated (keys popped out) | untouched | untouched (copy-first, tested) |
| Search result shape | items, scores discarded | one joined text blob | one MemoryItem per fact, similarity_score populated |
remove_items() with no kwargs |
silent no-op | deletes current thread | raises — refuses to guess |
| Delete blast radius | whole user | whole thread | session-scoped by default; whole user requires explicit scope="user" |
| Slow/down memory backend | blocks the turn | blocks the turn | 1.2 s recall budget, fail-open both directions |
| Retried writes | duplicated | duplicated | deterministic idempotency seeds — retries converge on one row |
Wiring mode 1 — explicit memory tools
The agent decides when to store and when to recall:
memory:
saas_memory:
_type: memorysync_memory # key comes from MEMORYSYNC_API_KEY env var
functions:
add_memory:
_type: add_memory
memory: saas_memory
description: Save any user preference or fact for later conversations.
get_memory:
_type: get_memory
memory: saas_memory
description: Recall previously saved user preferences and facts.
workflow:
_type: react_agent
tool_names: [add_memory, get_memory]
llm_name: my_llm
Wiring mode 2 — automatic memory (auto_memory_agent)
No tools, no prompt changes — every turn is stored and every prompt is
enriched automatically (requires nvidia-nat-langchain):
memory:
saas_memory:
_type: memorysync_memory
workflow:
_type: auto_memory_agent
augmented_fn: my_actual_workflow
memory: saas_memory
search runs inside a hard 1.2 s budget here, so automatic memory can never
stall a turn.
Builder API (Python)
from nat.builder.workflow_builder import WorkflowBuilder
from nat_memorysync import MemorySyncMemoryConfig
async with WorkflowBuilder() as builder:
await builder.add_memory_client("saas_memory", MemorySyncMemoryConfig())
editor = await builder.get_memory_client("saas_memory")
from nat.memory.models import MemoryItem
await editor.add_items([
MemoryItem(
conversation=[{"role": "user", "content": "I prefer teal dashboards"}],
user_id="customer-1",
metadata={"plan": "pro"},
)
])
items = await editor.search("dashboard preferences", top_k=5, user_id="customer-1")
for it in items:
print(it.similarity_score, it.memory)
Configuration
All fields are optional except the API key (env var or config field):
| YAML field | Default | Purpose |
|---|---|---|
api_key |
MEMORYSYNC_API_KEY env var |
API key — keep it in the env var so YAML stays credential-free |
base_url |
https://api.memorysync.io |
Override for self-hosted / staging |
project_id |
– | Optional X-Project-ID header |
top_k |
5 |
Default memories per search |
recall_timeout |
1.2 |
Hard recall budget (seconds); slow backend degrades to no memories |
min_query_chars |
8 |
Skip recall for shorter queries |
source |
nat |
Source label on stored turns |
MemoryBaseConfig + RetryMixin knobs (num_retries,
retry_on_status_codes, …) work too — retries are safe because every write
carries a deterministic idempotency seed.
Editor semantics
add_items(items)— eachMemoryItem.conversationis stored through MemorySync's extraction pipeline (facts, dedup, decay), scoped to that item'suser_id.metadatakeys ride along;metadata.ignore_rolesfilters roles out (e.g.["assistant"]stores only user turns). Items whose extraction fails are logged and skipped — a partial batch never raises mid-turn.search(query, top_k=..., user_id=...)— semantic recall, oneMemoryItemper fact withsimilarity_score.user_idis required (loudValueError, not aKeyError).remove_items(user_id=...)— deletes this adapter's session rows for the user. Addmemory_id="..."for one row, orscope="user"to wipe the user's entire memory (explicit opt-in). No kwargs →ValueError.
Session scope comes from the toolkit's Context.get().conversation_id
ContextVar when set (nat::<conversation_id>), else nat::default — but
rows are always additionally keyed by user_id, so an unset conversation id
can never mix users.
Tests
pip install -e . nvidia-nat-core langchain-core pytest pytest-asyncio "httpx>=0.25,<1"
pytest tests -q # 26 tests
The suite exercises the real WorkflowBuilder, NVIDIA's real
add_memory/get_memory tool functions driving this editor end to end, plus
named regression tests for every competitor bug in the table above.
License
MIT © MemorySync.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nat_memorysync-1.0.0.tar.gz.
File metadata
- Download URL: nat_memorysync-1.0.0.tar.gz
- Upload date:
- Size: 17.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81df17fc764d2d370a35363c9ac1b2677e783dd0a54779f751eed32885852fef
|
|
| MD5 |
03f1a83d36fc0440ca1633c1e2509907
|
|
| BLAKE2b-256 |
bcdc0ff62cdee7b611c2467be3f0bb014b656f9d3154d73ccfabe2081d2b5da3
|
File details
Details for the file nat_memorysync-1.0.0-py3-none-any.whl.
File metadata
- Download URL: nat_memorysync-1.0.0-py3-none-any.whl
- Upload date:
- Size: 13.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8474c944a5ade932488c1dfd1e69c12a922fe1321879b5b2df913d4ddb9bf587
|
|
| MD5 |
50673fa46c5a541a717c1abe36a640d1
|
|
| BLAKE2b-256 |
002d9bbe31d70ae8ffaedc27fcba5c96b26b8707d380b24dc139f3120a357e07
|