Skip to main content

ToolContext

Struct ToolContext 

Source
#[non_exhaustive]
pub struct ToolContext {
Show 21 fields pub cwd: PathBuf, pub session_id: String, pub turn_no: u32, pub cancel: CancellationToken, pub config: Arc<EngineConfig>, pub session: Arc<dyn Session>, pub tool_use_id: String, pub agent_depth: u32, pub elicitation: Option<Arc<dyn Elicitation>>, pub host_calls: Option<Arc<dyn HostCalls>>, pub exec: ExecProviders, pub dispatch: Option<Arc<dyn ToolDispatch>>, pub from_code: bool, pub via: String, pub confinement: ConfinementReport, pub engine_git: Arc<EngineExec>, pub attendance: Attendance, pub approval: Option<Approval>, pub turn: Arc<TurnScope>, pub inline_commands: Option<Arc<dyn InlineCommands>>, pub path_denials: Option<Arc<dyn PathDenials>>,
}

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.
§cwd: PathBuf§session_id: String§turn_no: u32§cancel: CancellationToken§config: Arc<EngineConfig>

The engine’s configuration; the session’s sandbox settings are its sandbox.

§session: Arc<dyn Session>

The session the call is made in: its live permission mode, the directories it may write besides its own, its running tasks.

§tool_use_id: String§agent_depth: u32

How many delegations deep the calling session is; 0 for the conversation the user talks to.

§elicitation: Option<Arc<dyn Elicitation>>

How a tool asks the user something — see crate::interface::elicitation::Elicitation. None where nothing can reach a person (a test context, a background run), which every asking tool must read as a refusal rather than as permission to make the answer up.

§host_calls: Option<Arc<dyn HostCalls>>

How a host-declared tool reaches the host; None where no host can answer, which such a tool reads as failing at once.

§exec: ExecProviders

How this tool reaches the machine — see crate::interface::exec. In production this machine’s (platform); a deployment executing somewhere else replaces the set and no tool notices.

§dispatch: Option<Arc<dyn ToolDispatch>>

How this tool calls other tools — set only for a tool whose ToolSpec::needs_dispatch says it does.

§from_code: bool

The call comes from a program (RunCode), not from the model: there is nobody to ask and no conversation to report back to mid-call.

§via: String

Who made the call, as tool.around is told: model, user, skill, RunCode, host, or the plugin command or function whose call it is.

§confinement: ConfinementReport

What the session’s sandbox holds a command to.

§engine_git: Arc<EngineExec>

How the engine runs its own git and helpers for the session — see crate::interface::exec::SandboxSettings::engine_git.

§attendance: Attendance

Whether someone can be asked about what this call does.

§approval: Option<Approval>

What the policy let this call through on; None when nothing judged it.

§turn: Arc<TurnScope>§inline_commands: Option<Arc<dyn InlineCommands>>

How a skill’s !`cmd` expanded during this call runs; None where nothing runs them.

§path_denials: Option<Arc<dyn PathDenials>>

What the permission rules in force deny of a directory walk; None where nothing judges paths.

Implementations§

Source§

impl ToolContext

Source

pub fn new( cwd: PathBuf, cancel: CancellationToken, exec: ExecProviders, config: Arc<EngineConfig>, session: Arc<dyn Session>, ) -> Self

Source

pub fn sandbox_mut(&mut self) -> &mut SandboxSettings

This context’s own sandbox settings, to change for it alone: the session’s stay as they are.

Source

pub fn in_delegate(&self) -> bool

Whether the call is a delegate’s — a sub-agent’s or a team member’s — rather than the conversation’s own.

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

Auto Trait Implementations§

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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> 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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more