Metadata-Version: 2.5
Name: crewai-memorysync
Version: 1.1.0
Summary: MemorySync memory for CrewAI: a native StorageBackend for Memory(storage=...), agent memory tools, and recall context for tasks.
Project-URL: Homepage, https://memorysync.io
Project-URL: Documentation, https://docs.memorysync.io/guides/crewai
Project-URL: API Reference, https://docs.memorysync.io/api/overview
Project-URL: Changelog, https://docs.memorysync.io/release-notes
Project-URL: Support, https://docs.memorysync.io/debugging/support
Project-URL: Status, https://status.memorysync.io
Author: MemorySync
License: MIT
Keywords: agent-memory,ai,ai-agents,crewai,llm,long-term-memory,memory,memorysync,multi-agent
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: crewai<2,>=1.0
Requires-Dist: httpx<1.0,>=0.25
Requires-Dist: memorysync>=1.9
Requires-Dist: pydantic>=2.0
Description-Content-Type: text/markdown

# crewai-memorysync

MemorySync memory for [CrewAI](https://www.crewai.com): the **native `StorageBackend`** for CrewAI 1.x. Point `Memory(storage=...)` at MemorySync and your crews get durable, shared, cross-execution memory driven by CrewAI's own save/recall loop — no manual wiring in your tasks.

```bash
pip install crewai-memorysync
```

## The native backend

```python
from crewai import Agent, Crew, Task
from crewai.memory import Memory
from crewai_memorysync import MemorySyncStorage

crew = Crew(
    agents=[researcher, writer],
    tasks=[research_task, write_task],
    memory=Memory(storage=MemorySyncStorage(user_id="support-crew")),
)
crew.kickoff()
# Every record the crew saved is now stored on MemorySync: it survives
# redeploys and is shared by every service using this user_id. The facts
# in those records show up in Memory Explorer and in recall everywhere.
```

Or register once and use a string spec anywhere:

```python
from crewai_memorysync import register_memorysync
from crewai.memory import Memory

register_memorysync(user_id="support-crew")
memory = Memory(storage="memorysync")
```

**How records are stored:** each CrewAI record is one value in MemorySync's state store — namespace `["crewai"]`, key = the record id — kept exactly as CrewAI wrote it, embedding included. Records are framework state, not memories, so they do not appear in memory lists or search themselves. Their content is also sent to fact extraction: the durable facts in it become memories, visible in Memory Explorer and recallable from every MemorySync surface (the SDKs, MCP, the other integrations, `get_crew_context`). Updating a record replaces the facts of its previous version; deleting or resetting records deletes their facts too.

**Design guarantees:**

- **Full protocol** — save, vector search, delete, update, get, list, scopes, categories, count, reset, plus honest async twins. Records round-trip exactly, embeddings included.
- **Built-in parity** — search uses the same score scale (`1/(1+distance)`) and filter semantics as CrewAI's bundled LanceDB backend.
- **Retry-safe** — a record has exactly one live value. Saving an identical record again (CrewAI's background executor replays saves) stores and extracts nothing twice; an update replaces the previous version in place.
- **Loud failures** — CrewAI's save executor silently drops `RuntimeError`, so this package never raises one. API failures raise `MemorySyncAPIError`; dimension mismatches raise CrewAI's own `EmbeddingDimensionMismatchError`; deletes that remove nothing raise `MemorySyncDeleteRefusedError`.
- **Full-wipe guard** — `reset(None)` and criteria-less deletes are refused unless you construct with `allow_full_reset=True`.

## Agent tools

```python
from crewai import Agent
from crewai_memorysync import create_memorysync_tools

agent = Agent(
    role="Personal assistant",
    goal="Help using what you know about the user",
    backstory="You remember the user's preferences.",
    tools=create_memorysync_tools(user_id="customer-7"),
)
```

Five tools — `add_memory`, `search_memory`, `list_memories`, `update_memory`, `delete_memory` — that never raise (failures come back as readable strings) with idempotent writes. `read_only=True` returns search + list only.

## Task context

```python
from crewai_memorysync import get_crew_context

context = get_crew_context("travel preferences", user_id="customer-7")
task = Task(description=f"Plan the trip.\nKnown preferences:\n{context}", ...)
```

## Observability

```python
from crewai_memorysync import attach_memory_logging
attach_memory_logging()  # logs every MemorySave*/MemoryQuery* event
```

## Version support

| Package | Requires | Runtime |
|---|---|---|
| `crewai-memorysync` | crewai >=1.0 <2 | Python 3.10+ |

On an older CrewAI the import fails with a sentence naming the fix — never a half-working crew.

## Documentation

Full guide: **https://docs.memorysync.io/guides/crewai**

Set `MEMORYSYNC_API_KEY` in the environment (create a key at [memorysync.io](https://memorysync.io)). The key needs read and write access; deletes and resets also need delete access. MIT licensed.
