Memory Handoff
This example shows CrewAI memory in action: one task records notes and the next task reuses them as context.
Requirements
- Python 3.10+
- An OpenAI API key set as an environment variable (
OPENAI_API_KEY)
Steps for running this example in the shell
- Install dependencies:
bash
python -m venv .venv
# macOS/Linux:
source .venv/bin/activate
# Windows Command Prompt:
.venv\Scripts\activate.bat
# Windows PowerShell:
.venv\Scripts\Activate.ps1
pip install -r requirements.txt- Export your API key as an environment variable:
bash
export OPENAI_API_KEY="sk-..." # Windows cmd: set OPENAI_API_KEY="sk-..." # Windows PowerShell: $env:OPENAI_API_KEY="sk-..."- Run the script:
bash
python memory_handoff.pyOutput
The script will print the initial notes and the final output to the console.
╭───────────────────────────────────────────────────────────────── ✅ Agent Final Answer ──────────────────────────────────────────────────────────────────╮
│ │
│ Agent: Responder │
│ │
│ Final Answer: │
│ Effective memory handoff is the process of transferring relevant information from one individual or system to another to ensure continuity. It │
│ requires clear, concise, and complete communication to avoid loss of critical information. Additionally, documentation and standardized handoff │
│ protocols improve the reliability and durability of memory transfer between parties. │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