Skip to main content
Memory stores conversation history, enabling agents to maintain context across interactions.

Quick Start

1

Enable Agent Memory

2

Clear Memory


User Interaction Flow


Memory

Main memory manager for agents.

Factory Methods

Instance Methods


MemoryConfig

Configuration for memory behavior.

Configuration Options


ConversationHistory

Low-level message storage with automatic trimming.

Methods

Note: When trimming, system messages are preserved - only user/assistant messages are removed.

MemoryAdapter Trait

Interface for custom memory backends.

InMemoryAdapter

Default in-memory implementation.

Methods


Custom Memory Adapter


Best Practices

Too many messages increase token usage and cost. Start with 50-100.
Use clear_memory() when starting unrelated conversations.
The trimming algorithm keeps system messages - only user/assistant messages are removed when exceeding limits.
For long histories, use search() to find relevant past messages instead of loading everything.

Agent

Agent API

Sessions

Session persistence