Skip to content

§ Tutorial

Give a CrewAI crew persistent memory. Shared across the crew.

Back your crew's external memory with OctaMem so agents remember context, findings, and decisions across runs — using CrewAI's ExternalMemory interface and the octamem[crewai] integration.

Framework

CrewAI

SDK

octamem (Python)

Est. time

~10 min

CrewAI orchestrates multiple agents working toward a goal. By default a crew’s memory is local to a run; this tutorial wires OctaMemin as the crew’s external memory so knowledge persists across runs and is shared between agents.

Prerequisites

  • Python 3.9+ and a model provider configured for CrewAI (e.g. OpenAI).
  • A free OctaMem API key from platform.octamem.com.

Step 1: Install

terminal
pip install octamem 'octamem[crewai]' crewai

Set OCTAMEM_API_KEY in your environment so OctaMemStorage can authenticate without hard-coding the key.

Step 2: Back the crew with OctaMem

Pass ExternalMemory(storage=OctaMemStorage()) as the external_memoryargument when you build your crew. That’s the whole integration — CrewAI handles the read/write calls.

crew_memory.py
from crewai import Agent, Task, Crew
from crewai.memory.external.external_memory import ExternalMemory
from octamem.integrations.crewai import OctaMemStorage

researcher = Agent(
    role="Researcher",
    goal="Gather and remember key facts about the account",
    backstory="You track everything the team learns about each customer.",
)

task = Task(
    description="Summarize what we know about customer #4521.",
    expected_output="A short brief citing prior interactions.",
    agent=researcher,
)

crew = Crew(
    agents=[researcher],
    tasks=[task],
    # Back the crew's external memory with OctaMem.
    external_memory=ExternalMemory(storage=OctaMemStorage()),
)

result = crew.kickoff()
print(result)

How it works

Each memory the crew stores becomes a typed record with provenance in your OctaMem account, retrievable by natural-language query. Because it’s external and account-scoped, the same memory is available on the next run, to other agents, and even to MCP clients like Cursor and Claude. For a deeper comparison of approaches, see Mem0 vs Zep vs OctaMem.

FAQ

Does CrewAI have persistent memory?

CrewAI has a built-in memory system, and it also supports external memory providers through its ExternalMemory interface. Backing that with OctaMem gives the crew durable, searchable memory that persists across runs and is shared with anything else using the same OctaMem account.

How do I connect OctaMem to CrewAI?

Install octamem with the crewai extra, then pass ExternalMemory(storage=OctaMemStorage()) as the external_memory argument when you build your Crew. Set OCTAMEM_API_KEY in your environment and the crew will read and write memories through OctaMem automatically.

Can multiple agents in a crew share memory?

Yes. External memory backed by OctaMem is shared across the crew, so what one agent learns is available to the others — and to agents on other frameworks that use the same account.