#[non_exhaustive]pub struct ToolContext {
pub run_id: RunId,
pub session_id: String,
pub call_id: String,
pub turn: u32,
pub cancel: CancellationToken,
pub extensions: Extensions,
pub declines: Option<SharedDeclines>,
pub authority: Option<Authority>,
pub nested: Option<NestedCalls>,
}Expand description
Trusted, harness-provided context for one call.
This is passed beside the model’s arguments rather than injected into them, so a model can never spoof a session id or role by inventing a field.
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.run_id: RunId§session_id: String§call_id: String§turn: u32§cancel: CancellationTokenCancelled when the run is cancelled; long tools should watch it.
extensions: ExtensionsApplication values set with crate::AgentBuilder::tool_extensions.
declines: Option<SharedDeclines>The owner’s declines in this run, live. A tool that starts another run shares them with it.
What this run may do, when a hook enforces it. A tool that starts another run must not let it do more.
nested: Option<NestedCalls>Has a call the tool makes on its own (a program it drives asks to
act) judged by the run’s safeguards; see crate::NestedCalls.
None outside a running batch.
Implementations§
Source§impl ToolContext
impl ToolContext
Sourcepub fn new(
session_id: impl Into<String>,
call_id: impl Into<String>,
) -> ToolContext
pub fn new( session_id: impl Into<String>, call_id: impl Into<String>, ) -> ToolContext
A context with a fresh run id, turn 0 and a new cancel token. The loop fills in the real values; tests and adapters use this directly.
pub fn with_run(self, run_id: RunId, turn: u32) -> ToolContext
pub fn with_cancel(self, cancel: CancellationToken) -> ToolContext
pub fn with_extensions(self, extensions: Extensions) -> ToolContext
pub fn with_declines(self, declines: SharedDeclines) -> ToolContext
pub fn with_nested(self, nested: Option<NestedCalls>) -> ToolContext
Trait Implementations§
Source§impl Clone for ToolContext
impl Clone for ToolContext
Source§fn clone(&self) -> ToolContext
fn clone(&self) -> ToolContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for ToolContext
impl !UnwindSafe for ToolContext
impl Forget for ToolContext
impl Freeze for ToolContextwhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
*const ArcInner<TreeNode> is !null: Freeze,
PhantomData<ArcInner<TreeNode>>: Freeze,
PhantomData<(TypeId, Arc<dyn Any + Send + Sync>)>: Freeze,
*const ArcInner<Mutex<Vec<EffectKey>>> is !null: Freeze,
PhantomData<ArcInner<Mutex<Vec<EffectKey>>>>: Freeze,
*const LeafNode<String, SetValZST> is !null: Freeze,
PhantomData<(Owned, LeafOrInternal)>: Freeze,
PhantomData<Box<(String, SetValZST)>>: Freeze,
*const ArcInner<Chan<NestedAsk, Semaphore>> is !null: Freeze,
PhantomData<ArcInner<Chan<NestedAsk, Semaphore>>>: Freeze,
impl Move for ToolContext
impl Send for ToolContext
impl Sync for ToolContext
impl Unpin for ToolContext
impl UnsafeUnpin for ToolContextwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
*const ArcInner<TreeNode> is !null: UnsafeUnpin,
PhantomData<ArcInner<TreeNode>>: UnsafeUnpin,
PhantomData<(TypeId, Arc<dyn Any + Send + Sync>)>: UnsafeUnpin,
*const ArcInner<Mutex<Vec<EffectKey>>> is !null: UnsafeUnpin,
PhantomData<ArcInner<Mutex<Vec<EffectKey>>>>: UnsafeUnpin,
*const LeafNode<String, SetValZST> is !null: UnsafeUnpin,
PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin,
PhantomData<Box<(String, SetValZST)>>: UnsafeUnpin,
*const ArcInner<Chan<NestedAsk, Semaphore>> is !null: UnsafeUnpin,
PhantomData<ArcInner<Chan<NestedAsk, Semaphore>>>: UnsafeUnpin,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more