#[non_exhaustive]pub struct ToolInvocation {
pub session_id: SessionId,
pub tool_call_id: String,
pub tool_name: String,
pub arguments: Value,
pub traceparent: Option<String>,
pub tracestate: Option<String>,
}Expand description
A request from the CLI to invoke a client-defined tool.
Received as a JSON-RPC request on the tool.call method. The client
must respond with a ToolResultResponse.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.session_id: SessionIdSession that owns this tool call.
tool_call_id: StringUnique ID for this tool call, used to correlate the response.
tool_name: StringName of the tool being invoked.
arguments: ValueTool arguments as JSON.
traceparent: Option<String>W3C Trace Context traceparent header propagated from the CLI’s
execute_tool span. Pass through to OpenTelemetry-aware code so
child spans created inside the handler are parented to the CLI
span. None when the CLI has no trace context for this call.
tracestate: Option<String>W3C Trace Context tracestate paired with
traceparent.
Implementations§
Source§impl ToolInvocation
impl ToolInvocation
Sourcepub fn params<P: DeserializeOwned>(&self) -> Result<P, Error>
pub fn params<P: DeserializeOwned>(&self) -> Result<P, Error>
Deserialize this invocation’s arguments into a
strongly-typed parameter struct.
Idiomatic way to extract typed parameters when implementing
ToolHandler directly. Equivalent to
serde_json::from_value(invocation.arguments.clone()) with the SDK’s
error type.
§Example
let params: MyParams = inv.params()?;
// …use `inv.session_id` / `inv.tool_call_id` alongside `params`…Sourcepub fn trace_context(&self) -> TraceContext
pub fn trace_context(&self) -> TraceContext
Returns the propagated TraceContext for this invocation, or
TraceContext::default() when the CLI sent no headers.
Trait Implementations§
Source§impl Clone for ToolInvocation
impl Clone for ToolInvocation
Source§fn clone(&self) -> ToolInvocation
fn clone(&self) -> ToolInvocation
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more