Skip to content

strands.memory.types

Core types for the Strands memory module.

@dataclass
class 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 by MemoryManager.search. Stores need not set this themselves.
@dataclass
class 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.

@dataclass
class 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.

@dataclass
class 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 the search_memory tool treats an empty list as “search all in-scope stores”.
@dataclass
class 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 the add_memory tool treats an empty list as “write to all in-scope stores”.
@dataclass
class MemoryToolConfig()

Defined in: src/strands/memory/types.py:84

Configuration for customizing a memory tool’s name or description.

@dataclass
class 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:MemoryStore instances. Omit to allow all writable stores.
  • wait_for_writes - When True (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.
@dataclass
class 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 to True.
  • add_tool_config - Add tool configuration. Defaults to False (opt-in); True allows all writable stores, or pass a :class:MemoryAddToolConfig to restrict it.
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.add or :meth:MemoryStore.add_messages).
  • extraction - Automatic-extraction configuration. Requires the store to be writable.
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.

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) -> Any

Defined 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.

async def add_messages(messages: list[Message],
context: AddMessagesContext | None = None) -> Any

Defined 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.

def get_tools() -> list[AgentTool]

Defined in: src/strands/memory/types.py:180

Return store-specific tools to register alongside the manager’s tools.