--- title: "Memory for CrewAI" description: "crewai-pastdotdev gives CrewAI crews memory with dates and sources: pass PastDevMemory as crew memory, or give an agent recall and ingest tools." canonical: https://past.dev/integrations/crewai last-updated: 2026-10-28 --- # Memory for CrewAI agents Source: https://past.dev/integrations/crewai CrewAI ships one Memory class that stores records in LanceDB inside the project directory. The `crewai-pastdotdev` package lets a crew use past.dev instead. Pass `PastDevMemory(identity=...)` as `memory=` to a Crew or an Agent, and CrewAI recalls before each task and saves each result through the Memory API. Or give an agent `PastDevRecallTool` and `PastDevIngestTool` and let it decide when to call them. Each memory keeps its date and its source, and your code sets the identity. ## What CrewAI memory covers CrewAI documents one unified memory system. The [memory guide](https://docs.crewai.com/en/concepts/memory) describes a single `Memory` class that replaced the separate short-term, long-term, entity and external memory types of earlier releases. A crew enables it with `memory=True`, or with a configured `Memory` instance for custom behavior. Records are stored in LanceDB under `./.crewai/memory` by default; a custom backend can implement the storage protocol. Records are organized into hierarchical scopes shaped like filesystem paths, such as `/project/alpha` or `/agent/researcher`. `memory.recall()` returns ranked matches scored by a blend of semantic similarity, recency decay and importance. - **Storage is local by default.** The default backend writes LanceDB files inside the project directory. A crew and your product, or two deployed services, share memory only through a backend you build and run. - **Recency is a ranking weight.** A newer record outranks an older one at recall, but neither carries a link to the record it replaced, so the store can't say which value is current or what was true on a date. - **Per-user isolation is a convention.** The application builds it from scope paths and read-only slices. ## Install crewai-pastdotdev ```bash pip install crewai-pastdotdev export PAST_API_KEY="past_sk_..." ``` The package needs Python 3.10 to 3.13 and CrewAI 1.14.6 or later. Create the project key in the [past.dev console](https://app.past.dev) under **Build › API keys**. You can also pass `api_key=` to each class. The package is [crewai-pastdotdev on PyPI](https://pypi.org/project/crewai-pastdotdev/), and its source and README are in the [pastdotdev/crewai-pastdotdev repository](https://github.com/pastdotdev/crewai-pastdotdev). ## Use past.dev as crew memory ```python from crewai import Agent, Crew, Task from crewai_pastdotdev import PastDevMemory memory = PastDevMemory(identity=current_user.id) writer = Agent( role="Account manager", goal="Write the weekly report the way the customer wants it", backstory="You know the customer well.", ) report = Task( description="Write this week's report for the customer.", expected_output="A report in the format the customer prefers.", agent=writer, ) crew = Crew(agents=[writer], tasks=[report], memory=memory) crew.kickoff() ``` 1. Before each task, CrewAI recalls with the task description, and the memories go into the agent's prompt. 2. After each task, CrewAI saves the task and its result, and `PastDevMemory` ingests them as one data point. Your crew makes no extra model call to save them. 3. CrewAI's own "Search memory" and "Save to memory" tools go through past.dev too. `memory.remember()`, `memory.recall()` and `memory.forget(record_ids=[...])` call Ingest, Recall and Delete data point directly. Set `audience` to scope what the crew saves, `read_only=True` to recall without saving, and `recall_level` or `recall_max_tokens` to size each recall. To change a fact, remember the new one: past.dev marks the earlier statement as replaced. ## Use past.dev as agent tools ```python from crewai import Agent from crewai_pastdotdev import PastDevIngestTool, PastDevRecallTool agent = Agent( role="Support agent", goal="Help the customer with what you know about them", backstory="You remember every earlier conversation.", tools=[ PastDevRecallTool(identity=current_user.id), PastDevIngestTool(identity=current_user.id), ], ) ``` The model gives only the `query` to the recall tool and the `content` to the ingest tool. The recall tool returns rank, date, content and the quotes from each memory's sources, and says when a later statement replaced a memory. An API error comes back to the agent as text, with a note not to retry when a retry can't help. > **Identity** > > The application sets the identity. The model never chooses it. Recall returns what the identity in the request may read, so take the identity from the signed-in user in code, and keep it out of every value that the model fills. `current_user.id` comes from your user record or the trigger of the run. Neither class has an identity argument the model can fill, so make one memory or one set of tools per user. ## Or connect the MCP server A CrewAI agent takes MCP servers in its `mcps` field. `MCPServerHTTP` from `crewai.mcp` connects to a remote server, with `streamable=True` for Streamable HTTP ([MCP overview](https://docs.crewai.com/en/mcp/overview)). The project's end-user MCP server then gives the agent `recall`, `answer` and `who_am_i`, plus `remember` while the project's write toggle is on, with no tool code to write. 1. Turn on the project's end-user MCP server on **Build › MCP server** in the console. 2. Mint an access link there, or with the account server's `create_mcp_access_link` tool. The link has the form `https://api.past.dev/mcp//link/`. It is one URL that is one identity, and the server answers it with no sign-in step. 3. Keep the link in a secret store, such as the `PAST_MCP_URL` environment variable that the code below reads. The secret in its path is the credential. ```python import os from crewai import Agent from crewai.mcp import MCPServerHTTP analyst = Agent( role="Account analyst", goal="Answer questions about customers from their dated history", backstory="You call recall before you answer questions about people, decisions or commitments.", mcps=[MCPServerHTTP(url=os.environ["PAST_MCP_URL"], streamable=True)], ) ``` Every call through the link runs as its identity, with that identity's audiences. Mint one link per install, so that a revoked link stops one agent only. When the agent serves several people, mint one link per end user, and connect each request with the link of the user who makes it. Never share one link between users. `remember` writes to the identity's own private audience, and only that identity recalls it. Send data that the whole project must recall through the ingest call. The [end-user server documentation](/docs/mcp/serving-your-own-users) describes the tools, the links and revocation. ## When to use which | Requirement | CrewAI Memory | crewai-pastdotdev | | --- | --- | --- | | Recall inside one project's runs | Yes | Yes | | Current value of a fact that changed | Newer records rank higher | Replaced statements are marked | | What was true on a date | No documented query | Point-in-time recall | | Recall result | Scored records | Ranked memories with dates and source excerpts | | Memory shared beyond one machine | Custom storage backend | One API for every caller | Recall returns ranked documents with dates and source excerpts. The application decides whether those documents support an answer, contain a disagreement, or are insufficient; HTTP failures are handled separately. The [quickstart](/docs/memory-api/quickstart) shows how to ingest, wait until ingestion completes, and recall. The [benchmarks](/benchmarks) document how recall is measured. [Facts that change over time](/guides/facts-that-change-over-time) covers general temporal designs. ## Frequently asked questions ### Does CrewAI have long term memory? Yes. Current CrewAI documentation describes one unified Memory class that persists records in LanceDB and ranks them at recall by similarity, recency and importance. It replaced the earlier separate short-term, long-term, entity and external memory types. ### Does PastDevMemory support every CrewAI memory method? It supports remember, remember_many, recall and forget. tree, info, list_records, update and reset aren't available, because the memory lives on past.dev. Use the past.dev console to browse it. ### Can two crews share what they learned? Yes. Every crew that uses a key for the same project reads and writes one memory, and each recall returns what its identity may read. ## Related - [Memory for LlamaIndex](https://past.dev/integrations/llamaindex) - [Memory for LangChain](https://past.dev/integrations/langchain) - [Memory for the OpenAI Agents SDK](https://past.dev/integrations/openai-agents-sdk) - [Memory for AutoGen](https://past.dev/integrations/autogen) - [What is agent memory?](https://past.dev/what-is-agent-memory) - [Quickstart](https://past.dev/docs/memory-api/quickstart)