StorageBackend protocol, so existing crews keep working. They just gain a long-term memory that survives restarts.
Requires Python 3.11+.
Overview
This guide shows how to add Synap to a CrewAI application to build crews that:- Persist
Memoryentries across executions and processes - Retrieve semantically-relevant context from prior crew runs
- Scope memories per user or per organization
Setup
Install the package alongside CrewAI:The pip package is
maximem-synap-crewai, but the import drops the maximem- prefix and uses underscores: from synap_crewai import .....env
Basic integration
The smallest useful integration swaps inSynapStorageBackend as the storage for CrewAI’s Memory. Every save call inside the crew is routed to Synap, and search returns ranked, semantically-matched results:
Core concepts
Lifecycle methods
SynapStorageBackend implements CrewAI’s StorageBackend protocol by mapping each method to the equivalent Synap operation:
CrewAI operations that have no direct Synap equivalent (notably
delete) are no-ops with a warning logged. The memory pipeline keeps moving rather than blocking the crew.
Async support
CrewAI 0.100+ supports async task execution.SynapStorageBackend exposes asearch for use in async crews:
search method wraps asearch via an event-loop bridge, so the same backend works in both sync and async crews. You don’t need separate configurations.
Complete example: research crew with shared memory
The following crew chains a researcher and a writer. Both agents share the same Synap-backed memory, so the writer sees what the researcher learned, and the next crew kickoff has access to everything from earlier runs:- Memory survives the crew. Re-running
kickoffwith a new topic still benefits from the prior run’s findings. - Scope is fixed at backend construction. All agents in this crew share the same
user_id/customer_id. Build a separate crew per user if you need isolation. - CrewAI’s built-in retrieval is unchanged. You don’t restructure tasks or prompts; the memory backend just becomes Synap.
Advanced patterns
Multi-tenant scoping
SynapStorageBackend accepts the standard scoping triple: user_id (required), optional customer_id, optional conversation_id. customer_id is required on B2B Synap instances and ignored on single-tenant ones. See Memory Scopes.
Sync and async in the same codebase
SynapStorageBackend supports both search (sync) and asearch (async). The sync method bridges to the async path via an event loop, so:
- In a sync crew, just call
crew.kickoff()as usual;searchworks transparently. - In an async crew, prefer
asearchfor direct access; the framework will call it for you when you await crew tasks.
Failure semantics
The integration follows the Synap-wide contract:searchandasearchdegrade gracefully: return[]and log an error if Synap is unreachable.savesurfaces failures: raisesSynapIntegrationErrorso the crew (and caller) know if persistence failed.- Unsupported operations (e.g.,
delete) are no-ops with a warning rather than raising, so they don’t kill the crew.
Going further
- Patterns overview: reusable memory patterns across frameworks.
- Cookbook overview: end-to-end worked examples.
Next steps
AutoGen
BaseTool implementations for AutoGen agents.Pydantic AI
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
save.