pub struct HumanInTheLoop { /* private fields */ }Expand description
Asks a human before tool calls run (HumanInTheLoop).
Which calls need approval, first match wins: a !tool entry always does; a tool trusted at
runtime (with enable_trust) does not; * or a listed tool does not; then the classifier
decides; without one, every call does. The prompt is
Approve "<tool>"[ — <reason>]?\n Input: <json>; with interrupts it is the interrupt’s
reason, under the interrupt name strands:human-in-the-loop.
Implementations§
Source§impl HumanInTheLoop
impl HumanInTheLoop
Sourcepub fn auto(config: HumanInTheLoopAutoConfig) -> Self
pub fn auto(config: HumanInTheLoopAutoConfig) -> Self
Auto mode ('auto'): the SDK’s current best approval strategy decides which calls need a
human. Today that is the built-in LLM risk classifier, the same as
ClassifierConfig::llm: low-risk calls run on their own and risky ones are escalated.
What auto mode resolves to may change between releases; pass a full
HumanInTheLoopConfig to new to pin the strategy.
use strands::vended_interventions::hitl::{HumanInTheLoop, HumanInTheLoopAsk, HumanInTheLoopAutoConfig};
let hitl = HumanInTheLoop::auto(HumanInTheLoopAutoConfig {
allowed_tools: vec!["read_file".into()],
ask: Some(HumanInTheLoopAsk::Stdio),
});Sourcepub fn new(config: HumanInTheLoopConfig) -> Self
pub fn new(config: HumanInTheLoopConfig) -> Self
A handler with these settings.
Trait Implementations§
Source§impl Debug for HumanInTheLoop
impl Debug for HumanInTheLoop
Source§impl Default for HumanInTheLoop
impl Default for HumanInTheLoop
Source§impl InterventionHandler for HumanInTheLoop
impl InterventionHandler for HumanInTheLoop
Source§fn name(&self) -> &str
fn name(&self) -> &str
Confirm raises.Source§fn before_tool_call<'life0, 'life1, 'async_trait>(
&'life0 self,
event: &'life1 mut BeforeToolCallEvent,
) -> Pin<Box<dyn Future<Output = InterventionResult<BeforeToolCallEvent>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn before_tool_call<'life0, 'life1, 'async_trait>(
&'life0 self,
event: &'life1 mut BeforeToolCallEvent,
) -> Pin<Box<dyn Future<Output = InterventionResult<BeforeToolCallEvent>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn on_error(&self) -> OnError
fn on_error(&self) -> OnError
OnError::Throw.Source§fn before_invocation<'a, 'life0, 'life1, 'async_trait>(
&'life0 self,
_event: &'life1 mut BeforeInvocationEvent<'a>,
) -> Pin<Box<dyn Future<Output = InterventionResult<BeforeInvocationEvent<'a>>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn before_invocation<'a, 'life0, 'life1, 'async_trait>(
&'life0 self,
_event: &'life1 mut BeforeInvocationEvent<'a>,
) -> Pin<Box<dyn Future<Output = InterventionResult<BeforeInvocationEvent<'a>>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn after_tool_call<'life0, 'life1, 'async_trait>(
&'life0 self,
_event: &'life1 mut AfterToolCallEvent,
) -> Pin<Box<dyn Future<Output = InterventionResult<AfterToolCallEvent>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn after_tool_call<'life0, 'life1, 'async_trait>(
&'life0 self,
_event: &'life1 mut AfterToolCallEvent,
) -> Pin<Box<dyn Future<Output = InterventionResult<AfterToolCallEvent>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn before_model_call<'a, 'life0, 'life1, 'async_trait>(
&'life0 self,
_event: &'life1 mut BeforeModelCallEvent<'a>,
) -> Pin<Box<dyn Future<Output = InterventionResult<BeforeModelCallEvent<'a>>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn before_model_call<'a, 'life0, 'life1, 'async_trait>(
&'life0 self,
_event: &'life1 mut BeforeModelCallEvent<'a>,
) -> Pin<Box<dyn Future<Output = InterventionResult<BeforeModelCallEvent<'a>>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn after_model_call<'a, 'life0, 'life1, 'async_trait>(
&'life0 self,
_event: &'life1 mut AfterModelCallEvent<'a>,
) -> Pin<Box<dyn Future<Output = InterventionResult<AfterModelCallEvent<'a>>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn after_model_call<'a, 'life0, 'life1, 'async_trait>(
&'life0 self,
_event: &'life1 mut AfterModelCallEvent<'a>,
) -> Pin<Box<dyn Future<Output = InterventionResult<AfterModelCallEvent<'a>>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Auto Trait Implementations§
impl !Freeze for HumanInTheLoop
impl !RefUnwindSafe for HumanInTheLoop
impl !UnwindSafe for HumanInTheLoop
impl Send for HumanInTheLoop
impl Sync for HumanInTheLoop
impl Unpin for HumanInTheLoop
impl UnsafeUnpin for HumanInTheLoop
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more