
To enable memory in CrewAI, add memory=True when instantiating the Crew — this automatically activates short-term, long-term, entity, and contextual memory for all agents in the crew.

CrewAI's memory system transforms simple agents into assistants with contextual learning capability — a critical feature for projects involving multiple executions, iterative research, or customer support. Without memory, each run starts from scratch; with memory enabled, the crew retains context from previous executions and uses that information to respond more accurately and consistently.
Memory Types Available in CrewAI
CrewAI implements four distinct memory types, each with specific behavior and purpose:
| Type | Duration | What It Stores | Default Backend |
|---|---|---|---|
| Short-term Memory | Within 1 run | Current conversation/task context | RAM (in-memory) |
| Long-term Memory | Between runs | Past results and learnings | Local SQLite |
| Entity Memory | Between runs | Info about entities (people, companies) | SQLite + embeddings |
| Contextual Memory | Within 1 run | Combines short-term + entity for rich context | Derived |
| User Memory | Persistent | User preferences and history | Mem0 (optional) |
Enabling Memory: Basic Configuration
The simplest way to activate memory in CrewAI is to add the memory=True parameter when creating the Crew instance. The framework automatically initializes all memory types with default backends:
from crewai import Agent, Task, Crew, Process
# Defining agents
researcher = Agent(
role="Senior Researcher",
goal="Research and synthesize relevant information",
backstory="Information analysis specialist with 10 years of experience",
verbose=True
)
analyst = Agent(
role="Data Analyst",
goal="Analyze information and generate actionable insights",
backstory="Analyst focused on market patterns and trends",
verbose=True
)
# Creating the Crew with memory enabled
crew = Crew(
agents=[researcher, analyst],
tasks=[task1, task2],
process=Process.sequential,
memory=True, # Enables all memory types
verbose=True
)
result = crew.kickoff(inputs={"topic": "AI trends in 2026"})
Withmemory=Trueactive, CrewAI automatically persists each task's results in a local SQLite database (default location:~/.crewai/). On the next execution, the crew queries this history before executing each task, allowing agents to reference past work without reprocessing the same content.
Practical Difference Between Agents With and Without Memory
The behavioral difference between crews with and without memory is significant in multi-execution scenarios.
Without memory, a research agent analyzing weekly market reports treats each run independently — with no awareness of what was analyzed in previous weeks.
With long-term memory enabled, the same agent recalls previous analyses, identifies that a specific report has already been processed, and focuses on new information only. This dramatically reduces token usage and improves response quality by avoiding unnecessary repetition.

Configuring Long-Term Memory with Embeddings
CrewAI's long-term memory uses vector embeddings to store and retrieve semantically relevant information. By default, CrewAI uses OpenAI embeddings — requiring the OpenAI API key.
To use local embeddings (zero cost), Ollama or local models can be configured:
from crewai import Crew
from crewai.memory import LongTermMemory
from crewai.memory.storage.ltm_sqlite_storage import LTMSQLiteStorage
# Configuring long-term memory with custom storage
crew = Crew(
agents=[...],
tasks=[...],
memory=True,
long_term_memory=LongTermMemory(
storage=LTMSQLiteStorage(
db_path="./project_memory.db" # custom path
)
)
)
For production projects, defining a specific path for the memory SQLite database is a recommended practice — it prevents data from different projects from being mixed in the user's default directory.DomineTec Tip: When using long-term memory in production environments, back up the SQLite file periodically. Losing this file means losing all agent learning history — there is no automatic recovery.
Practical Use Cases for CrewAI Memory
Customer support: A support crew that recalls each user's problem history can respond with much more context — without asking for information already provided in previous sessions. Entity memory is especially useful here for storing individual customer profiles.
Iterative research: Crews monitoring information sources regularly (news, reports, social media feeds) benefit from long-term memory to know what has already been processed and focus only on new content.
Content production: Writer agents with memory maintain consistency in tone, vocabulary, and references across multiple pieces of content produced in separate sessions.
Limitations and Best Practices
CrewAI's memory has important limitations to consider. The default SQLite database doesn't scale well for very large data volumes — projects with more than a few gigabytes of history may experience slowdowns in retrieval.
For these cases, configuring an alternative backend (such as RAG with ChromaDB or Pinecone) is the right approach.
Another consideration is privacy: long-term memory persists locally, but if the crew uses the OpenAI API for embeddings, texts are sent to OpenAI servers during the vectorization process. For sensitive data, using local embeddings with Ollama is essential.
See more about setting up and configuring CrewAI in the guide on installing CrewAI with CLI. For understanding how agents delegate tasks to each other, see the CrewAI automatic delegation guide.
Frequently Asked Questions
1. Does CrewAI memory work with any LLM?
Short-term and contextual memory work with any LLM. Long-term and entity memory require an embedding provider — OpenAI by default, but configurable for local providers like Ollama with models such as nomic-embed-text.
2. Does memory data stay local or go to external servers?
Memory data is stored locally in SQLite by default. If the OpenAI API is used for embedding generation, the processed texts pass through OpenAI servers during vectorization — but stored data remains on the local machine.
3. How to clear CrewAI memory between tests?
Simply delete the generated SQLite file (default location: ~/.crewai/long_term_memory_storage.db and similar files). Alternatively, pass memory=False temporarily to run without memory during testing.
4. Does memory work in hierarchical process mode?
Yes. Memory works regardless of the process type (sequential or hierarchical).
In hierarchical mode, the manager agent also has access to the crew's shared memory.
Final Thoughts
CrewAI's memory system is a significant differentiator for projects requiring consistency across multiple executions. Basic activation with memory=True is sufficient for most use cases, while advanced embedding provider configuration allows adapting the system to specific privacy, scale, and cost requirements.
Projects that adopt memory from the beginning of development build a context base that becomes more valuable over time — transforming the crew into a system that organically improves with each execution.




