Skip to main content
Make CrewAI’s built-in memory durable and queryable across crews. The integration plugs into CrewAI’s 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 Memory entries across executions and processes
  • Retrieve semantically-relevant context from prior crew runs
  • Scope memories per user or per organization
The Synap CrewAI integration ships a single class: a drop-in replacement for CrewAI’s default storage backend.

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 ....
Configure your API key. Generate one from the Synap Dashboard.
.env
Initialize the SDK once at application startup:
See SDK Initialization for the full lifecycle and configuration options.

Basic integration

The smallest useful integration swaps in SynapStorageBackend as the storage for CrewAI’s Memory. Every save call inside the crew is routed to Synap, and search returns ranked, semantically-matched results:
CrewAI’s memory machinery is now backed by Synap. Search failures degrade gracefully (empty result + log); writes raise on failure so silent data loss is impossible.

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:
The synchronous 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:
Three things to notice in this pattern:
  1. Memory survives the crew. Re-running kickoff with a new topic still benefits from the prior run’s findings.
  2. 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.
  3. 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.
For multi-tenant services, construct a backend per request; never share a backend whose scope doesn’t match the inbound user.

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; search works transparently.
  • In an async crew, prefer asearch for direct access; the framework will call it for you when you await crew tasks.

Failure semantics

The integration follows the Synap-wide contract:
  • search and asearch degrade gracefully: return [] and log an error if Synap is unreachable.
  • save surfaces failures: raises SynapIntegrationError so 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.
This is by design: read failures shouldn’t break a crew run mid-flight, but silent write failures would corrupt the memory pool.

Going further


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.