Skip to main content

Why Memory Matters

An AI without memory is like a goldfish - every conversation starts from zero. Your users expect agents that:
  • Remember context - “As we discussed yesterday…”
  • Learn preferences - “You mentioned you prefer TypeScript…”
  • Build knowledge - Facts extracted from conversations persist
Memory is your agent’s brain. Messages, facts, relationships, goals - all stored, indexed, and searchable through embeddings.

Memory System

The memory system provides hierarchical storage for conversations, knowledge, and agent state. It enables agents to maintain context, learn from interactions, and build persistent knowledge.

Conceptual Overview

Understanding memory architecture

Runtime Core

How memory integrates with the runtime

Memory Types

Core Memory Types

Memory Interface

State Management

State Structure

State represents the agent’s current understanding of context:

State Composition Pipeline

Memory Operations

Creating Memories

Searching Memories

Memory Retrieval

Embeddings and Similarity

Creating Embeddings

Facts and Knowledge

Fact Extraction

Facts are automatically extracted from conversations:

Fact Management

Relationships

Relationship Storage

Managing Relationships

State Cache

Cache Architecture

The runtime maintains an in-memory cache for composed states:

Cache Management

Document Storage

Document Memory

Document Operations

Memory Cleanup

Automatic Cleanup

Manual Cleanup

Memory Optimization

Indexing Strategies

Batch Operations

Memory Compression

Best Practices

Memory Design

  • Type Selection: Use appropriate memory types for different data
  • Embedding Strategy: Generate embeddings for searchable content
  • Metadata Usage: Store relevant metadata for filtering
  • Relationship Tracking: Maintain entity relationships
  • Fact Extraction: Extract and store facts from conversations

Performance

  • Indexing: Create appropriate database indexes
  • Batch Operations: Use batch operations for multiple items
  • Caching: Cache frequently accessed memories
  • Cleanup: Implement regular cleanup routines
  • Compression: Compress old data to save space

Data Integrity

  • Validation: Validate memory content before storage
  • Deduplication: Prevent duplicate facts and relationships
  • Consistency: Maintain referential integrity
  • Versioning: Track memory updates and changes
  • Backup: Regular backup of critical memories

See Also

Events

Learn about the communication system

Providers

Understand how providers use memory

Models

Explore AI model integration

Services

Build services that manage memory