strands.memory.extraction.types
Primitive types for the memory extraction subsystem.
ExtractionResult
Section titled “ExtractionResult”@dataclassclass ExtractionResult()Defined in: src/strands/memory/extraction/types.py:37
A discrete entry produced by an :class:Extractor, ready to write via add.
ExtractorContext
Section titled “ExtractorContext”@dataclassclass ExtractorContext()Defined in: src/strands/memory/extraction/types.py:45
Context passed to :meth:Extractor.extract.
Attributes:
default_model- The agent’s model, supplied so an extractor can default to it.
Extractor
Section titled “Extractor”class Extractor(Protocol)Defined in: src/strands/memory/extraction/types.py:56
Transforms conversation messages into discrete, searchable entries.
Optional on a store’s :class:ExtractionConfig: when absent, the manager
passes messages straight to the store’s add_messages (the no-extractor
passthrough), which is the right path for backends that extract server-side.
extract
Section titled “extract”async def extract( messages: list[Message], context: ExtractorContext | None = None) -> list[ExtractionResult]Defined in: src/strands/memory/extraction/types.py:64
Extract entries from a batch of messages.
MemoryMessageFilter
Section titled “MemoryMessageFilter”@dataclassclass MemoryMessageFilter()Defined in: src/strands/memory/extraction/types.py:70
Filters content blocks out of messages before extraction.
Blocks whose kind is in :attr:exclude are stripped; a message left with no
content is dropped. Defaults to excluding tool traffic (toolUse /
toolResult).
ExtractionTriggerContext
Section titled “ExtractionTriggerContext”@dataclassclass ExtractionTriggerContext()Defined in: src/strands/memory/extraction/types.py:86
Context handed to :meth:ExtractionTrigger.attach.
Attributes:
agent- The agent the trigger attaches its hooks to.fire- Save this store’s unsaved messages now. Runs in the background and returns immediately. To await completion, seeMemoryManager.flush.
ExtractionTrigger
Section titled “ExtractionTrigger”class ExtractionTrigger(ABC)Defined in: src/strands/memory/extraction/types.py:99
Controls when a store’s :class:ExtractionConfig runs.
A trigger is a self-attaching value object: :meth:attach wires the agent
hooks it needs and calls :attr:ExtractionTriggerContext.fire when extraction
should happen. Subclass for custom triggering logic. A trigger that never
fires never extracts; for a guaranteed final write, use
MemoryManager.flush.
Attributes:
name- Stable identifier for this trigger kind, used in logging.
attach
Section titled “attach”@abstractmethoddef attach(context: ExtractionTriggerContext) -> NoneDefined in: src/strands/memory/extraction/types.py:115
Wire this trigger into the agent lifecycle.
Called once per store during MemoryManager initialization. Register
hooks on context.agent and call context.fire() when extraction
should run.
ExtractionConfig
Section titled “ExtractionConfig”@dataclassclass ExtractionConfig()Defined in: src/strands/memory/extraction/types.py:126
Per-store automatic-extraction configuration.
Attributes:
trigger- When to run extraction. A single trigger or a non-empty list; multiple triggers compose (extraction runs whenever any fires).extractor- How to turn messages into entries. When set, the store must implementadd. When omitted, the manager hands the filtered messages straight to the store’sadd_messages(for backends that extract server-side).filter- Content blocks to strip before extraction. Defaults to :data:DEFAULT_MEMORY_MESSAGE_FILTER(excludestoolUse/toolResult). PassMemoryMessageFilter(exclude=[])to keep tool blocks.