Skip to main content

Overview

Memory in the context of an agent refers to the system’s capability to store, recall, and utilize information from past interactions. This enables the agent to maintain context over time, improve its responses based on previous exchanges, and provide a more personalized experience. BeeAI framework provides several memory implementations:
Supported in Python and TypeScript.

Core concepts

Messages

Messages are the fundamental units stored in memory, representing interactions between users and agents:
  • Each message has a role (USER, ASSISTANT, SYSTEM)
  • Messages contain text content
  • Messages can be added, retrieved, and processed

Memory types

Different memory strategies are available depending on your requirements:
  • Unconstrained - Store unlimited messages
  • Sliding Window - Keep only the most recent N messages
  • Token-based - Manage a token budget to stay within model context limits
  • Summarization - Compress previous interactions into summaries

Integration points

Memory components integrate with other parts of the framework:
  • LLMs use memory to maintain conversation context
  • Agents access memory to process and respond to interactions
  • Workflows can share memory between different processing steps

Basic usage

Capabilities showcase

Usage with LLMs

Memory for non-chat LLMs works exactly the same way.

Usage with agents

If your memory already contains the user message, run the agent with prompt: null.
ReAct Agent internally uses TokenMemory to store intermediate steps for a given run.

Memory types

The framework provides multiple out-of-the-box memory implementations for different use cases.

UnconstrainedMemory

Unlimited in size, stores all messages without constraints.

SlidingMemory

Keeps last k entries in the memory. The oldest ones are deleted (unless specified otherwise).

TokenMemory

Ensures that the token sum of all messages is below the given threshold. If overflow occurs, the oldest message will be removed.

SummarizeMemory

Only a single summarization of the conversation is preserved. Summarization is updated with every new message.

Creating custom memory

To create your memory implementation, you must implement the BaseMemory class.
The simplest implementation is UnconstrainedMemory.

Examples

Python

Explore reference memory implementations in Python

TypeScript

Explore reference memory implementations in TypeScript