Skip to main content

ToolContext

Struct ToolContext 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional 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: CancellationToken

Cancelled when the run is cancelled; long tools should watch it.

§extensions: Extensions

Application 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.

§authority: Option<Authority>

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

Source

pub fn new(session_id: impl Into<String>, call_id: impl Into<String>) -> Self

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.

Source

pub fn with_run(self, run_id: RunId, turn: u32) -> Self

Source

pub fn with_cancel(self, cancel: CancellationToken) -> Self

Source

pub fn with_extensions(self, extensions: Extensions) -> Self

Source

pub fn with_declines(self, declines: SharedDeclines) -> Self

Source

pub fn with_authority(self, authority: Option<Authority>) -> Self

Source

pub fn with_nested(self, nested: Option<NestedCalls>) -> Self

Trait Implementations§

Source§

impl Clone for ToolContext

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ToolContext

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for ToolContext

§

impl !UnwindSafe for ToolContext

§

impl Forget for ToolContext

§

impl Freeze for ToolContext
where *const u8 is !null: Freeze, PhantomData<u8>: Freeze, *const ArcInner<TreeNode> is !null: Freeze, PhantomData<ArcInner<TreeNode>>: Freeze, PhantomData<(TypeId, Arc<dyn Any + Sync + Send>)>: 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
where RawVecInner: Send, Arc<TreeNode>: Send, RawTable<(TypeId, Arc<dyn Any + Sync + Send>)>: Send, Arc<Mutex<Vec<EffectKey>>>: Send, NodeRef<Owned, String, SetValZST, LeafOrInternal>: Send, BoxRaw<(String, SetValZST)>: Send, Arc<Chan<NestedAsk, Semaphore>>: Send,

§

impl Sync for ToolContext
where RawVecInner: Sync, Arc<TreeNode>: Sync, RawTable<(TypeId, Arc<dyn Any + Sync + Send>)>: Sync, Arc<Mutex<Vec<EffectKey>>>: Sync, NodeRef<Owned, String, SetValZST, LeafOrInternal>: Sync, BoxRaw<(String, SetValZST)>: Sync, Arc<Chan<NestedAsk, Semaphore>>: Sync,

§

impl Unpin for ToolContext
where *const u8 is !null: Unpin, Arc<TreeNode>: Unpin, *const (): Unpin, Arc<dyn Any + Sync + Send>: Unpin, Arc<Mutex<Vec<EffectKey>>>: Unpin, *const LeafNode<String, SetValZST> is !null: Unpin, Box<(String, SetValZST)>: Unpin, Arc<Chan<NestedAsk, Semaphore>>: Unpin,

§

impl UnsafeUnpin for ToolContext
where *const u8 is !null: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, *const ArcInner<TreeNode> is !null: UnsafeUnpin, PhantomData<ArcInner<TreeNode>>: UnsafeUnpin, PhantomData<(TypeId, Arc<dyn Any + Sync + Send>)>: 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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.