#[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
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: u32How 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: ExecProvidersHow 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: boolThe 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: StringWho made the call, as tool.around is told: model, user,
skill, RunCode, host, or the plugin command or function whose
call it is.
confinement: ConfinementReportWhat 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: AttendanceWhether 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
impl ToolContext
pub fn new( cwd: PathBuf, cancel: CancellationToken, exec: ExecProviders, config: Arc<EngineConfig>, session: Arc<dyn Session>, ) -> Self
Sourcepub fn sandbox_mut(&mut self) -> &mut SandboxSettings
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.
Sourcepub fn in_delegate(&self) -> bool
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.