pub struct ToolContext {
pub provider: ProviderKind,
pub model: String,
pub round: usize,
pub tool_name: String,
pub tool_call_id: String,
}Expand description
Metadata passed to each tool handler invocation.
§Example
use rai_sdk::{JsonSchema, Tool};
use serde::Deserialize;
#[derive(Deserialize, JsonSchema)]
#[schemars(crate = "rai_sdk::schemars")]
struct EchoArgs {
value: String,
}
let _tool = Tool::new("echo")
.description("Return the input together with model metadata")
.handler(|args: EchoArgs, ctx: rai_sdk::ToolContext| async move {
Ok(format!("{} via {}", args.value, ctx.model))
})?;Fields§
§provider: ProviderKindProvider that requested the tool call.
model: StringModel ID that requested the tool call, as sent on the wire.
round: usizeZero-based index of the tool-calling round within the current request.
Useful for detecting repeated calls and for bounding work in handlers that may be invoked several times in one generation.
tool_name: StringName of the tool being invoked.
tool_call_id: StringProvider-assigned identifier for this specific tool call.
Trait Implementations§
Source§impl Clone for ToolContext
impl Clone for ToolContext
Source§fn clone(&self) -> ToolContext
fn clone(&self) -> ToolContext
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ToolContext
impl RefUnwindSafe for ToolContext
impl Send for ToolContext
impl Sync for ToolContext
impl Unpin for ToolContext
impl UnsafeUnpin for ToolContext
impl UnwindSafe for ToolContext
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