Skip to main content

ConfirmationProvider

Trait ConfirmationProvider 

Source
pub trait ConfirmationProvider: Send + Sync {
    // Required methods
    fn requires_confirmation<'life0, 'life1, 'async_trait>(
        &'life0 self,
        tool_name: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn request_confirmation<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        tool_id: &'life1 str,
        tool_name: &'life2 str,
        args: &'life3 Value,
    ) -> Pin<Box<dyn Future<Output = Receiver<ConfirmationResponse>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
    fn confirm<'life0, 'life1, 'async_trait>(
        &'life0 self,
        tool_id: &'life1 str,
        approved: bool,
        reason: Option<String>,
    ) -> Pin<Box<dyn Future<Output = Result<bool, String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn policy<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = ConfirmationPolicy> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn set_policy<'life0, 'async_trait>(
        &'life0 self,
        policy: ConfirmationPolicy,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn check_timeouts<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = usize> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn cancel_all<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = usize> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Trait for confirmation providers (HITL runtime behavior)

This trait abstracts the confirmation flow, allowing different implementations (e.g., interactive, auto-approve, test mocks) while keeping the agent logic clean.

Required Methods§

Source

fn requires_confirmation<'life0, 'life1, 'async_trait>( &'life0 self, tool_name: &'life1 str, ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Check if a tool requires confirmation

Source

fn request_confirmation<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, tool_id: &'life1 str, tool_name: &'life2 str, args: &'life3 Value, ) -> Pin<Box<dyn Future<Output = Receiver<ConfirmationResponse>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Request confirmation for a tool execution

Returns a receiver that will receive the confirmation response.

Source

fn confirm<'life0, 'life1, 'async_trait>( &'life0 self, tool_id: &'life1 str, approved: bool, reason: Option<String>, ) -> Pin<Box<dyn Future<Output = Result<bool, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Handle a confirmation response from the user

Returns Ok(true) if the confirmation was found and processed, Ok(false) if no pending confirmation was found.

Source

fn policy<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = ConfirmationPolicy> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the current policy

Source

fn set_policy<'life0, 'async_trait>( &'life0 self, policy: ConfirmationPolicy, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Update the confirmation policy

Source

fn check_timeouts<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = usize> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Check for and handle timed out confirmations

Source

fn cancel_all<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = usize> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Cancel all pending confirmations

Implementors§