Skip to main content

Module hitl

Module hitl 

Source
Expand description

Human-in-the-loop approval of tool calls.

HumanInTheLoop asks a human before tool calls. By default the agent stops with an interrupt and the caller resumes it with the answer; give it an ask callback (or HumanInTheLoopAsk::Stdio) to ask inline instead.

use strands::Agent;
use strands::testing::MockModel;
use strands::vended_interventions::hitl::{HumanInTheLoop, HumanInTheLoopConfig};

let hitl = HumanInTheLoop::new(HumanInTheLoopConfig {
    allowed_tools: vec!["read_file".into()],
    ..Default::default()
});
let agent = Agent::builder()
    .model(MockModel::new())
    .interventions([hitl])
    .printer(false)
    .build()?;

Structs§

AskFn
Collects a human’s answer inline. The answer is None when there is none, which denies the call.
ClassifierResult
A classifier’s decision (ClassifierResult).
HumanInTheLoop
Asks a human before tool calls run (HumanInTheLoop).
HumanInTheLoopAutoConfig
What HumanInTheLoop::auto accepts (HumanInTheLoopAutoConfig): how the human is reached and the calls that skip the decision entirely. The approval strategy is the mode’s to choose.
HumanInTheLoopAutoConfigBuilder
Use builder syntax to set the inputs and finish with build().
HumanInTheLoopConfig
Settings of a HumanInTheLoop (HumanInTheLoopConfig).
HumanInTheLoopConfigBuilder
Use builder syntax to set the inputs and finish with build().
LlmClassifierConfig
Settings of the built-in LLM risk classifier (LlmClassifierConfig).

Enums§

ClassifierConfig
How a HumanInTheLoop decides which tool calls need a human (classifier): the built-in LLM risk classifier or a custom classifier.
HumanInTheLoopAsk
How a HumanInTheLoop collects answers inline (ask).

Constants§

HUMAN_IN_THE_LOOP_NAME
The name of the handler and of the interrupts it raises.
TRUSTED_TOOLS_KEY
The app-state key of the tools trusted for the session.

Traits§

HumanInTheLoopClassifier
Decides whether a tool call needs human approval (HumanInTheLoopClassifier).