pub struct ToolContext {
pub tool_call_id: ToolCallId,
pub messages: Arc<[Message]>,
pub cancellation: CancellationToken,
pub tools_context: Option<JsonValue>,
pub sandbox: Option<Arc<dyn Sandbox>>,
}Expand description
Per-call information handed to a tool execution.
Fields§
§tool_call_id: ToolCallIdId of the tool call being executed.
messages: Arc<[Message]>Messages sent to the model for the step that produced the call (without the system prompt and without the assistant response).
cancellation: CancellationTokenCancels the execution.
tools_context: Option<JsonValue>This tool’s selected context, validated when it declares a context schema.
sandbox: Option<Arc<dyn Sandbox>>Sandbox the tool operates in.
Implementations§
Source§impl ToolContext
impl ToolContext
Sourcepub fn new(tool_call_id: impl Into<ToolCallId>) -> Self
pub fn new(tool_call_id: impl Into<ToolCallId>) -> Self
Creates a context with no messages, a fresh token and no tool context.
Sourcepub fn with_messages(self, messages: impl Into<Arc<[Message]>>) -> Self
pub fn with_messages(self, messages: impl Into<Arc<[Message]>>) -> Self
Sets the step messages.
Sourcepub fn with_cancellation(self, cancellation: CancellationToken) -> Self
pub fn with_cancellation(self, cancellation: CancellationToken) -> Self
Sets the cancellation token.
Sourcepub fn with_tools_context(self, tools_context: Option<JsonValue>) -> Self
pub fn with_tools_context(self, tools_context: Option<JsonValue>) -> Self
Sets the validated tool context.
Sourcepub fn with_sandbox(self, sandbox: Arc<dyn Sandbox>) -> Self
pub fn with_sandbox(self, sandbox: Arc<dyn Sandbox>) -> Self
Sets the sandbox.
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 !RefUnwindSafe for ToolContext
impl !UnwindSafe for ToolContext
impl Freeze for ToolContext
impl Send for ToolContext
impl Sync for ToolContext
impl Unpin for ToolContext
impl UnsafeUnpin 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