strands.memory.extraction.triggers
Built-in extraction triggers that control when a store’s extraction runs.
- :class:
InvocationTrigger— fire after every agent invocation. - :class:
IntervalTrigger— fire once everyturnsinvocations.
See :class:ExtractionTrigger for the self-attaching trigger contract.
InvocationTrigger
Section titled “InvocationTrigger”class InvocationTrigger(ExtractionTrigger)Defined in: src/strands/memory/extraction/triggers.py:16
Runs extraction after every agent invocation.
The highest-fidelity option, and the most expensive when an
:class:~strands.memory.extraction.types.Extractor is configured (a model
call per turn).
Example:
ExtractionConfig(trigger=[InvocationTrigger()])attach
Section titled “attach”def attach(context: ExtractionTriggerContext) -> NoneDefined in: src/strands/memory/extraction/triggers.py:31
Register an after-invocation callback that fires extraction.
Runs after the SDK’s own after-invocation hooks so extraction sees the settled turn. The save runs in a background task, so the hook never blocks.
IntervalTrigger
Section titled “IntervalTrigger”class IntervalTrigger(ExtractionTrigger)Defined in: src/strands/memory/extraction/triggers.py:45
Runs extraction every turns agent invocations.
A controllable middle ground: the high-water mark still picks up the skipped turns when the trigger fires.
Example:
ExtractionConfig(trigger=[IntervalTrigger(turns=5)])Attributes:
name- Stable identifier for this trigger kind (interval).
__init__
Section titled “__init__”def __init__(turns: int) -> NoneDefined in: src/strands/memory/extraction/triggers.py:62
Initialize the trigger with a firing cadence.
Arguments:
turns- Run extraction once every this many invocations. Must be a positive integer.
Raises:
ValueError- Ifturnsis not a positive integer (boolis rejected even though it subclassesint).
attach
Section titled “attach”def attach(context: ExtractionTriggerContext) -> NoneDefined in: src/strands/memory/extraction/triggers.py:78
Register an after-invocation callback that fires every turns turns.
Each attach creates a fresh closure counter, so one trigger instance
shared across stores keeps an independent count per attachment.