Integrate

CrewAI memory that survives the crew run

CrewAI now provides a unified memory system with hierarchical scopes, recall, storage controls, and memory inside crews and flows. Use it for the work of a crew. Add an external, product-owned memory boundary when a customer’s context must follow them across crews, applications, model providers, and retention policies.

Updated October 30, 202611 min readAI Memory field guide
A coordinated crew of translucent agents sharing clearly separated memory chambers.

What memory does CrewAI provide?

CrewAI’s memory documentation describes a unified memory system with hierarchical scopes, recall, extraction, consolidation, configurable storage, and non-blocking saves. A crew can enable memory, and agents can use shared crew memory or a scoped view for private context.

That is useful infrastructure for the lifecycle of a crew. The product decision still remains: which facts belong to a customer, which belong to one run, which agents may read them, how long they stay, and how they leave through export or deletion.

When should you use CrewAI memory instead of an external memory API?

Use CrewAI memory when the crew runtime is the main boundary and its storage, scope, and recall behavior already match the product. Add an external layer when identity and lifecycle span several frameworks, when one customer uses multiple crews, or when a platform team needs one memory contract across many agents.

RequirementCrewAI memory is a good fit when…External memory is a good fit when…
RuntimeThe crew owns the workflow and stateSeveral runtimes share durable user context
ScopeCrew and agent scopes match the product modelUser, tenant, project, and agent scopes need one contract
LifecycleThe crew backend handles retention and deletionThe application needs explicit export, redaction, and policy
PortabilityThe crew remains on one platformMemory must survive framework or model changes
OperationsThe team wants one system to operateThe team wants memory capabilities without rebuilding a graph pipeline

How do you retrieve persistent memory before a CrewAI run?

Resolve the customer and tenant before constructing the crew, retrieve a small context block, and inject it as trusted read-only input. Keep the same identifiers on the post-run write so context does not drift between the read and the save.

Pythonpython
from aimemory import Memory

store = Memory(api_key=os.environ["AI_MEMORY_KEY"])

context = store.search(
    query="What should the crew know before this account review?",
    user_id=customer_id,
    agent_id="account-review-crew",
    metadata={"tenant": tenant_id},
    limit=6,
)

crew = AccountReviewCrew(
    inputs={
        "account_id": account_id,
        "durable_context": str(context),
    }
).crew()
result = crew.kickoff()

store.add(
    messages=[
        {"role": "user", "content": review_request},
        {"role": "assistant", "content": str(result)},
    ],
    user_id=customer_id,
    agent_id="account-review-crew",
    metadata={"tenant": tenant_id, "workflow": "account-review"},
)

How should CrewAI memory scopes map to users and agents?

Use the security boundary to choose the outermost scope, then use shorter scopes for execution detail. A tenant should never be an optional metadata filter that the model can omit. A crew or agent scope should not become a shortcut around user authorization.

MemoryScopeExample
Account entitlementtenant + accountThe customer’s current plan and service region
Personal preferencetenant + userPreferred report format and contact window
Agent private findingtenant + crew + agentResearch notes that only one specialist should reuse
Current run statetenant + runIntermediate work that should expire after the workflow
Shared project decisiontenant + projectAn approved architecture or delivery constraint

What should a CrewAI workflow remember after it finishes?

Store the durable outcome, not the internal theatre of the crew. The final answer may contain a decision, a changed constraint, and the evidence behind it. Tool traces and intermediate drafts usually belong in observability storage, not long-term memory.

  • Confirmed decisions and the date they became effective.
  • Constraints that should affect a future run.
  • Stable customer preferences with their source.
  • Corrections that supersede an older memory.
  • An episode summary only when the sequence of events matters later.

How do you keep one CrewAI agent’s private memory private?

Give each specialist an explicit agent identity and query agent-private memory only when the task belongs to that specialist. Shared facts should be promoted deliberately to a crew, project, or user scope. A manager agent should not inherit every private memory merely because it can delegate work.

When a delegated task needs context from a private scope, pass a bounded summary through the workflow rather than broadening the original memory. This preserves both utility and least privilege.

How should a CrewAI system correct, export, and delete memory?

Correction, export, and deletion must be product operations, not hidden maintenance scripts. A new run can supersede a fact, but an authorized user should also be able to inspect and correct it. Tenant offboarding should remove events, extracted memories, summaries, graph edges, and exported copies still under application control.

Test deletion after restoring a backup and after changing the crew’s extraction prompt. The same request must stay deleted when the workflow is replayed.

Frequently asked questions

Does CrewAI already have memory?

Yes. CrewAI documents a unified memory system with scopes, recall, extraction, storage, and use inside crews and flows. The question is whether its boundary matches your product’s cross-application identity and lifecycle.

Do I need an external memory API with CrewAI?

Not always. Add one when customer memory must span several crews or applications, use a model-neutral contract, or follow a platform-wide export, retention, and deletion policy.

How should user and tenant IDs be passed to a crew?

Resolve them from authenticated server context, use them for the memory read and write, and pass only the minimum needed context into crew inputs. Do not let generated content choose a broader scope.

Should every task output become long-term memory?

No. Store confirmed outcomes, useful preferences, constraints, and corrections. Keep tool traces and intermediate drafts in observability storage.

Can CrewAI agents share memory safely?

Use explicit tenant, user, crew, and agent scopes, then test cross-scope queries. Shared memory should be an intentional promotion, not the default for every specialist.

How do I migrate from CrewAI memory to another layer?

Export source, scope, timestamp, and version metadata; map identities; replay a representative sample; and compare recall and deletion before switching writes.

Give every crew the right customer context

Start with one crew, one customer, and one tenant. Retrieve the facts it needs, write only the confirmed outcome, then prove correction and deletion.