pub struct Context {
pub request_id: String,
pub tool_use_id: String,
pub max_result_size: usize,
/* private fields */
}Expand description
Carries per-request metadata and cancellation through tool execution.
Fields§
§request_id: StringUnique request identifier.
tool_use_id: StringTool-use identifier (links back to the LLM tool call).
max_result_size: usizeMaximum size (in bytes) for the result content.
Implementations§
Source§impl Context
impl Context
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a context with empty identifiers, no result-size limit, and a fresh cancellation token.
Sourcepub fn with_cancellation(token: CancellationToken) -> Self
pub fn with_cancellation(token: CancellationToken) -> Self
Create a context that observes the provided cancellation token.
Sourcepub fn set(&mut self, key: &str, value: ToolOutput)
pub fn set(&mut self, key: &str, value: ToolOutput)
Store metadata for the current tool call under key.
Sourcepub fn get(&self, key: &str) -> Option<&ToolOutput>
pub fn get(&self, key: &str) -> Option<&ToolOutput>
Return metadata previously stored under key, if present.
Sourcepub const fn cancel_token(&self) -> &CancellationToken
pub const fn cancel_token(&self) -> &CancellationToken
Return the cancellation token associated with this tool call.
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Return whether cancellation has been requested for this tool call.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Context
impl RefUnwindSafe for Context
impl Send for Context
impl Sync for Context
impl Unpin for Context
impl UnsafeUnpin for Context
impl UnwindSafe for Context
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