pub struct AgentBuilder { /* private fields */ }Implementations§
Source§impl AgentBuilder
impl AgentBuilder
pub fn model(self, model: impl Model + 'static) -> Self
Sourcepub fn replace_tools(self, tools: Vec<Arc<dyn Tool>>) -> Self
pub fn replace_tools(self, tools: Vec<Arc<dyn Tool>>) -> Self
Replace the tool set.
Sourcepub fn without_on_delta(self) -> Self
pub fn without_on_delta(self) -> Self
Stop streaming deltas (e.g. for background replays).
pub fn system(self, prompt: impl Into<String>) -> Self
pub fn tool(self, tool: impl Tool + 'static) -> Self
Sourcepub fn tools<T: Tool + 'static>(
self,
tools: impl IntoIterator<Item = T>,
) -> Self
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).
pub fn budget(self, budget: Budget) -> Self
pub fn policy(self, policy: impl Policy + 'static) -> Self
pub fn journal(self, journal: impl Journal + 'static) -> Self
pub fn max_tokens(self, n: u32) -> Self
pub fn temperature(self, t: f32) -> Self
Sourcepub fn provider_option(self, provider: &str, options: Value) -> Self
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}})).
Sourcepub fn on_delta(self, f: impl Fn(&StreamEvent) + Send + Sync + 'static) -> Self
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.
Sourcepub fn tool_timeout(self, limit: Duration) -> Self
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.
Sourcepub fn finish_schema(self, schema: Value) -> Self
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.
Sourcepub fn finish_as<T: JsonSchema>(self) -> Self
pub fn finish_as<T: JsonSchema>(self) -> Self
finish_schema derived from a Rust type.
Sourcepub fn worker_id(self, id: impl Into<String>) -> Self
pub fn worker_id(self, id: impl Into<String>) -> Self
Name this worker in run leases (default: a random worker-<uuid>).
Sourcepub fn lease_ttl(self, ttl: Duration) -> Self
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.
Sourcepub fn finish_retries(self, n: u32) -> Self
pub fn finish_retries(self, n: u32) -> Self
Corrective retries allowed for a final answer that fails the schema.
Sourcepub fn without_tool_timeout(self) -> Self
pub fn without_tool_timeout(self) -> Self
Remove the default tool timeout (per-tool timeouts still apply).