Skip to content

strands.interventions.actions

Intervention action types.

Each action represents a typed decision that a handler returns after evaluating an event. The framework uses these to compose decisions across multiple handlers.

def default_evaluate(response: Any) -> bool

Defined in: src/strands/interventions/actions.py:26

Default evaluate function for the confirm action.

Accepts: True, ‘y’/‘yes’ (case-insensitive, whitespace-trimmed).

Arguments:

  • response - The human’s response value to evaluate.

Returns:

True if the response is considered an approval, False otherwise.

@dataclass(frozen=True)
class Proceed()

Defined in: src/strands/interventions/actions.py:45

Allow the operation to continue unchanged.

Arguments:

  • reason - Optional metadata for debugging/logging. Not shown to the model.
@dataclass(frozen=True)
class Deny()

Defined in: src/strands/interventions/actions.py:57

Block the operation. The reason is shown to the model as the cancellation message.

@dataclass(frozen=True)
class Guide()

Defined in: src/strands/interventions/actions.py:65

Provide feedback to steer behavior.

On beforeToolCall/beforeInvocation, sets cancel so the model sees the feedback. On beforeModelCall, injects feedback as a user message. On afterModelCall, the response is discarded and the model retries with feedback.

.. warning:: On after_model_call, Guide triggers a model retry. Handlers must ensure convergence (e.g., by tracking retry count and escalating to Deny after repeated failures). The framework imposes no retry cap on guide-triggered retries.

.. note:: On before_model_call and after_model_call, guidance messages are injected directly into agent.messages and bypass session management. Session managers will not track these injected messages.

@dataclass(frozen=True)
class Confirm()

Defined in: src/strands/interventions/actions.py:89

Request human approval before proceeding. Only supported on beforeToolCall.

Two modes depending on whether response is provided:

  • With response: passed as a preemptive value to the interrupt system, agent never pauses.
  • Without response: breaks out of the agent loop to pause for external resume.
@dataclass(frozen=True)
class Transform()

Defined in: src/strands/interventions/actions.py:105

Modify event content in-place.

The apply function mutates the event before execution proceeds. Later handlers in the pipeline see the transformed content.

Union of all intervention actions a handler can return.

Action-to-event compatibility matrix::

Actionbefore_invocationbefore_tool_callbefore_model_callafter_tool_callafter_model_call
Proceed
Denycancelcancelcancel
Guidecancel+cancel+injectinject + retry
Confirmconfirm
Transformapplyapplyapplyapplyapply

— = no-op (warns at runtime) cancel = sets event.cancel/cancel_tool, short-circuits (remaining handlers skipped) cancel+ = sets cancel with accumulated feedback from all guiding handlers confirm = uses preemptive response or interrupt, checks with evaluate, sets cancel if denied inject = appends accumulated feedback as a user message so the model sees it on this call inject + retry = appends accumulated feedback and retries so the model sees guidance apply = calls action.apply(event) for in-place mutation, later handlers see the change