Skip to main content
Memory systems allow agents to retrieve relevant context from past conversations, documents, or external knowledge bases.

Overview

AgentChat supports memory through the Memory interface. Agents can query memory systems to augment their context before generating responses.

Memory interface

Memory systems implement the Memory protocol:

Vector memory

For semantic search over documents:

Agent state

Agents maintain state across messages through AgentState:

Team state

Teams also maintain state:

Conversation history

Agents automatically maintain conversation history:

Context management

Control how much context is sent to the LLM:

Memory with RAG

Combine memory with Retrieval-Augmented Generation:

Persistent memory

Save and restore agent state across sessions:

Memory events

Agents emit memory query events:

Best practices

Vector memory with embeddings is ideal for searching large knowledge bases.
Use BufferedChatCompletionContext to prevent context overflow and reduce costs.
Keep recent conversation in agent state, use vector memory for long-term knowledge.
Save agent state after critical interactions for recovery and continuity.

Memory integration examples

Example: FAQ bot with memory

Example: Conversation summarization

Next steps

Extensions Overview

Advanced extension patterns

State Management

Team state patterns

Examples

See memory in action

Custom Agents

Build memory-aware agents