Skip to main content

AgentTool

Struct AgentTool 

Source
pub struct AgentTool { /* private fields */ }
Expand description

A child Agent exposed as a Tool. Arguments: {task, context?}.

Note that the parent’s Limits::tool_timeout (default 120 s) bounds the whole child run; raise it on parents that delegate long tasks.

Implementations§

Source§

impl AgentTool

Source

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.

Source

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.

Source

pub fn from_builder( builder: AgentBuilder, budget: ChildBudget, ) -> Result<Self, BuildError>

Source

pub fn name(self, name: impl Into<String>) -> Self

Source

pub fn description(self, description: impl Into<String>) -> Self

Source

pub fn context_mode(self, mode: ContextMode) -> Self

Source

pub fn fork_from(self, source: ForkSource) -> Self

Shorthand for context_mode(ContextMode::Fork(source)).

Source

pub fn max_result_chars(self, chars: usize) -> Self

Cap on the condensed result (head + tail). 0 disables condensing.

Source

pub fn with_annotations(self, annotations: ToolAnnotations) -> Self

Source

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

Source

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.

Source

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.

Source

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.

Source

pub fn agent(&self) -> &Agent

Trait Implementations§

Source§

impl Clone for AgentTool

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 AgentTool

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Tool for AgentTool

Source§

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.

Source§

fn spec(&self) -> ToolSpec

Source§

fn annotations(&self) -> ToolAnnotations

Source§

fn validate(&self, arguments: &Value) -> Result<(), String>

Deterministic argument checks, run before any policy or I/O. The kernel checks the arguments against the declared schema (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.
Source§

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

Whether this tool may answer with 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,

Continue the child run this tool suspended, with the answer to its interruption, and return what Tool::call would have returned: a result, or ToolOutput::suspended if the child paused again. Read more
Source§

fn annotations_for(&self, _arguments: &Value) -> ToolAnnotations

Annotations for one call. Tools whose effect depends on the arguments (a shell running ls versus rm) override this; the default is the tool-wide Tool::annotations. Read more
Source§

fn source_trust(&self, _arguments: &Value) -> SourceTrust

Who authored what this call returns. The default is 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

What this call carries out of the machine if it only reads. The default says nothing does.
Source§

fn timeout(&self) -> Option<Duration>

How long this tool may run, overriding 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.
Source§

fn access(&self, _arguments: &Value) -> AccessManifest

Declare what this call will touch. Optional; policies treat an empty manifest as undeclared.
Source§

fn concurrent_peers(&self) -> usize

How many calls of this tool may run together in one batch although the tool is not read-only: 0 (the default) runs each call alone. A tool returns more only when it coordinates the shared state its concurrent calls touch itself (sub-agents whose writes a coordination ledger arbitrates). Calls queued this way still run after every earlier call in the batch has been judged, and before any later call that is not concurrent-safe.

Auto Trait Implementations§

§

impl !RefUnwindSafe for AgentTool

§

impl !UnwindSafe for AgentTool

§

impl Forget for AgentTool

§

impl Freeze for AgentTool
where *const ArcInner<AgentInner> is !null: Freeze, PhantomData<ArcInner<AgentInner>>: Freeze, *const u8 is !null: Freeze, PhantomData<u8>: Freeze, *const ArcInner<dyn Fn(&ToolContext) -> Option<String> + Send + Sync> is !null: Freeze, PhantomData<ArcInner<dyn Fn(&ToolContext) -> Option<String> + Send + Sync>>: Freeze, *const ArcInner<dyn InterruptResolver> is !null: Freeze, PhantomData<ArcInner<dyn InterruptResolver>>: Freeze,

§

impl Move for AgentTool

§

impl Send for AgentTool
where Arc<AgentInner>: Send, RawVecInner: Send, Arc<dyn Fn(&ToolContext) -> Option<String> + Send + Sync>: Send, Arc<dyn InterruptResolver>: Send,

§

impl Sync for AgentTool
where Arc<AgentInner>: Sync, RawVecInner: Sync, Arc<dyn Fn(&ToolContext) -> Option<String> + Send + Sync>: Sync, Arc<dyn InterruptResolver>: Sync,

§

impl Unpin for AgentTool
where Arc<AgentInner>: Unpin, *const u8 is !null: Unpin, Arc<dyn Fn(&ToolContext) -> Option<String> + Send + Sync>: Unpin, Arc<dyn InterruptResolver>: Unpin,

§

impl UnsafeUnpin for AgentTool
where *const ArcInner<AgentInner> is !null: UnsafeUnpin, PhantomData<ArcInner<AgentInner>>: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, *const ArcInner<dyn Fn(&ToolContext) -> Option<String> + Send + Sync> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn Fn(&ToolContext) -> Option<String> + Send + Sync>>: UnsafeUnpin, *const ArcInner<dyn InterruptResolver> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn InterruptResolver>>: 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.