Skip to main content

AgentCall

Struct AgentCall 

Source
pub struct AgentCall<T = NoSchema> { /* private fields */ }
Expand description

A fluent, owned builder for one agent leaf. Created by agent.

The type parameter T selects the terminal: NoSchema (default) yields the agent’s text, a StructuredSchema type T yields a validated T, and RawJson yields a validated serde_json::Value. T is phantom — it lives only here, so the underlying runner stays Value-only and object-safe.

Implementations§

Source§

impl<T> AgentCall<T>

Source

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

Set the display label (used in events and as the runner name).

Source

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

Override the phase this call is grouped under.

Source

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

Run this leaf on a different model: a ROLE name (“fast”, “frontier”) or a raw model id, resolved by the ctx’s provider factory. Dynamic model-by-task, the Claude Code way — the workflow decides per agent.

Source

pub fn isolation(self, isolation: Isolation) -> Self

Isolate this leaf’s filesystem effects (see Isolation).

Source

pub fn tools(self, tools: Vec<Arc<dyn Tool>>) -> Self

Wire a tool set into this agent, overriding the ctx’s base tools. The agent can then call these tools during its ReAct loop. (Sub-agents inherit tools the way Claude Code’s subagents inherit the allowlist.)

Source

pub fn goal(self, goal: GoalCondition) -> Self

Attach a persistent GoalCondition: the leaf self-continues until an independent judge confirms the objective (bounded by the goal’s max_continuations). The continuations all run inside the one leaf, so their combined token spend is recorded once against the shared flow budget, and a run-wide budget breach or cancellation aborts the goal loop at the leaf’s cancel race.

Source§

impl AgentCall<NoSchema>

Source

pub fn schema<S: StructuredSchema>(self) -> AgentCall<S>

Force validated structured output of type S, transforming this into an AgentCall<S> whose run() returns Option<S>. The schema comes from StructuredSchema::json_schema.

Source

pub fn schema_value(self, schema: Value) -> AgentCall<RawJson>

Force validated structured output against a hand-written JSON Schema, transforming this into an AgentCall<RawJson> whose run() returns the raw validated serde_json::Value (no deserialization).

Source

pub async fn run(self) -> Result<Option<String>, Error>

Run the agent leaf and return its text. Ok(None) only on cancellation.

Source§

impl<T: StructuredSchema> AgentCall<T>

Source

pub async fn run(self) -> Result<Option<T>, Error>

Run the agent leaf and deserialize its validated structured output into T. Ok(None) only on cancellation. A run that finishes without producing structured output, or whose output fails to deserialize into T, returns Err — never a silent None.

Source§

impl AgentCall<RawJson>

Source

pub async fn run(self) -> Result<Option<Value>, Error>

Run the agent leaf and return its raw validated serde_json::Value. Ok(None) only on cancellation; a run that finishes without structured output returns Err.

Auto Trait Implementations§

§

impl<T = NoSchema> !RefUnwindSafe for AgentCall<T>

§

impl<T = NoSchema> !UnwindSafe for AgentCall<T>

§

impl<T> Freeze for AgentCall<T>

§

impl<T> Send for AgentCall<T>

§

impl<T> Sync for AgentCall<T>

§

impl<T> Unpin for AgentCall<T>

§

impl<T> UnsafeUnpin for AgentCall<T>

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> 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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