Add long-term memory to CrewAI agents and crews.
CrewAI Integration
CortexDB provides persistent long-term memory for CrewAI agents, enabling crews to learn and remember across task executions.
Installation
pip install cortexdb[crewai]
Setup
from crewai import Agent, Task, Crew
from cortexdb.integrations.crewai import CortexMemory
memory = CortexMemory(
api_key="your-cortex-api-key",
tenant_id="my-app",
namespace="engineering-crew",
)
researcher = Agent(
role="Senior Researcher",
goal="Find relevant technical context",
backstory="You are a senior engineer with deep institutional knowledge.",
memory=memory,
)
writer = Agent(
role="Technical Writer",
goal="Write clear technical documentation",
backstory="You produce excellent technical docs.",
memory=memory, # Shared memory across agents
)
task = Task(
description="Write a summary of our database migration decisions.",
agent=writer,
)
crew = Crew(
agents=[researcher, writer],
tasks=[task],
)
result = crew.kickoff()
Shared vs Per-Agent Memory
# Shared memory (all agents see the same memories)
shared_memory = CortexMemory(tenant_id="my-app", namespace="shared")
# Per-agent memory (isolated)
researcher_memory = CortexMemory(tenant_id="my-app", namespace="researcher")
writer_memory = CortexMemory(tenant_id="my-app", namespace="writer")
Configuration
| Parameter | Default | Description |
|---|---|---|
| api_key | $CORTEX_API_KEY | CortexDB API key |
| tenant_id | Required | Tenant identifier |
| namespace | None | Memory namespace |
| top_k | 10 | Results per recall |