Skip to main content

AgentBuilder

Struct AgentBuilder 

Source
pub struct AgentBuilder { /* private fields */ }

Implementations§

Source§

impl AgentBuilder

Source

pub fn model(self, model: impl Model + 'static) -> Self

Source

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

Replace the tool set.

Source

pub fn without_on_delta(self) -> Self

Stop streaming deltas (e.g. for background replays).

Source

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

Source

pub fn tool(self, tool: impl Tool + 'static) -> Self

Source

pub fn tools<T: Tool + 'static>( self, tools: impl IntoIterator<Item = T>, ) -> Self

Add several tools at once (e.g. all tools from an MCP server).

Source

pub fn budget(self, budget: Budget) -> Self

Source

pub fn policy(self, policy: impl Policy + 'static) -> Self

Source

pub fn journal(self, journal: impl Journal + 'static) -> Self

Source

pub fn shared_journal(self, journal: Arc<dyn Journal>) -> Self

Source

pub fn max_tokens(self, n: u32) -> Self

Source

pub fn temperature(self, t: f32) -> Self

Source

pub fn provider_option(self, provider: &str, options: Value) -> Self

Provider-specific request options, e.g. .provider_option("anthropic", json!({"thinking": {"type": "enabled", "budget_tokens": 4096}})).

Source

pub fn on_delta(self, f: impl Fn(&StreamEvent) + Send + Sync + 'static) -> Self

Stream model output as it is generated (text, thinking, tool-call arguments). Enables streaming calls to the model.

Source

pub fn tool_timeout(self, limit: Duration) -> Self

Default limit for each tool call (120 s unless changed). Tools can override it with with_timeout. A timed-out call is cancelled and reported to the model as an error; the run continues.

Source

pub fn finish_schema(self, schema: Value) -> Self

Require the run’s final answer to be JSON matching schema (JSON Schema). The schema is added to the system prompt; an answer that does not match gets finish_retries corrective retries (default 1), after which the run fails. The validated value is available as RunOutcome::structured.

Source

pub fn finish_as<T: JsonSchema>(self) -> Self

finish_schema derived from a Rust type.

Source

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

Name this worker in run leases (default: a random worker-<uuid>).

Source

pub fn lease_ttl(self, ttl: Duration) -> Self

How long a run lease lasts without renewal (default 60 s). A crashed worker’s runs can be taken over after this long.

Source

pub fn finish_retries(self, n: u32) -> Self

Corrective retries allowed for a final answer that fails the schema.

Source

pub fn without_tool_timeout(self) -> Self

Remove the default tool timeout (per-tool timeouts still apply).

Source

pub fn build(self) -> Result<Agent, AgentError>

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = !

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