Skip to main content

ToolContext

Struct ToolContext 

Source
pub struct ToolContext<'run> { /* private fields */ }
Expand description

Per-call environment for ToolProvider::execute. Fields are sealed so the runtime can add capabilities without breaking tool authors.

Implementations§

Source§

impl<'run> ToolContext<'run>

Source

pub fn session_id(&self) -> &str

Source

pub fn agent_frame_id(&self) -> &str

Source

pub fn sessions(&self) -> ToolSessionAdmin<'run>

Source

pub fn dispatch(&self) -> ToolDispatchClient<'run>

Source

pub fn triggers(&self) -> ToolTriggerClient<'run>

Source

pub fn processes(&self) -> ToolSessionProcessAdmin<'run>

Source

pub fn emit_lashlang_child_process_started( &self, process_id: impl Into<String>, child_entry_name: Option<String>, )

Source

pub fn direct_completions(&self) -> ToolDirectCompletionClient<'run>

Source

pub fn attachments(&self) -> ToolAttachmentClient

Source

pub fn process_events(&self) -> ToolProcessEventClient

Source

pub fn cancellation_token(&self) -> Option<&CancellationToken>

Source

pub fn async_process_id(&self) -> Option<&str>

Source

pub fn runtime_process_id(&self) -> Option<&str>

Source

pub fn tool_call_id(&self) -> Option<&str>

Source

pub fn prepared_payload(&self) -> &Value

Source

pub fn decode_prepared_payload<T>(&self) -> Result<T, Error>

Source

pub fn attempt_number(&self) -> u32

Source

pub fn max_attempts(&self) -> u32

Source

pub fn replay_key(&self) -> Option<&str>

Source

pub async fn completion_key(&self) -> Result<AwaitEventKey, RuntimeError>

Obtain the durable completion key for this call, required before returning ToolResult::Pending.

A tool that defers its outcome (waiting on a webhook, human approval, or another service) calls this, hands the returned AwaitEventKey to whatever will complete the work out-of-band, and then returns ToolResult::Pending(..). The key names the durable wait the runtime parks the call on; the external resolver delivers the result against it later.

The key is stored on the context and consumed by the dispatcher when the tool returns Pending. Returning Pending without first calling this fails the call with pending_tool_missing_completion_key. Calls made outside a prepared tool invocation (no tool call id) fail with tool_completion_key_missing_call_id.

Source

pub fn with_async_process( self, process_id: impl Into<String>, cancellation_token: CancellationToken, ) -> Self

Trait Implementations§

Source§

impl<'run> Clone for ToolContext<'run>

Source§

fn clone(&self) -> ToolContext<'run>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<'run> !RefUnwindSafe for ToolContext<'run>

§

impl<'run> !UnwindSafe for ToolContext<'run>

§

impl<'run> Freeze for ToolContext<'run>

§

impl<'run> Send for ToolContext<'run>

§

impl<'run> Sync for ToolContext<'run>

§

impl<'run> Unpin for ToolContext<'run>

§

impl<'run> UnsafeUnpin for ToolContext<'run>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more