#[non_exhaustive]pub struct ExecuteToolContext {
pub agent: ToolAgent,
pub tool: Option<Arc<dyn Tool>>,
pub tool_use: ToolUse,
pub invocation_state: InvocationState,
/* private fields */
}Expand description
What tool-stage handlers receive (ExecuteToolContext). tool_use is a copy of the model’s
request; invocation_state is shared.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.agent: ToolAgentThe agent, as tools see it (an escape hatch).
tool: Option<Arc<dyn Tool>>The tool that runs, or None when the name is not registered.
tool_use: ToolUseThe tool use request.
invocation_state: InvocationStatePer-invocation state, shared.
Implementations§
Source§impl ExecuteToolContext
impl ExecuteToolContext
Sourcepub fn cancel_signal(&self) -> &CancelSignal
pub fn cancel_signal(&self) -> &CancelSignal
The executor’s cancellation signal for this call; observe it, it cannot be replaced.
Sourcepub fn interrupt(
&self,
params: impl Into<InterruptParams>,
) -> Result<MiddlewareInterruptResult, InterruptError>
pub fn interrupt( &self, params: impl Into<InterruptParams>, ) -> Result<MiddlewareInterruptResult, InterruptError>
Requests a human-in-the-loop interrupt (interrupt).
Returns the response on resume (or the preemptive params.response); otherwise the
interrupt, which ? turns into MiddlewareError::Interrupt so
the agent stops with StopReason::Interrupt and the tool does not run. The id is
middleware:executeTool:<toolUseId>:<name>.
§Errors
The unanswered interrupt.
Trait Implementations§
Source§impl Clone for ExecuteToolContext
impl Clone for ExecuteToolContext
Auto Trait Implementations§
impl !RefUnwindSafe for ExecuteToolContext
impl !UnwindSafe for ExecuteToolContext
impl Forget for ExecuteToolContext
impl Freeze for ExecuteToolContextwhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
*const ArcInner<RwLock<Map<String, Value>>> is !null: Freeze,
PhantomData<ArcInner<RwLock<Map<String, Value>>>>: Freeze,
*const ArcInner<dyn Model> is !null: Freeze,
PhantomData<ArcInner<dyn Model>>: Freeze,
*const ArcInner<Shared> is !null: Freeze,
PhantomData<ArcInner<Shared>>: Freeze,
*const ArcInner<[Source]> is !null: Freeze,
PhantomData<ArcInner<[Source]>>: Freeze,
*const ArcInner<[Message]> is !null: Freeze,
PhantomData<ArcInner<[Message]>>: Freeze,
*const ArcInner<ToolRegistry> is !null: Freeze,
PhantomData<ArcInner<ToolRegistry>>: Freeze,
*const ArcInner<Inner> is !null: Freeze,
PhantomData<ArcInner<Inner>>: Freeze,
*const ArcInner<Mutex<InterruptStateData>> is !null: Freeze,
PhantomData<ArcInner<Mutex<InterruptStateData>>>: Freeze,
*const ArcInner<dyn ToolPipeline> is !null: Freeze,
PhantomData<ArcInner<dyn ToolPipeline>>: Freeze,
*const ArcInner<CallScope> is !null: Freeze,
PhantomData<ArcInner<CallScope>>: Freeze,
*const ArcInner<dyn Sandbox> is !null: Freeze,
PhantomData<ArcInner<dyn Sandbox>>: Freeze,
*const ArcInner<[Arc<dyn ContextStrategy>]> is !null: Freeze,
PhantomData<ArcInner<[Arc<dyn ContextStrategy>]>>: Freeze,
*const ArcInner<dyn Storage> is !null: Freeze,
PhantomData<ArcInner<dyn Storage>>: Freeze,
*const ArcInner<Mutex<Option<AgentArchive>>> is !null: Freeze,
PhantomData<ArcInner<Mutex<Option<AgentArchive>>>>: Freeze,
*const ArcInner<[Arc<dyn InterventionHandler>]> is !null: Freeze,
PhantomData<ArcInner<[Arc<dyn InterventionHandler>]>>: Freeze,
*const ArcInner<Tracer> is !null: Freeze,
PhantomData<ArcInner<Tracer>>: Freeze,
*const ArcInner<dyn Tool> is !null: Freeze,
PhantomData<ArcInner<dyn Tool>>: Freeze,
PhantomData<Value>: Freeze,
PhantomData<usize>: Freeze,
PhantomData<Bucket<String, Value>>: Freeze,
*const ArcInner<RwLock<Extensions>> is !null: Freeze,
PhantomData<ArcInner<RwLock<Extensions>>>: Freeze,
*const ArcInner<dyn Fn(&InterruptParams) -> Result<Value, InterruptError> + Send + Sync> is !null: Freeze,
PhantomData<ArcInner<dyn Fn(&InterruptParams) -> Result<Value, InterruptError> + Send + Sync>>: Freeze,
impl Move for ExecuteToolContext
impl Send for ExecuteToolContextwhere
RawVecInner: Send,
Arc<RwLock<Map<String, Value>>>: Send,
Arc<dyn Model>: Send,
Arc<Shared>: Send,
Arc<[Source]>: Send,
Arc<[Message]>: Send,
Arc<ToolRegistry>: Send,
Arc<Inner>: Send,
Arc<Mutex<InterruptStateData>>: Send,
Arc<dyn ToolPipeline>: Send,
Arc<CallScope>: Send,
Arc<dyn Sandbox>: Send,
Arc<[Arc<dyn ContextStrategy>]>: Send,
Arc<dyn Storage>: Send,
Arc<Mutex<Option<AgentArchive>>>: Send,
Arc<[Arc<dyn InterventionHandler>]>: Send,
Arc<Tracer>: Send,
Arc<dyn Tool>: Send,
RawTable<usize>: Send,
Arc<RwLock<Extensions>>: Send,
Arc<dyn Fn(&InterruptParams) -> Result<Value, InterruptError> + Send + Sync>: Send,
impl Sync for ExecuteToolContextwhere
RawVecInner: Sync,
Arc<RwLock<Map<String, Value>>>: Sync,
Arc<dyn Model>: Sync,
Arc<Shared>: Sync,
Arc<[Source]>: Sync,
Arc<[Message]>: Sync,
Arc<ToolRegistry>: Sync,
Arc<Inner>: Sync,
Arc<Mutex<InterruptStateData>>: Sync,
Arc<dyn ToolPipeline>: Sync,
Arc<CallScope>: Sync,
Arc<dyn Sandbox>: Sync,
Arc<[Arc<dyn ContextStrategy>]>: Sync,
Arc<dyn Storage>: Sync,
Arc<Mutex<Option<AgentArchive>>>: Sync,
Arc<[Arc<dyn InterventionHandler>]>: Sync,
Arc<Tracer>: Sync,
Arc<dyn Tool>: Sync,
RawTable<usize>: Sync,
Arc<RwLock<Extensions>>: Sync,
Arc<dyn Fn(&InterruptParams) -> Result<Value, InterruptError> + Send + Sync>: Sync,
impl Unpin for ExecuteToolContextwhere
*const u8 is !null: Unpin,
Arc<RwLock<Map<String, Value>>>: Unpin,
Arc<dyn Model>: Unpin,
Arc<Shared>: Unpin,
Arc<[Source]>: Unpin,
Arc<[Message]>: Unpin,
Arc<ToolRegistry>: Unpin,
Arc<Inner>: Unpin,
Arc<Mutex<InterruptStateData>>: Unpin,
Arc<dyn ToolPipeline>: Unpin,
Arc<CallScope>: Unpin,
Arc<dyn Sandbox>: Unpin,
Arc<[Arc<dyn ContextStrategy>]>: Unpin,
Arc<dyn Storage>: Unpin,
Arc<Mutex<Option<AgentArchive>>>: Unpin,
Arc<[Arc<dyn InterventionHandler>]>: Unpin,
Arc<Tracer>: Unpin,
Arc<dyn Tool>: Unpin,
Arc<RwLock<Extensions>>: Unpin,
Arc<dyn Fn(&InterruptParams) -> Result<Value, InterruptError> + Send + Sync>: Unpin,
impl UnsafeUnpin for ExecuteToolContextwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
*const ArcInner<RwLock<Map<String, Value>>> is !null: UnsafeUnpin,
PhantomData<ArcInner<RwLock<Map<String, Value>>>>: UnsafeUnpin,
*const ArcInner<dyn Model> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn Model>>: UnsafeUnpin,
*const ArcInner<Shared> is !null: UnsafeUnpin,
PhantomData<ArcInner<Shared>>: UnsafeUnpin,
*const ArcInner<[Source]> is !null: UnsafeUnpin,
PhantomData<ArcInner<[Source]>>: UnsafeUnpin,
*const ArcInner<[Message]> is !null: UnsafeUnpin,
PhantomData<ArcInner<[Message]>>: UnsafeUnpin,
*const ArcInner<ToolRegistry> is !null: UnsafeUnpin,
PhantomData<ArcInner<ToolRegistry>>: UnsafeUnpin,
*const ArcInner<Inner> is !null: UnsafeUnpin,
PhantomData<ArcInner<Inner>>: UnsafeUnpin,
*const ArcInner<Mutex<InterruptStateData>> is !null: UnsafeUnpin,
PhantomData<ArcInner<Mutex<InterruptStateData>>>: UnsafeUnpin,
*const ArcInner<dyn ToolPipeline> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn ToolPipeline>>: UnsafeUnpin,
*const ArcInner<CallScope> is !null: UnsafeUnpin,
PhantomData<ArcInner<CallScope>>: UnsafeUnpin,
*const ArcInner<dyn Sandbox> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn Sandbox>>: UnsafeUnpin,
*const ArcInner<[Arc<dyn ContextStrategy>]> is !null: UnsafeUnpin,
PhantomData<ArcInner<[Arc<dyn ContextStrategy>]>>: UnsafeUnpin,
*const ArcInner<dyn Storage> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn Storage>>: UnsafeUnpin,
*const ArcInner<Mutex<Option<AgentArchive>>> is !null: UnsafeUnpin,
PhantomData<ArcInner<Mutex<Option<AgentArchive>>>>: UnsafeUnpin,
*const ArcInner<[Arc<dyn InterventionHandler>]> is !null: UnsafeUnpin,
PhantomData<ArcInner<[Arc<dyn InterventionHandler>]>>: UnsafeUnpin,
*const ArcInner<Tracer> is !null: UnsafeUnpin,
PhantomData<ArcInner<Tracer>>: UnsafeUnpin,
*const ArcInner<dyn Tool> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn Tool>>: UnsafeUnpin,
PhantomData<Value>: UnsafeUnpin,
PhantomData<usize>: UnsafeUnpin,
PhantomData<Bucket<String, Value>>: UnsafeUnpin,
*const ArcInner<RwLock<Extensions>> is !null: UnsafeUnpin,
PhantomData<ArcInner<RwLock<Extensions>>>: UnsafeUnpin,
*const ArcInner<dyn Fn(&InterruptParams) -> Result<Value, InterruptError> + Send + Sync> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn Fn(&InterruptParams) -> Result<Value, InterruptError> + Send + Sync>>: UnsafeUnpin,
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> ⓘ
Converts
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> ⓘ
Converts
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 moreCreates a shared type from an unshared type.