strands.memory.types
Core types for the Strands memory module.
MemoryEntry
Section titled “MemoryEntry”@dataclassclass MemoryEntry()Defined in: src/strands/memory/types.py:21
A single memory entry retrieved from or stored to a memory store.
Attributes:
store_name- Name of the store this entry came from, set byMemoryManager.search. Stores need not set this themselves.
SearchOptions
Section titled “SearchOptions”@dataclassclass SearchOptions()Defined in: src/strands/memory/types.py:35
Options passed to :meth:MemoryStore.search.
Store implementations may extend this with backend-specific fields; note that
MemoryManager.search forwards only these base fields across its stores.
AddMessagesContext
Section titled “AddMessagesContext”@dataclassclass AddMessagesContext()Defined in: src/strands/memory/types.py:46
Context the manager supplies to :meth:MemoryStore.add_messages.
Intentionally empty for now so fields can be added later without a breaking signature change.
MemorySearchOptions
Section titled “MemorySearchOptions”@dataclassclass MemorySearchOptions(SearchOptions)Defined in: src/strands/memory/types.py:55
Options for MemoryManager.search.
Attributes:
stores- Filter to specific stores by name. Omit to search all. A programmatic search with an empty list searches no stores, whereas thesearch_memorytool treats an empty list as “search all in-scope stores”.
MemoryAddOptions
Section titled “MemoryAddOptions”@dataclassclass MemoryAddOptions()Defined in: src/strands/memory/types.py:69
Options for MemoryManager.add.
Attributes:
stores- Filter to specific writable stores by name. Omit to write to all. A programmatic add with an empty list matches no store (raises), whereas theadd_memorytool treats an empty list as “write to all in-scope stores”.
MemoryToolConfig
Section titled “MemoryToolConfig”@dataclassclass MemoryToolConfig()Defined in: src/strands/memory/types.py:84
Configuration for customizing a memory tool’s name or description.
MemoryAddToolConfig
Section titled “MemoryAddToolConfig”@dataclassclass MemoryAddToolConfig(MemoryToolConfig)Defined in: src/strands/memory/types.py:92
Configuration for the add_memory tool.
Attributes:
stores- The writable stores the tool may write to, as store names or :class:MemoryStoreinstances. Omit to allow all writable stores.wait_for_writes- WhenTrue(default), wait for writes and return- ```{“stored”` - …}
(or surface a failure to the model). WhenFalse, fire-and-forget: return{“accepted”: …}“ once writes are dispatched; per-store failures are logged.
MemoryManagerConfig
Section titled “MemoryManagerConfig”@dataclassclass MemoryManagerConfig()Defined in: src/strands/memory/types.py:109
Configuration for the MemoryManager, mirroring the constructor kwargs.
Attributes:
stores- One or more memory stores to manage.search_tool_config- Search tool configuration. Defaults toTrue.add_tool_config- Add tool configuration. Defaults toFalse(opt-in);Trueallows all writable stores, or pass a :class:MemoryAddToolConfigto restrict it.
MemoryStoreConfig
Section titled “MemoryStoreConfig”class MemoryStoreConfig(Protocol)Defined in: src/strands/memory/types.py:125
Declarative identity and behavior fields shared by every memory store.
Attributes:
name- Unique identifier for this store, used to target it in tools.description- Human-readable description; included in tool descriptions.max_search_results- Default maximum results per search, used when a caller does not pass a per-call value.writable- Whether this store accepts writes. A writable store requires at least one write sink (:meth:MemoryStore.addor :meth:MemoryStore.add_messages).extraction- Automatic-extraction configuration. Requires the store to be writable.
MemoryStore
Section titled “MemoryStore”class MemoryStore(MemoryStoreConfig, Protocol)Defined in: src/strands/memory/types.py:147
Runtime contract for a memory store backend.
Extends :class:MemoryStoreConfig with runtime methods. Every store is
searchable; writable declares whether it also accepts writes. A store
author implements the config fields plus :meth:search, and optionally
:meth:add, :meth:add_messages, and :meth:get_tools.
search
Section titled “search”async def search(query: str, options: SearchOptions | None = None) -> list[MemoryEntry]Defined in: src/strands/memory/types.py:156
Search the store for entries matching the query, ordered by relevance.
async def add(content: str, metadata: Metadata | None = None) -> AnyDefined in: src/strands/memory/types.py:162
Add a single piece of content to the store.
Extraction writes are at-least-once, so implementations used with extraction should tolerate duplicate writes. The resolved value is store-specific and not consumed by the manager.
add_messages
Section titled “add_messages”async def add_messages(messages: list[Message], context: AddMessagesContext | None = None) -> AnyDefined in: src/strands/memory/types.py:171
Ingest a batch of conversation messages, preserving role structure.
The sink for extraction without a client-side extractor: the manager hands the filtered batch straight here. The resolved value is store-specific.
get_tools
Section titled “get_tools”def get_tools() -> list[AgentTool]Defined in: src/strands/memory/types.py:180
Return store-specific tools to register alongside the manager’s tools.