Skip to main content

agno-memorysync

MemorySync memory backend for Agno agents.

A memory-only db for Agno's MemoryManager: user memories live in MemorySync (persistent, semantic, cross-framework) while sessions and other agent state stay in your local db. Ships a sync MemorySyncDb and an async-native AsyncMemorySyncDb twin.

pip install agno-memorysync

Quickstart

from agno.agent import Agent
from agno.db.sqlite import SqliteDb
from agno.memory import MemoryManager
from agno_memorysync import MemorySyncDb

agent = Agent(
    db=SqliteDb(db_file="agent.db"),                  # sessions: local
    memory_manager=MemoryManager(db=MemorySyncDb()),  # memories: MemorySync
    update_memory_on_run=True,   # extract + store memories after every run
    user_id="customer-42",
)
agent.run("I prefer teal dashboards and window seats")
agent.run("Which color should the new chart use?")   # remembers

The API key comes from the MEMORYSYNC_API_KEY environment variable (or MemorySyncDb(api_key=...)). add_memories_to_context auto-enables when a memory manager is set, so recalled memories are injected into context on every run.

Why this instead of the Mem0 toolkit?

Agno's ecosystem has one other memory SaaS: the Mem0Tools toolkit shipped in agno core, plus a cookbook. Verified against their source:

Behavior Mem0 (Mem0Tools + cookbook) agno-memorysync
Integration depth LLM tools — the model must decide to recall native MemoryManager backend — automatic extraction + injection
Async agents ✗ sync client blocks the event loop sync db with bounded budget + a true AsyncBaseDb twin
Missing user id returns error strings as tool output deterministic default namespace, never cross-user
Retries / re-runs cookbook: "comment out this line after running once" deterministic idempotency seeds — retries converge
Memory snapshot cookbook injects a static snapshot fetched at construction fresh recall every run
Agent scoping search/get_all ignore agent_id agent_id / team_id stored and filterable
Semantic search real vector search via search_content (agno itself has only last_n / first_n / an extra LLM round-trip)
Whole-store wipe clear_memories() refuses; per-user wipe is explicit

The memory-only contract

BaseDb covers sessions, evals, knowledge, metrics, and traces too. MemorySyncDb implements every memory method for real and makes every other surface raise MemorySyncMemoryOnlyError with the fix in the message — a backend that silently pretended to store sessions would lose them.

Agent(
    db=SqliteDb(...),                                # sessions, evals, ...
    memory_manager=MemoryManager(db=MemorySyncDb())  # memories only
)

Semantic recall

db = MemorySyncDb()
memories = db.get_user_memories(
    user_id="customer-42",
    search_content="what does the user like to eat?",  # real vector search
    limit=5,
)

Agno's built-in search_user_memories offers last_n, first_n, and agentic (an extra LLM call that reads all memories). search_content here is served by MemorySync's vector index — no LLM round-trip, ranked by similarity.

Async agents

from agno_memorysync import AsyncMemorySyncDb

manager = MemoryManager(db=AsyncMemorySyncDb())
# MemoryManager awaits AsyncBaseDb natively on Agent.arun paths.

Delete semantics — designed against data loss

Call What happens
delete_user_memory(id, user_id=...) deletes that row; already-gone id is an idempotent no-op; a FAILED delete raises
delete_user_memories([ids], user_id=...) bulk variant
clear_memories() always raises — a nullary everything-wipe is how accounts get destroyed
forget_user_memories(user_id) the explicit, scoped, loud per-user wipe

Failure policy

  • Reads fail open under a hard budget (recall_timeout, default 1.2 s): a slow or down memory service degrades to no memories, never a stalled or crashed turn.
  • Writes fail open by default (fail_open_writes=True): post-run extraction never turns a successful agent run into a failure. The failure is logged loudly and the call returns None — an honest contract value. Set fail_open_writes=False to raise instead.
  • Deletes are never fail-open. A delete that did not happen raises.

Configuration

Parameter Default Meaning
api_key MEMORYSYNC_API_KEY env var API key
base_url https://api.memorysync.io Override for staging
project_id Optional X-Project-ID header
tenant_id auto-discovered Skip discovery
default_user_id "default" Namespace when agno passes user_id=None
recall_timeout 1.2 Hard read budget (seconds)
fail_open_writes True Post-run extraction failures log instead of raise
source "agno" Source label on stored rows

Multimodal memories

Images flow to the model (Agent.run(images=[Image(...)])), the model's understanding is extracted by MemoryManager as text, and the memory lands here with its source input — image-derived memories work through agno's NATIVE pipeline. (The Mem0 docs demo bypasses agno's memory system entirely and pushes raw base64 into their cloud.)

Tests

pip install -e . pytest pytest-asyncio
pytest tests -q   # 30+ checks against the real agno at latest

The suite drives the real MemoryManager and a REAL Agent run (stub model, local session db) and reproduces each named competitor bug as a regression test.

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

agno_memorysync-1.0.2.tar.gz (15.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agno_memorysync-1.0.2-py3-none-any.whl (21.1 kB view details)

Uploaded Python 3

File details

Details for the file agno_memorysync-1.0.2.tar.gz.

File metadata

  • Download URL: agno_memorysync-1.0.2.tar.gz
  • Upload date:
  • Size: 15.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.9

File hashes

Hashes for agno_memorysync-1.0.2.tar.gz
Algorithm Hash digest
SHA256 c5ff35a97def0361d30a31a94f45c047e7928c26700c49a3b37462f7fd6d842f
MD5 5c614070e146e82dfb34e31258ffbbe9
BLAKE2b-256 82b886457f74640861f22c5c8b842943c28a0e6819fd44c5eb7b64334c548137

See more details on using hashes here.

File details

Details for the file agno_memorysync-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for agno_memorysync-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 de9e4f35756a9101d8eb01cb7ef1bb253f312ea20793d0dd3060a8774724a962
MD5 cb90f3d86848315c53caaf4fcbe69f3f
BLAKE2b-256 98b69df2c0a9309cbfb1e39916c78bbc51626b1b15b4047282193a03d9c11d88

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 files

1.0.1

2 files

1.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page