MemorySync
Integrations

CAMEL-AI Memory

Give CAMEL’s ChatAgent persistent memory with one constructor argument. MemorySyncMemory keeps verbatim history locally and losslessly, sends each user turn to MemorySync, where only the durable facts in it are stored, injects scored semantic recall right after the system prompt under a hard budget, and needs zero client-side embeddings.

CAMEL keeps verbatim history locally, sends each user turn for server-side fact extraction, and places one recalled SYSTEM-role record after the system prompt.

How it works

  1. Install camel-memorysync from PyPI.
  2. Pass memory=MemorySyncMemory(...) to your ChatAgent.
  3. Every user turn is sent to MemorySync, which extracts the durable facts in it and stores only those; assistant replies are not sent, and your verbatim history stays local.
  4. On each step, the user’s relevant memories are recalled and injected after the system prompt — days later, in new sessions, in other frameworks.

Before you start

  1. A MemorySync API key. Create one in the dashboard under Settings → API Keys, inside a project.
  2. Python 3.10+ with camel-ai 0.2.60 or newer.

Install

One package:

Terminal
pip install camel-memorysync

Quickstart

Step 1 — hand the agent its memory

agent.py
from camel.agents import ChatAgent
from camel_memorysync import MemorySyncMemory
memory = MemorySyncMemory(
user_id="customer-42", # required — who these memories belong to
session_id="support", # session scope — tags this conversation's facts
)
agent = ChatAgent(
system_message="You are a helpful travel assistant.",
memory=memory,
)

Step 2 — teach it, then ask later

agent.py
agent.step("I always prefer window seats on long flights")
# a new session, days later:
agent.step("which seat should I book for the Oslo flight?") # remembers

How recall enters the context

CAMEL’s ScoreBasedContextCreator sorts records by timestamp. The recall block is ONE SYSTEM-role record with timestamp=0.0, so it lands right after the system prompt — your history is never reordered, rewritten, or role-swapped. An anti-echo filter drops any match already present verbatim in the live context, so the question the user just asked can never come back as a “memory”.

The resulting context
[system] You are a helpful travel assistant.
[system] Relevant long-term memories about this user:
- Prefers window seats on long flights
[user] which seat should I book for the Oslo flight?

Advanced: the storage seam

If you compose CAMEL memories yourself, MemorySyncStorage slots into CAMEL’s own ChatHistoryMemory as a BaseKeyValueStorage. save() keeps verbatim records locally (exact round-trip) and sends each user turn to MemorySync, which extracts the durable facts in it and stores only those; assistant replies are not sent, and system prompts and tool chatter never leave the process. A retried save is recognised server-side, so each turn is extracted once:

storage.py
from camel.memories import ChatHistoryMemory, ScoreBasedContextCreator
from camel.types import ModelType
from camel.utils import OpenAITokenCounter
from camel_memorysync import MemorySyncStorage
memory = ChatHistoryMemory(
context_creator=ScoreBasedContextCreator(
OpenAITokenCounter(ModelType.GPT_4O_MINI), 2048),
storage=MemorySyncStorage(user_id="customer-42", session_id="support"),
)

Deletion — designed against data loss

CallWhat happens
clear()Resets the LOCAL conversation window only — remote memories survive
forget_session()Deletes the facts extracted from THIS session’s turns and returns the number deleted (loud — failures raise)
forget_user()Deletes the facts extracted from all of this user’s CAMEL turns (every camel-surface memory) and returns the number deleted; other surfaces’ memories survive

Configuration

ParameterDefaultMeaning
user_id— (required)End user the memories belong to
session_iddefaultSession scope camel::<session> — tags this conversation’s facts; bounds forget_session()
top_k5Memories per recall
recall_timeout1.2Hard recall budget in seconds
min_query_chars8Skip recall for trivial topics
extractionTrueSend the user’s turns to MemorySync for fact extraction
context_creatorScoreBased / 2048 tokensAny BaseContextCreator

Quotas and plan limits

Hitting a monthly plan limit never breaks a conversation. Over-limit writes are accepted without storing and recalls return empty — the agent keeps answering from live history. Evaluation keys instead surface a truthful 429, so limits show up in testing, not production.

Troubleshooting

  • Import crash mentioning `FastMCP` — the installed mcp release is newer than camel-ai supports. Reinstall camel-memorysync to restore a compatible version.
  • A recall was skipped — the 1.2s budget fails open to history-only, and topics under min_query_chars skip recall by design.
  • A “memory” repeats the question just asked — cannot happen: the anti-echo filter drops matches already present in the live context. If you see it, the text differed — check the stored fact.
  • `clear()` didn’t delete remote memories — by design. Use forget_session() or forget_user() for explicit, scoped remote deletes.

Supported versions

SurfaceRequiresVerified on
camel-memorysync 1.1.0camel-ai 0.2.60+ (Python 3.10+)33 CI checks against the latest camel-ai: REAL ChatAgent turns via CAMEL’s own StubModel — the byte-exact local round-trip including a PIL image, role preservation in local history, only user turns sent to MemorySync, local-only clear with explicit scoped forgets, the anti-echo filter, timestamp-0 placement through the real ScoreBasedContextCreator, the 1.2s budget, seed idempotency, and both monthly-quota server modes

How it compares

CAMEL ships a Mem0 storage inside its own repo — the only other memory SaaS in the ecosystem. Verified against its source:

Mem0 (`Mem0Storage`, in-repo)ZepSupermemoryMemorySync
History round-trip✗ broken — load() returns extracted facts, not your messages— nothing at all— nothing at all✓ byte-exact: from_dict reconstructs every record
Message roles✗ every record hardcoded `role=USER` — OpenAI alternation breaks——✓ preserved exactly
clear() blast radius✗ calls `client.delete_users()` — the entire user entity——✓ local window only; remote wipes are explicit and scoped
agent_id filter✗ silently overwritten by the user_id filter——✓ both preserved per record
Failures✗ every exception swallowed — callers never know——✓ conversation always works, failures logged loudly; explicit deletes raise
Multimodal✗ image_list/video_bytes silently discarded——✓ full media round-trip (base64)
Recall latency guard✗ none——✓ 1.2s hard budget, fails open to history-only
Client-side embeddingsn/a——✓ none needed (CAMEL’s own VectorDBMemory defaults to OpenAIEmbedding() + a vector DB you operate)

Where to go next

Was this page helpful?