pub struct ToolContext {Show 17 fields
pub policy: SandboxPolicy,
pub executor: Executor,
pub web: WebSettings,
pub memory: Option<SessionStore>,
pub skills: Arc<Skills>,
pub secrets: SecretVault,
pub editor: Option<Arc<dyn EditorFiles>>,
pub specialties: Arc<Specialties>,
pub scope: Option<Arc<ToolScope>>,
pub can_delegate: bool,
pub fanout: Option<Arc<FanOut>>,
pub fresh_clients: bool,
pub worktree: Option<Arc<Worktree>>,
pub card: Option<Arc<Card>>,
pub subagent: Option<Arc<SubagentRun>>,
pub asker: Asker,
pub ui: Option<Arc<UiSession>>,
/* private fields */
}Expand description
Ambient state handed to every tool at execution time.
Fields§
§policy: SandboxPolicy§executor: ExecutorWhere commands and Python snippets run.
web: WebSettingsweb_fetch settings.
memory: Option<SessionStore>Long-term memory for remember and recall; None when memory is off.
skills: Arc<Skills>The discovered skills, for use_skill.
secrets: SecretVaultSecrets the user entered (beyond Python): set in tool processes’ environment, and redacted from every result. Shared by clones and sub-agent forks.
editor: Option<Arc<dyn EditorFiles>>The editor’s files, when an editor drives the agent. Shared by clones and sub-agent forks.
specialties: Arc<Specialties>The specialist sub-agents (beyond Python), for delegate and use_skill.
scope: Option<Arc<ToolScope>>What narrows this context (beyond Python): the specialty it runs, or one it
was delegated from. Set once when a sub-agent is spawned (or for run --agent), never by the model, and checked with the active skill’s list.
can_delegate: boolWhether a use_skill hand-off to a specialty could be made from here: the
harness delegates, delegate is offered at this depth, and this context may
call it. Set by the harness.
fanout: Option<Arc<FanOut>>The fan-out this context’s sub-agent belongs to (beyond Python): siblings running at once share its spend and its stop. Inherited by forks, so a sibling’s own delegations stop with it.
fresh_clients: boolOn a fan-out thread: every sub-agent here calls a provider copy with an
HTTP client of its own (crate::provider::Provider::fresh).
worktree: Option<Arc<Worktree>>The git worktree this context is jailed to, when a specialty runs isolated; a delegation from inside asking for isolation is served by the same one.
card: Option<Arc<Card>>The card a sub-agent’s progress is reported on (beyond Python): the top-level delegation’s, which nested runs share.
subagent: Option<Arc<SubagentRun>>The sub-agent run this context belongs to (beyond Python), with its progress, so a question it asks can say who asks. Set when a sub-agent is spawned.
asker: AskerThe hook ask_user asks the user through (beyond Python; ADR 0006), once
a surface installs one. Shared by clones; sub-agent forks get an empty
one, since only the main loop asks.
ui: Option<Arc<UiSession>>The renderer the embedder declared (beyond Python; ADR 0005), for
render_ui: its catalogs and the surfaces drawn. Shared by clones;
sub-agent forks have none, since only the main loop draws.
Implementations§
Source§impl ToolContext
impl ToolContext
Sourcepub fn activate_skill(&self, skill: &Arc<Skill>)
pub fn activate_skill(&self, skill: &Arc<Skill>)
Make skill the active one, replacing (never stacking on) any other.
Sourcepub fn clear_skill(&self)
pub fn clear_skill(&self)
Lift the active skill’s restriction, as the end of a turn does.
Sourcepub fn fork(&self) -> Self
pub fn fork(&self) -> Self
A copy for a sub-agent: the same tools and jail, and its own active skill,
starting as this context’s, so what it activates restricts only itself.
It draws no UI and asks the user nothing: only the main loop has the
renderer and the ask_user hook.
pub fn active_skill(&self) -> Option<Arc<Skill>>
Sourcepub fn scope_allows(&self, name: &str) -> bool
pub fn scope_allows(&self, name: &str) -> bool
Whether the specialty this context runs under (if any) permits name.
Sourcepub fn allowed_tool(&self, name: &str) -> bool
pub fn allowed_tool(&self, name: &str) -> bool
Whether name may be called now, given the active skill’s allowed-tools.
use_skill always may: it is how the model switches skills, and a skill
that forgot to list it would otherwise be a one-way door.
Trait Implementations§
Source§impl Clone for ToolContext
impl Clone for ToolContext
Auto Trait Implementations§
impl !RefUnwindSafe for ToolContext
impl !UnwindSafe for ToolContext
impl Forget for ToolContext
impl Freeze for ToolContext
impl Move for ToolContext
impl Send for ToolContext
impl Sync for ToolContext
impl Unpin for ToolContext
impl UnsafeUnpin for ToolContext
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
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