πŸ“¦ Moved to new directory. Last updated 12.2.2026. New location: claude-config/library/03-memory-state/deep-dives/fw-crewai.html

Framework deep dive: CrewAI memory and the 27 solutions

Nov 19, 2026 · Michael Chang · Status: ⬜ not used in NurseOps Now (planned for restaurant-ai-platform, F14)

Show definitions in ( ) Β· hover a highlighted word for its meaning, click it for details Β· open with ?defs=1 to show definitions

Part of: Remembering the right things: state management in NurseOps Now Β· All 27 solutions Β· Other frameworks: LangGraph Β· AutoGen Β· LlamaIndex

Read in this order

  1. In plain words
  2. What it gives you for memory: from the current docs
  3. How to implement it (ServiceApps): code and output
  4. The 27 solutions with CrewAI: replace, complement or still yours
  5. Use both: what you still build
  6. In NurseOps Now, Trade-offs and Interview answer

In plain words

CrewAI builds a "crew" of role-playing agents (an AI that chooses which tools to use to answer) that work through tasks. Its memory is now one unified Memory class: agents (an AI that chooses which tools to use to answer) remember facts and recall the relevant ones before each task, organized in scopes like folders (/customer/acme, /agent/researcher).

In plain terms: a shared team wiki with folders, which every teammate searches before starting a task.

What it gives you for memory

From the official memory docs (CrewAI memory docs), checked on Nov 19, 2026:

How to implement it (ServiceApps)

Illustrative example: made-up data, no ServiceApps (a company platform for IT tickets, HR requests and help-center articles) instance. The code is written from the current docs but not run (it needs an API key (a secret code that lets the app use a paid service)).

The scenario. ServiceApps (a company platform for IT tickets, HR requests and help-center articles) Assist's crew remembers facts per customer scope and recalls them before a task; one customer's memories are reset on request.

Steps.

  1. Create Memory() (configure embedder and storage for production).
  2. Save facts with a scope per customer or user, and private=True for sensitive ones.
  3. Pass memory to the crew (Crew(..., memory=memory)) or give an agent (an AI that chooses which tools to use to answer) a scoped view.
  4. Delete one customer's memories with memory.reset(scope=...).

The code (Python):

from crewai import Agent, Crew, Memory, Task

memory = Memory(storage="./.crewai/memory")                     # LanceDB by default; set embedder= for production
memory.remember("Acme uses the corporate VPN profile v2", scope="/customer/acme", importance=0.8)
memory.remember("Acme's admin contact prefers email", scope="/customer/acme", private=True)

for m in memory.recall("how does acme connect to vpn", scope="/customer/acme", limit=3):
    print(round(m.score, 2), m.record.content)

assist = Agent(role="ServiceApps Assist", goal="Answer IT questions from KB articles",
               backstory="Cites KB numbers", memory=memory.scope("/customer/acme"))
crew = Crew(agents=[assist], tasks=[Task(description="Help Acme with VPN error 809",
                                         expected_output="Steps with KB citations", agent=assist)], memory=memory)

memory.reset(scope="/customer/acme")                           # forget one customer

Output: not run. CrewAI's memory sends content to an embedding (text turned into numbers so similar meanings sit close together) model and an LLM (large language model: the AI that reads and writes text (here, Claude)) (OpenAI by default) on every save, so it needs an API key (a secret code that lets the app use a paid service). The code follows the current memory docs.

What to watch for.

The 27 solutions with CrewAI

πŸ” Replace = CrewAI does it, you configure it (9 of 27). 🀝 Complement = use both: CrewAI gives the mechanism, you add the rules (8). πŸ›  Still yours = build it yourself (10). † = not a memory feature, so from general knowledge rather than the memory docs; check the current docs.

