pub struct PromptingConfirmationHandler { /* private fields */ }harness only.Expand description
A ToolConfirmationHandler that asks an ApprovalPrompter (spec 3.1 §7.5).
Prompts are serialized, because calls in a batch are decided concurrently, and capped
per turn of each session. Before prompting, the call is decided again by the run’s whole policy — the
harness layer with the call’s origin, made stricter by the run’s and the operator’s
layers — so a rule granted for an earlier call in the same batch applies without a
prompt when only the harness asked. A call another layer requires approval for, or the
agent’s confirmation policy holds, is always put to the person. An approval with edited arguments returns them through decide_approval, and
the governed path checks them against the policy again. After a person denies a call,
the rest of the turn’s calls are denied (I19).
§Example
let harness = HarnessAgent::builder("harness")
.model(model)
.workspace(workspace)
.prompter(Arc::new(ConsolePrompter::new()))
.build()?;Implementations§
Source§impl PromptingConfirmationHandler
impl PromptingConfirmationHandler
Sourcepub fn new(
prompter: Arc<dyn ApprovalPrompter>,
standing: Arc<dyn StandingRuleStore>,
policy: HarnessPolicy,
) -> PromptingConfirmationHandler
pub fn new( prompter: Arc<dyn ApprovalPrompter>, standing: Arc<dyn StandingRuleStore>, policy: HarnessPolicy, ) -> PromptingConfirmationHandler
A handler asking prompter, granting remembered rules in standing, and
re-checking each call against policy.
Sourcepub async fn prompt_elicitation(
&self,
turn: (&str, &str, &str, &str),
prompt: ApprovalPrompt,
) -> Result<Option<PromptAnswer>, AdkError>
pub async fn prompt_elicitation( &self, turn: (&str, &str, &str, &str), prompt: ApprovalPrompt, ) -> Result<Option<PromptAnswer>, AdkError>
Shows prompt under this handler’s serial mutex and per-turn cap, for a request
that is not a held tool call: an MCP server’s elicitation (spec 3.1 §7.21).
turn is the (app, user, session, invocation) the request belongs to. Returns
Ok(None) when the turn reached its prompt cap or a person denied its remaining
calls, so the caller declines.
§Errors
Returns the prompter’s error.
Sourcepub fn with_per_turn_cap(self, cap: usize) -> PromptingConfirmationHandler
pub fn with_per_turn_cap(self, cap: usize) -> PromptingConfirmationHandler
Sets the most prompts one turn may show (default DEFAULT_PROMPTS_PER_TURN).
Trait Implementations§
Source§impl Debug for PromptingConfirmationHandler
impl Debug for PromptingConfirmationHandler
Source§impl ToolConfirmationHandler for PromptingConfirmationHandler
impl ToolConfirmationHandler for PromptingConfirmationHandler
Source§fn batch_started<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
calls: &'life1 [BatchCall<'life2>],
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
PromptingConfirmationHandler: 'async_trait,
fn batch_started<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
calls: &'life1 [BatchCall<'life2>],
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
PromptingConfirmationHandler: 'async_trait,
Keeps the turn’s batch, so its held edits are reviewed as one change set (spec 3.1 §7.26, §10 C6).
Source§fn decide<'life0, 'life1, 'async_trait>(
&'life0 self,
request: &'life1 ToolConfirmationRequest,
) -> Pin<Box<dyn Future<Output = Result<ToolConfirmationDecision, AdkError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
PromptingConfirmationHandler: 'async_trait,
fn decide<'life0, 'life1, 'async_trait>(
&'life0 self,
request: &'life1 ToolConfirmationRequest,
) -> Pin<Box<dyn Future<Output = Result<ToolConfirmationDecision, AdkError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
PromptingConfirmationHandler: 'async_trait,
Source§fn decide_approval<'life0, 'life1, 'async_trait>(
&'life0 self,
request: &'life1 ToolConfirmationRequest,
) -> Pin<Box<dyn Future<Output = Result<ToolApproval, AdkError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
PromptingConfirmationHandler: 'async_trait,
fn decide_approval<'life0, 'life1, 'async_trait>(
&'life0 self,
request: &'life1 ToolConfirmationRequest,
) -> Pin<Box<dyn Future<Output = Result<ToolApproval, AdkError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
PromptingConfirmationHandler: 'async_trait,
Auto Trait Implementations§
impl !Freeze for PromptingConfirmationHandler
impl !RefUnwindSafe for PromptingConfirmationHandler
impl !UnwindSafe for PromptingConfirmationHandler
impl Forget for PromptingConfirmationHandler
impl Move for PromptingConfirmationHandler
impl Send for PromptingConfirmationHandlerwhere
Arc<dyn ApprovalPrompter>: Send,
Arc<dyn StandingRuleStore>: Send,
Arc<PolicyInner>: Send,
Arc<dyn AuditRecorder>: Send,
Arc<dyn ToolPolicy>: Send,
RawVecInner: Send,
Arc<ControlState>: Send,
Mutex<Turns>: Send,
Mutex<BatchBook>: Send,
NodeRef<Owned, UsageUnit, u64, LeafOrInternal>: Send,
BoxRaw<(UsageUnit, u64)>: Send,
NodeRef<Owned, PartitionId, SetValZST, LeafOrInternal>: Send,
BoxRaw<(PartitionId, SetValZST)>: Send,
Arc<PartitionsInner>: Send,
Arc<RwLock<BTreeMap<String, CrossingRoute>>>: Send,
impl Sync for PromptingConfirmationHandlerwhere
Arc<dyn ApprovalPrompter>: Sync,
Arc<dyn StandingRuleStore>: Sync,
Arc<PolicyInner>: Sync,
Arc<dyn AuditRecorder>: Sync,
Arc<dyn ToolPolicy>: Sync,
RawVecInner: Sync,
Arc<ControlState>: Sync,
Mutex<Turns>: Sync,
Mutex<BatchBook>: Sync,
NodeRef<Owned, UsageUnit, u64, LeafOrInternal>: Sync,
BoxRaw<(UsageUnit, u64)>: Sync,
NodeRef<Owned, PartitionId, SetValZST, LeafOrInternal>: Sync,
BoxRaw<(PartitionId, SetValZST)>: Sync,
Arc<PartitionsInner>: Sync,
Arc<RwLock<BTreeMap<String, CrossingRoute>>>: Sync,
impl Unpin for PromptingConfirmationHandlerwhere
Arc<dyn ApprovalPrompter>: Unpin,
Arc<dyn StandingRuleStore>: Unpin,
Arc<PolicyInner>: Unpin,
Arc<dyn AuditRecorder>: Unpin,
Arc<dyn ToolPolicy>: Unpin,
*const u8 is !null: Unpin,
Arc<ControlState>: Unpin,
Align4<u32>: Unpin,
Align1<u8>: Unpin,
*const Waiter is !null: Unpin,
Align8<usize>: Unpin,
NonZero<i32>: Unpin,
Utc: Unpin,
*const LeafNode<UsageUnit, u64> is !null: Unpin,
Box<(UsageUnit, u64)>: Unpin,
*const LeafNode<PartitionId, SetValZST> is !null: Unpin,
Box<(PartitionId, SetValZST)>: Unpin,
Arc<PartitionsInner>: Unpin,
Arc<RwLock<BTreeMap<String, CrossingRoute>>>: Unpin,
impl UnsafeUnpin for PromptingConfirmationHandlerwhere
*const ArcInner<dyn ApprovalPrompter> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn ApprovalPrompter>>: UnsafeUnpin,
*const ArcInner<dyn StandingRuleStore> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn StandingRuleStore>>: UnsafeUnpin,
*const ArcInner<PolicyInner> is !null: UnsafeUnpin,
PhantomData<ArcInner<PolicyInner>>: UnsafeUnpin,
*const ArcInner<dyn AuditRecorder> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn AuditRecorder>>: UnsafeUnpin,
*const ArcInner<dyn ToolPolicy> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn ToolPolicy>>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<GovernanceControl>: UnsafeUnpin,
Align4<u32>: UnsafeUnpin,
Align1<u8>: UnsafeUnpin,
*const Waiter is !null: UnsafeUnpin,
Align8<usize>: UnsafeUnpin,
PhantomData<(String, TurnState)>: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
PhantomData<(u64, Batch)>: UnsafeUnpin,
PhantomData<(String, u64)>: UnsafeUnpin,
PhantomData<u64>: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
*const LeafNode<UsageUnit, u64> is !null: UnsafeUnpin,
PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin,
PhantomData<Box<(UsageUnit, u64)>>: UnsafeUnpin,
*const LeafNode<PartitionId, SetValZST> is !null: UnsafeUnpin,
PhantomData<Box<(PartitionId, SetValZST)>>: UnsafeUnpin,
*const ArcInner<PartitionsInner> is !null: UnsafeUnpin,
PhantomData<ArcInner<PartitionsInner>>: UnsafeUnpin,
*const ArcInner<RwLock<BTreeMap<String, CrossingRoute>>> is !null: UnsafeUnpin,
PhantomData<ArcInner<RwLock<BTreeMap<String, CrossingRoute>>>>: UnsafeUnpin,
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> 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 moreimpl<T> MaybeSend for Twhere
T: Send,
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.