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>
impl<'run> ToolContext<'run>
pub fn session_id(&self) -> &str
pub fn agent_frame_id(&self) -> &str
pub fn sessions(&self) -> ToolSessionAdmin<'run>
pub fn dispatch(&self) -> ToolDispatchClient<'run>
pub fn triggers(&self) -> ToolTriggerClient<'run>
pub fn processes(&self) -> ToolSessionProcessAdmin<'run>
pub fn emit_lashlang_child_process_started( &self, process_id: impl Into<String>, child_entry_name: Option<String>, )
pub fn direct_completions(&self) -> ToolDirectCompletionClient<'run>
pub fn attachments(&self) -> ToolAttachmentClient
pub fn process_events(&self) -> ToolProcessEventClient
Sourcepub fn durable_effects(
&self,
) -> Result<ToolDurableEffects<'_, 'run>, RuntimeError>
pub fn durable_effects( &self, ) -> Result<ToolDurableEffects<'_, 'run>, RuntimeError>
Borrow this tool call’s durable effect boundary.
This is available only while executing a prepared tool call under a controller that explicitly supports durable tool effects. The returned facade records JSON steps and await-event waits in the caller’s existing effect log; it does not expose the underlying workflow engine context.
pub fn cancellation_token(&self) -> Option<&CancellationToken>
pub fn async_process_id(&self) -> Option<&str>
pub fn runtime_process_id(&self) -> Option<&str>
pub fn tool_call_id(&self) -> Option<&str>
pub fn prepared_payload(&self) -> &Value
pub fn decode_prepared_payload<T>(&self) -> Result<T, Error>where
T: DeserializeOwned,
pub fn attempt_number(&self) -> u32
pub fn max_attempts(&self) -> u32
pub fn replay_key(&self) -> Option<&str>
Sourcepub async fn completion_key(&self) -> Result<AwaitEventKey, RuntimeError>
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.
pub fn with_async_process( self, process_id: impl Into<String>, cancellation_token: CancellationToken, ) -> Self
Trait Implementations§
Source§impl<'run> Clone for ToolContext<'run>
impl<'run> Clone for ToolContext<'run>
Source§fn clone(&self) -> ToolContext<'run>
fn clone(&self) -> ToolContext<'run>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more