Skip to content

MemoryManager

Defined in: src/memory/memory-manager.ts:75

Provides cross-session memory retrieval and storage for agents.

Manages one or more MemoryStore backends, exposing search_memory and add_memory tools for agent-driven recall and persistence. Any tools the stores themselves provide (via MemoryStore.getTools) are registered alongside these.

import { Agent, MemoryManager } from '@strands-agents/sdk'
// Config shorthand
const agent = new Agent({
model,
memoryManager: { stores: [myStore], addToolConfig: true },
})
// Class instance (for programmatic access)
const memoryManager = new MemoryManager({ stores: [myStore], addToolConfig: true })
const agent = new Agent({ model, memoryManager })
await memoryManager.search('user preferences')
new MemoryManager(config): MemoryManager;

Defined in: src/memory/memory-manager.ts:89

ParameterType
configMemoryManagerConfig

MemoryManager

readonly name: "strands:memory-manager" = 'strands:memory-manager';

Defined in: src/memory/memory-manager.ts:76

A stable string identifier for the plugin. Used for logging, duplicate detection, and plugin management.

For strands-vended plugins, names should be prefixed with strands:.

Plugin.name

initAgent(agent): void;

Defined in: src/memory/memory-manager.ts:189

Initializes the plugin with the agent.

Wires up automatic extraction for any store configured with ExtractionConfig: buffers conversation messages and attaches each store’s triggers. A no-op when no store uses extraction.

ParameterTypeDescription
agentLocalAgentThe agent this plugin is being attached to

void

Plugin.initAgent


flush(): Promise<void>;

Defined in: src/memory/memory-manager.ts:221

Saves every store’s remaining messages and waits for all saves to finish. No-op when no store has extraction configured.

Extraction normally runs in the background, so the most recent turn may not be saved yet when the agent responds. Call this once at a boundary you control - typically your app’s shutdown handler - so nothing is lost. A process killed before then (crash, hard timeout) may still lose the last unsaved turn; a more frequent trigger narrows that window.

Do not call this after every turn alongside a periodic trigger: it forces a save each time and so defeats the trigger’s schedule.

Promise<void>


getTools(): Tool[];

Defined in: src/memory/memory-manager.ts:233

Returns tools registered by this plugin.

Includes the manager’s own search_memory / add_memory tools (per their config) plus any tools the configured stores expose via MemoryStore.getTools.

Tool[]

Array of tools to register with the agent

Plugin.getTools


search(query, options?): Promise<MemoryEntry[]>;

Defined in: src/memory/memory-manager.ts:269

Search stores for entries matching the query. If stores is provided, only searches to those named stores.

This method is unscoped with full access to all configured stores. Tool-level store scoping is applied by the search tool callback. When options.stores is omitted, all stores are searched.

Only maxSearchResults and routing (stores) cross this layer. Store-specific search parameters (e.g. a Bedrock metadata filter or search-type override) are not expressible here across heterogeneous stores — set them as per-instance defaults on the store, or call the store’s own search() directly for full control. Per-instance store policy (such as a tenant filter) always applies, including when reached through the search_memory tool.

ParameterTypeDescription
querystringThe search query string
options?MemorySearchOptionsOptional max results (forwarded to all stores) and store name filter

Promise<MemoryEntry[]>

Array of memory entries from matching stores


add(content, options?): Promise<void>;

Defined in: src/memory/memory-manager.ts:324

Add content to writable stores. If stores is provided, only writes to those named stores; otherwise all writable stores are targeted.

This method is unscoped, with full access to all configured writable stores; tool-level store scoping is applied by the add tool callback. Target stores are validated first (an unknown or read-only named store throws), then the writes are awaited: per-store failures are logged, and an AggregateError is thrown if any store fails.

ParameterTypeDescription
contentstringThe text content to add
options?MemoryAddOptionsOptional metadata and store name filter

Promise<void>