Skip to content

Give your agent long-term memory

By default a Strands agent starts every conversation from zero: it cannot recall a user’s preferences, past decisions, or anything it learned in an earlier session. The MemoryManager gives an agent long-term memory that persists across sessions.

Memory works through memory stores, the backends that hold what the agent remembers. A store can be the built-in zero-setup test store, a managed service like Amazon Bedrock Knowledge Bases, or your own implementation. Across the stores you attach, the manager does three jobs:

  1. Recall - the agent searches stored knowledge on demand through a tool.
  2. Injection - the manager folds relevant knowledge into the prompt automatically, before the model runs.
  3. Extraction - turning conversation messages into memories and writing them to stores.

Recall and injection are enabled by default when you attach a store; writing memories is opt-in.

Attach a memory manager to an agent through the memory_managermemoryManager parameter. The test store needs no cloud account and persists to disk by default, so this agent remembers across restarts with no setup:

from strands import Agent
from strands.memory import MemoryManager
from strands.vended_memory_stores.test_memory_store import TestMemoryStore
# Persists to ~/.strands/memory/notes.json by default.
store = TestMemoryStore(name="notes")
agent = Agent(memory_manager=MemoryManager(stores=[store]))

With no further configuration, recall and injection are on. From here you choose a backend and control what the agent reads and writes.

New to memory? Reach for the test store to give an agent memory in one line, then control what your agent remembers to turn on writing and tune recall, injection, and extraction. For a production backend with semantic search, use the Bedrock Knowledge Base store.

Memory is one of three ways an agent carries state. Session management persists the full conversation so an agent can resume where it left off; conversation management keeps a session within the model’s context window; memory carries durable knowledge across sessions, without replaying past conversations.