Memory solutionWith CrewAIHowSolution
Three-Tier Memory: Short-Term (Context Window) (what the AI sees in the current call)🀝 ComplementRecalled memories are injected before each task; no chat-window setting on the memory pageDeep dive
Three-Tier Memory: Long-Term (Vector Store) (knowledge saved outside the model and searched when needed)πŸ” ReplaceUnified Memory: remember / recall with semantic search (LanceDB by default)Deep dive
Three-Tier Memory: Episodic (Experience Log) (a record of what happened, step by step)🀝 ComplementMemory records carry source and time; the audit log (a permanent record of who did what and when) is yoursDeep dive
Agentic Outcome: Token Budgets (keeping each call within a planned size)πŸ›  Still yoursNot on the memory pageDeep dive
Agentic Outcome: Hybrid Memory Systems (recent chat in the window plus long-term search)πŸ” ReplaceOne Memory recalled into every taskDeep dive
Agentic Outcome: Strict State Serialization (saving state so work can pause, crash and resume without loss)🀝 ComplementMemory is persistent; saving a run's state (everything the app must remember to continue correctly) isn't on the memory pageDeep dive
Token Counting Middleware (code that counts tokens before every AI call and acts when the window gets too full)πŸ›  Still yoursNot on the memory pageDeep dive
Dynamic Context Loading (giving the AI tools to fetch data only when it needs it, instead of putting everything in the prompt)πŸ” ReplaceAgent (an AI that chooses which tools to use to answer) tools (a function the AI can call, such as policy search) and knowledge sources are standard †Deep dive
System Prompt Pinning (keeping the rules in a protected place that is sent on every call and never trimmed)πŸ” ReplaceEach agent (an AI that chooses which tools to use to answer)'s role, goal and backstory go into every task prompt (the instructions and text given to the AI) †Deep dive
Textual Summarization (rewriting old conversation into short, dense notes)🀝 Complementextract_memories() splits text into facts (not a summary)Deep dive
Rolling Summaries (a short running summary that replaces old conversation turns)πŸ›  Still yoursNot built inDeep dive
Entity Extraction (pulling key facts (names, dates, IDs) out of text into a structured record)πŸ” Replaceremember analyzes content with an LLM (large language model: the AI that reads and writes text (here, Claude)) (categories, importance); extract_memories()Deep dive
Vector Compression via RAG (storing text as vectors and pulling back only the parts that match)πŸ” Replacerecall(query) over all saved memoriesDeep dive
The Engineering Trade-off: Fidelity vs. Capacity (the trade-off between keeping every detail and fitting more in the window)πŸ›  Still yoursConsolidation can merge or delete records automatically: keep exact facts elsewhereDeep dive
The Hot/Cold State Architecture (splitting memory into what is in the current call (hot) and what is saved for later (cold))🀝 ComplementThe prompt (the instructions and text given to the AI) is hot; Memory is coldDeep dive
Structured Storage (SQL/Postgres) (a database with fixed tables for exact facts)πŸ›  Still yoursMemory is stored in LanceDB, not your recordsDeep dive
Semantic Storage (Vector DB like Pinecone, Weaviate, or Chroma) (a vector database that finds text by meaning)πŸ” ReplaceLanceDB by default, or a custom StorageBackendDeep dive
Session Caching (Redis/Key-Value) (saving a conversation's state so it can pause and resume)πŸ›  Still yoursNo session or thread (one saved conversation, here one per user and case) concept (scopes instead)Deep dive
The Rehydration Pattern (fetch saved state, keep only what's relevant, and put it back into the next call)πŸ” ReplaceRelevant memories are recalled into each task, filtered by scopeDeep dive
Sanitization layer (code that masks personal details and secrets before anything is saved)πŸ›  Still yoursNo redaction; private flag; docs suggest a local LLM (large language model: the AI that reads and writes text (here, Claude)) for sensitive dataDeep dive
TTL (time-to-live) expiration (deleting saved data automatically after a set time)πŸ›  Still yoursNot built in; recency_half_life_days only affects rankingDeep dive
GDPR Right to Be Forgotten (a person's right to have their stored data deleted (from the EU's GDPR law))🀝 Complementmemory.reset(scope="/customer/...") clears one scopeDeep dive
Engineering Fix: Recursive Goal Injection (repeating a short reminder of the rules before every AI answer)🀝 ComplementRole and goal in every task prompt (the instructions and text given to the AI) act as an anchor †Deep dive
Engineering Fix: Strict RAG and Citation Enforcement (answering only from retrieved sources, and flagging any answer without one)πŸ›  Still yoursYours †Deep dive
Input Filtering: Relevance Pruning (checking and trimming a question before the AI sees it)πŸ›  Still yoursYours †Deep dive
Process Control: Self-Correction Loop (checking the AI's answer and sending it back once to fix what failed)🀝 ComplementTask guardrails (checks that block unsafe or off-topic input and output) can reject output and retry †Deep dive
Output Guardrails: Schema Enforcement (requiring the AI's answer to match a fixed shape, checked in code)πŸ” ReplaceTask output_pydantic / output_json †Deep dive

Use both: what you still build

Still yours with CrewAI:

Use both (complement), with your rules on top:

In NurseOps Now

Not used in NurseOps Now. CrewAI is planned as feature F14 in restaurant-ai-platform.

Trade-offs

Interview answer

"CrewAI gives me one Memory with scopes: agents (an AI that chooses which tools to use to answer) remember and recall facts before each task, and I can reset one customer's scope for deletion. I'd keep exact facts in our own database, because CrewAI's LLM-based consolidation can rewrite memories, and I'd use a local model for anything sensitive."

All data in this post is made up.

← Back to all 27 solutions

Key terms

Every highlighted word in this post links here. Click ↩ Back to return to the spot you came from.

agent
An AI that chooses which tools to use to answer.Used in: In plain words, How to implement it (ServiceApps), The 27 solutions with CrewAI, Interview answer↩ Back to where you were
agentic outcome: hybrid memory systems
Recent chat in the window plus long-term search.Used in: The 27 solutions with CrewAI↩ Back to where you were
agentic outcome: strict state serialization
Saving state so work can pause, crash and resume without loss.Used in: The 27 solutions with CrewAI, Use both: what you still build↩ Back to where you were
agentic outcome: token budgets
Keeping each call within a planned size.Used in: The 27 solutions with CrewAI, Use both: what you still build↩ Back to where you were
API key
A secret code that lets the app use a paid service.Used in: How to implement it (ServiceApps)↩ Back to where you were
audit log
A permanent record of who did what and when.Used in: The 27 solutions with CrewAI, Use both: what you still build↩ Back to where you were
dynamic context loading
Giving the AI tools to fetch data only when it needs it, instead of putting everything in the prompt.Used in: The 27 solutions with CrewAI↩ Back to where you were
embedding
Text turned into numbers so similar meanings sit close together.Used in: How to implement it (ServiceApps)↩ Back to where you were
embeddings
Text turned into numbers so similar meanings sit close together.Used in: What it gives you for memory↩ Back to where you were
engineering fix: recursive goal injection
Repeating a short reminder of the rules before every AI answer.Used in: The 27 solutions with CrewAI, Use both: what you still build↩ Back to where you were
engineering fix: strict rag and citation enforcement
Answering only from retrieved sources, and flagging any answer without one.Used in: The 27 solutions with CrewAI, Use both: what you still build↩ Back to where you were
entity extraction
Pulling key facts (names, dates, IDs) out of text into a structured record.Used in: The 27 solutions with CrewAI↩ Back to where you were
gdpr right to be forgotten
A person's right to have their stored data deleted (from the EU's GDPR law).Used in: The 27 solutions with CrewAI, Use both: what you still build↩ Back to where you were
guardrails
Checks that block unsafe or off-topic input and output.Used in: The 27 solutions with CrewAI, Use both: what you still build↩ Back to where you were
input filtering: relevance pruning
Checking and trimming a question before the AI sees it.Used in: The 27 solutions with CrewAI, Use both: what you still build↩ Back to where you were
LLM
Large language model: the AI that reads and writes text (here, Claude).Used in: How to implement it (ServiceApps), The 27 solutions with CrewAI, Use both: what you still build, Trade-offs↩ Back to where you were
memory types
Working memory plus three long-term kinds: episodic, semantic, procedural.Used in: What it gives you for memory↩ Back to where you were
output guardrails: schema enforcement
Requiring the AI's answer to match a fixed shape, checked in code.Used in: The 27 solutions with CrewAI↩ Back to where you were
process control: self-correction loop
Checking the AI's answer and sending it back once to fix what failed.Used in: The 27 solutions with CrewAI, Use both: what you still build↩ Back to where you were
prompt
The instructions and text given to the AI.Used in: The 27 solutions with CrewAI, Use both: what you still build↩ Back to where you were
rolling summaries
A short running summary that replaces old conversation turns.Used in: The 27 solutions with CrewAI, Use both: what you still build↩ Back to where you were
sanitization layer
Code that masks personal details and secrets before anything is saved.Used in: The 27 solutions with CrewAI, Use both: what you still build↩ Back to where you were
semantic storage (vector db like pinecone, weaviate, or chroma)
A vector database that finds text by meaning.Used in: The 27 solutions with CrewAI↩ Back to where you were
ServiceApps
A company platform for IT tickets, HR requests and help-center articles.Used in: How to implement it (ServiceApps)↩ Back to where you were
session caching (redis/key-value)
Saving a conversation's state so it can pause and resume.Used in: The 27 solutions with CrewAI, Use both: what you still build↩ Back to where you were
state
Everything the app must remember to continue correctly.Used in: The 27 solutions with CrewAI, Use both: what you still build↩ Back to where you were
structured storage (sql/postgres)
A database with fixed tables for exact facts.Used in: The 27 solutions with CrewAI, Use both: what you still build↩ Back to where you were
system prompt pinning
Keeping the rules in a protected place that is sent on every call and never trimmed.Used in: The 27 solutions with CrewAI↩ Back to where you were
textual summarization
Rewriting old conversation into short, dense notes.Used in: The 27 solutions with CrewAI, Use both: what you still build↩ Back to where you were
the engineering trade-off: fidelity vs. capacity
The trade-off between keeping every detail and fitting more in the window.Used in: The 27 solutions with CrewAI, Use both: what you still build↩ Back to where you were
the hot/cold state architecture
Splitting memory into what is in the current call (hot) and what is saved for later (cold).Used in: The 27 solutions with CrewAI, Use both: what you still build↩ Back to where you were
the rehydration pattern
Fetch saved state, keep only what's relevant, and put it back into the next call.Used in: The 27 solutions with CrewAI↩ Back to where you were
thread
One saved conversation, here one per user and case.Used in: The 27 solutions with CrewAI, Use both: what you still build, Trade-offs↩ Back to where you were
three-tier memory: episodic (experience log)
A record of what happened, step by step.Used in: The 27 solutions with CrewAI, Use both: what you still build↩ Back to where you were
three-tier memory: long-term (vector store)
Knowledge saved outside the model and searched when needed.Used in: The 27 solutions with CrewAI↩ Back to where you were
three-tier memory: short-term (context window)
What the AI sees in the current call.Used in: The 27 solutions with CrewAI, Use both: what you still build↩ Back to where you were
token counting middleware
Code that counts tokens before every AI call and acts when the window gets too full.Used in: The 27 solutions with CrewAI, Use both: what you still build↩ Back to where you were
tool
A function the AI can call, such as policy search.Used in: The 27 solutions with CrewAI↩ Back to where you were
ttl (time-to-live) expiration
Deleting saved data automatically after a set time.Used in: The 27 solutions with CrewAI, Use both: what you still build↩ Back to where you were
vector compression via rag
Storing text as vectors and pulling back only the parts that match.Used in: The 27 solutions with CrewAI↩ Back to where you were