Context vs Memory
PraisonAI provides two distinct systems for managing information flow between agents: Context and Memory. Understanding when to use each is crucial for building efficient multi-agent workflows.Quick Comparison
| Aspect | Context | Memory |
|---|---|---|
| Lifetime | Single session | Persists across sessions |
| Storage | In-memory only | File/Database |
| Scope | Current workflow | All workflows |
| Use Case | Passing data between agents | Learning & remembering |
| Performance | Fast (no I/O) | Slower (disk/network) |
| Dependencies | None | Optional (chromadb, etc.) |
Context: Ephemeral Data Flow
Context is the default way agents share information within a single workflow execution. Data flows from one agent to the next and is lost when the session ends.How Context Works
Output Becomes Context
Agent’s output is automatically passed as context to the next agent via
{{previous_output}}.Context Manager Optimizes
The Context Manager handles token limits, deduplication, and summarization.
Context Configuration
Context Code Example
Memory: Persistent Knowledge
Memory allows agents to store and recall information across sessions. Unlike context, memory persists to disk and can be accessed by any agent at any time.Memory Types
Short-term Memory
Rolling buffer of recent interactions. Auto-expires. Fast access.
Long-term Memory
Persistent facts and knowledge. Survives restarts. Searchable.
Entity Memory
Named entities with attributes and relationships.
Episodic Memory
Date-based interaction history.
Memory Code Example
Memory Configuration
When to Use Each
Use Context When:
- Single workflow execution - Data only needed during current run
- Agent-to-agent handoffs - Passing results between sequential agents
- Performance critical - No disk I/O overhead
- Stateless operations - Each run is independent
Use Memory When:
- User preferences - Remember settings across sessions
- Learning systems - Build knowledge over time
- Conversation history - Multi-turn interactions
- Entity tracking - Track people, places, concepts
Using Both Together
The most powerful pattern combines both: Context for workflow data flow + Memory for persistent learning.Performance Comparison
| Operation | Context | Memory (File) | Memory (ChromaDB) |
|---|---|---|---|
| Read | ~0ms | ~1-5ms | ~10-50ms |
| Write | ~0ms | ~5-10ms | ~50-100ms |
| Search | N/A | ~10ms | ~20-100ms |
| Dependencies | None | None | chromadb |
Context is always faster because it’s in-memory only. Use memory only when persistence is required.
Summary
Context
Ephemeral - Fast data flow between agents within a single session. No persistence. Zero overhead.
Memory
Persistent - Store and recall information across sessions. Learning capability. Requires storage.

