Skip to content

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 every turns invocations.

See :class:ExtractionTrigger for the self-attaching trigger contract.

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()])
def attach(context: ExtractionTriggerContext) -> None

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

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).
def __init__(turns: int) -> None

Defined 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 - If turns is not a positive integer (bool is rejected even though it subclasses int).
def attach(context: ExtractionTriggerContext) -> None

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