Skip to content

Gate tool calls with interventions

An intervention decides whether a tool call runs. By default Strands harness applies none, so every call proceeds. Pass interventions to gate calls behind human approval or a policy. The option is sugar over the Strands Harness SDK’s intervention handlers: a preset, a policy string, a Cedar file, a Strands Harness SDK handler instance, or a list of these.

The two presets cover the common cases:

  • "ask" gates every tool call for approval.
  • "smart" uses the Strands Harness SDK’s risk classifier to flag risky calls and gates only those.
# pip install strands-harness
from strands_harness import create_harness
agent = create_harness(interventions="ask") # approve every tool call

Any string that is not a preset and does not end in .cedar is treated as a natural-language risk policy. It becomes the risk classifier’s prompt, so the model judges each call against your rule and escalates a match for approval, like "smart" with your own rubric:

# pip install strands-harness
from strands_harness import create_harness
agent = create_harness(
interventions="Ask before deleting files or making any network request.",
)

A string ending in .cedar loads a Cedar policy file for programmatic authorization. Cedar needs an optional dependency: strands-agents[cedar] in Python, or the @cedar-policy/cedar-wasm package in TypeScript.

from strands_harness import create_harness
agent = create_harness(interventions="./policies/agent.cedar")

Inline Cedar text is not auto-detected (it is indistinguishable from prose), so pass a CedarAuthorization instance directly for that.

Pass a Strands Harness SDK handler, or layer several

Section titled “Pass a Strands Harness SDK handler, or layer several”

For anything the presets do not cover (a custom approval callback, a Cedar principal resolver, bespoke trust rules), construct the Strands Harness SDK handler yourself and pass it; a handler instance passes through untouched. You can also pass a list to layer a Cedar policy with one human-approval gate. Two handlers of the same kind collide, since an agent registers at most one per name, so layer different kinds rather than duplicates.

The built-in generalist subagent inherits whatever interventions you set, so a subagent cannot bypass the gate you put on the main agent. For the underlying handlers, see the Strands Harness SDK’s interventions documentation. For the full option list, see the configuration reference.