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:
- Recall - the agent searches stored knowledge on demand through a tool.
- Injection - the manager folds relevant knowledge into the prompt automatically, before the model runs.
- 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.
Give your agent memory
Section titled “Give your agent memory”A running agent with memory
Section titled “A running agent with memory”Attach a memory manager to an agent through the memory_managermemoryManager
from strands import Agentfrom strands.memory import MemoryManagerfrom 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]))import { Agent, BedrockModel } from '@strands-agents/sdk'import { TestMemoryStore } from '@strands-agents/sdk/vended-memory-stores/test-memory-store'
// Persists to ~/.strands/memory/notes.json by default.const store = new TestMemoryStore({ name: 'notes' })
const agent = new Agent({ model: new BedrockModel(), 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.
Where to go next
Section titled “Where to go next”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.