pub struct AgentTool { /* private fields */ }Expand description
Implementations§
Source§impl AgentTool
impl AgentTool
Sourcepub fn new(agent: Agent) -> Self
pub fn new(agent: Agent) -> Self
Wrap an already-built agent. The child keeps the limits it was built
with; call AgentTool::budget (or use AgentTool::from_builder)
to give it child-sized caps.
Sourcepub fn budget(self, budget: ChildBudget) -> Self
pub fn budget(self, budget: ChildBudget) -> Self
Build the child from builder with budget applied. This replaces
any limits already set on the builder.
Give the wrapped agent child-sized caps, replacing its own limits.
pub fn from_builder( builder: AgentBuilder, budget: ChildBudget, ) -> Result<Self, BuildError>
pub fn name(self, name: impl Into<String>) -> Self
pub fn description(self, description: impl Into<String>) -> Self
pub fn context_mode(self, mode: ContextMode) -> Self
Sourcepub fn fork_from(self, source: ForkSource) -> Self
pub fn fork_from(self, source: ForkSource) -> Self
Shorthand for context_mode(ContextMode::Fork(source)).
Sourcepub fn max_result_chars(self, chars: usize) -> Self
pub fn max_result_chars(self, chars: usize) -> Self
Cap on the condensed result (head + tail). 0 disables condensing.
pub fn with_annotations(self, annotations: ToolAnnotations) -> Self
Sourcepub fn read_only(self) -> Self
pub fn read_only(self) -> Self
Mark the child read-only so several calls in one turn run concurrently. Only do this for children whose tools are all read-only (research, search, review).
Sourcepub fn max_depth(self, depth: usize) -> Self
pub fn max_depth(self, depth: usize) -> Self
Maximum session depth a child may run at (top level is 0, its child is 1). Calls that would exceed it are refused.
Sourcepub fn interrupt_resolver(self, resolver: Arc<dyn InterruptResolver>) -> Self
pub fn interrupt_resolver(self, resolver: Arc<dyn InterruptResolver>) -> Self
Settle the child’s interruptions with resolver instead of ending
the delegation with an error. It sees the child’s state, whose
session_id and parent_run name where the child came from.
Sourcepub fn suspend_on_interrupt(self) -> Self
pub fn suspend_on_interrupt(self) -> Self
Pause the parent durably for a child left interrupted, instead of
ending the delegation with an error (see the crate docs). A resolver
set with AgentTool::interrupt_resolver is asked first; only what
it leaves unsettled pauses the parent. A call of this tool runs alone,
even when the tool is marked read-only.
pub fn agent(&self) -> &Agent
Trait Implementations§
Source§impl Tool for AgentTool
impl Tool for AgentTool
Source§fn effects(&self, _arguments: &Value) -> CallEffects
fn effects(&self, _arguments: &Value) -> CallEffects
The delegation itself changes nothing: the child’s own calls carry their effects, judged by the child’s hooks.
fn spec(&self) -> ToolSpec
fn annotations(&self) -> ToolAnnotations
Source§fn validate(&self, arguments: &Value) -> Result<(), String>
fn validate(&self, arguments: &Value) -> Result<(), String>
check_arguments: required keys, types, enums, nested objects
and array items) before calling this, whatever a tool does here, so
an override only adds checks. The default is that schema check.fn call<'life0, 'life1, 'async_trait>(
&'life0 self,
arguments: Value,
ctx: &'life1 ToolContext,
) -> Pin<Box<dyn Future<Output = ToolResult> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn suspends(&self) -> bool
fn suspends(&self) -> bool
ToolOutput::suspended. A call
of such a tool always runs alone, because a run pauses on one call at
a time.Source§fn resume_child<'life0, 'life1, 'async_trait>(
&'life0 self,
child: RunState,
resolution: Resolution,
ctx: &'life1 ToolContext,
) -> Pin<Box<dyn Future<Output = ToolResult> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn resume_child<'life0, 'life1, 'async_trait>(
&'life0 self,
child: RunState,
resolution: Resolution,
ctx: &'life1 ToolContext,
) -> Pin<Box<dyn Future<Output = ToolResult> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Tool::call would have returned: a
result, or ToolOutput::suspended if the child paused again. Read moreSource§fn annotations_for(&self, _arguments: &Value) -> ToolAnnotations
fn annotations_for(&self, _arguments: &Value) -> ToolAnnotations
ls versus rm) override this; the default is the
tool-wide Tool::annotations. Read moreSource§fn source_trust(&self, _arguments: &Value) -> SourceTrust
fn source_trust(&self, _arguments: &Value) -> SourceTrust
Untrusted; a
tool whose output is the owner’s own (a workspace file, the
kernel’s bookkeeping) returns Trusted. A result may override this
with ToolOutput::with_trust.Source§fn outbound(&self, _arguments: &Value) -> Outbound
fn outbound(&self, _arguments: &Value) -> Outbound
Source§fn timeout(&self) -> Option<Duration>
fn timeout(&self) -> Option<Duration>
Limits::tool_timeout. Tools
that take their own timeout argument (such as a shell) return a value
at least as long as their own maximum.