pub trait ConfirmationProvider: Send + Sync {
Show 14 methods
// 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;
// Provided methods
fn snapshot_for_run(&self) -> Option<Arc<dyn ConfirmationProvider>> { ... }
fn requires_confirmation_for<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tool_name: &'life1 str,
_args: &'life2 Value,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn confirmation_available_for<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_tool_name: &'life1 str,
_args: &'life2 Value,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn policy_for<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_tool_name: &'life1 str,
_args: &'life2 Value,
) -> Pin<Box<dyn Future<Output = ConfirmationPolicy> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn cancel<'life0, 'life1, 'async_trait>(
&'life0 self,
tool_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn expire<'life0, 'life1, 'async_trait>(
&'life0 self,
tool_id: &'life1 str,
action: TimeoutAction,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn pending_confirmations<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Vec<PendingConfirmationInfo>> + 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§
Sourcefn 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 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
Sourcefn 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 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.
Sourcefn 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 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.
Sourcefn policy<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ConfirmationPolicy> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: '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,
Get the current policy
Sourcefn 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 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
Provided Methods§
Sourcefn snapshot_for_run(&self) -> Option<Arc<dyn ConfirmationProvider>>
fn snapshot_for_run(&self) -> Option<Arc<dyn ConfirmationProvider>>
Freeze host confirmation semantics for one agent run.
The returned provider may share its pending-request store with the session provider, but mode-dependent routing must no longer change after this snapshot is created. Stateless providers can keep the default and will be shared as-is.
Sourcefn requires_confirmation_for<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tool_name: &'life1 str,
_args: &'life2 Value,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn requires_confirmation_for<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tool_name: &'life1 str,
_args: &'life2 Value,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Check whether this exact invocation requires confirmation.
Providers that do not inspect arguments inherit the tool-level behavior. Composed child-run providers override this method so an Ask introduced by the parent boundary cannot be auto-approved by a child-local policy.
Sourcefn confirmation_available_for<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_tool_name: &'life1 str,
_args: &'life2 Value,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn confirmation_available_for<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_tool_name: &'life1 str,
_args: &'life2 Value,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Whether this provider can resolve confirmation for this invocation.
Most providers are always available. A composed child-run provider uses
this hook to fail closed before emitting a HITL request when the policy
scope that produced Ask deliberately has no provider (deny_on_ask),
or when a parent escalation boundary has no confirmation channel.
Sourcefn policy_for<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_tool_name: &'life1 str,
_args: &'life2 Value,
) -> Pin<Box<dyn Future<Output = ConfirmationPolicy> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn policy_for<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_tool_name: &'life1 str,
_args: &'life2 Value,
) -> Pin<Box<dyn Future<Output = ConfirmationPolicy> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Return the effective confirmation policy for this invocation.
Argument-insensitive providers inherit the session-wide policy. A composed provider overrides this so timeout behavior comes only from the child and/or parent scopes that actually requested confirmation.
Sourcefn cancel<'life0, 'life1, 'async_trait>(
&'life0 self,
tool_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn cancel<'life0, 'life1, 'async_trait>(
&'life0 self,
tool_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Cancel one exact pending confirmation.
The default uses the provider’s targeted confirm operation so existing
provider implementations remain source-compatible. Session shutdown
should use Self::cancel_all; invocation cancellation must use this
method so concurrent, unrelated confirmations remain pending.
Sourcefn expire<'life0, 'life1, 'async_trait>(
&'life0 self,
tool_id: &'life1 str,
action: TimeoutAction,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn expire<'life0, 'life1, 'async_trait>(
&'life0 self,
tool_id: &'life1 str,
action: TimeoutAction,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Settle one exact confirmation after its invocation deadline expires.
Providers may override this to emit a native timeout event. The default remains targeted and therefore cannot settle another invocation.
Sourcefn pending_confirmations<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Vec<PendingConfirmationInfo>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn pending_confirmations<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Vec<PendingConfirmationInfo>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Snapshot pending confirmations for status inspection.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".