pub struct RunOptions { /* private fields */ }async and conversation only.Expand description
Optional knobs for the agent loop.
Build via RunOptions::default and chain setters; see method docs.
Implementations§
Source§impl RunOptions
impl RunOptions
Sourcepub fn new() -> Self
pub fn new() -> Self
Equivalent to Self::default.
Sourcepub fn max_iterations(self, max: u32) -> Self
pub fn max_iterations(self, max: u32) -> Self
Maximum total iterations of the model loop. Default 16.
Sourcepub fn on_iteration<F>(self, hook: F) -> Self
pub fn on_iteration<F>(self, hook: F) -> Self
Hook invoked after each messages.create response. Receives the
response and the 1-indexed iteration number. Useful for streaming
progress to the UI or recording fine-grained traces.
Sourcepub fn on_checkpoint<F>(self, hook: F) -> Self
pub fn on_checkpoint<F>(self, hook: F) -> Self
Hook invoked at the end of every iteration with a borrowed
snapshot of the Conversation – after the assistant turn and
any tool_result turn have been appended.
Resumability: persist the conversation here and resume after
a process restart by passing the deserialized Conversation
back into Client::run. The conversation is the source of
truth for the loop; no additional state needs to be saved.
Iteration state lives on the stack and is reconstructable from
turn count alone.
Sourcepub fn parallel_tool_dispatch(self, parallel: bool) -> Self
pub fn parallel_tool_dispatch(self, parallel: bool) -> Self
Whether to dispatch the tool_use blocks within a single assistant
turn concurrently (default true). Set to false to dispatch
sequentially – useful when tools have ordering side effects (e.g.
shared mutable state) or when serial output is easier to debug.
Sourcepub fn cost_budget(self, max_usd: f64, pricing: PricingTable) -> Self
Available on crate feature pricing only.
pub fn cost_budget(self, max_usd: f64, pricing: PricingTable) -> Self
pricing only.Cap cumulative spend on the conversation. After each turn the
runner computes Conversation::cost
against pricing and aborts with Error::CostBudgetExceeded if
the cumulative cost exceeds max_usd.
Sourcepub fn cancel_token(self, token: CancellationToken) -> Self
pub fn cancel_token(self, token: CancellationToken) -> Self
Attach a cancellation token. Checked at the top of every iteration;
if cancelled, the loop returns Error::Cancelled before issuing
the next request.
Sourcepub fn with_approver(self, approver: Arc<dyn ToolApprover>) -> Self
pub fn with_approver(self, approver: Arc<dyn ToolApprover>) -> Self
Attach a ToolApprover.
Consulted before every tool dispatch; the verdict can approve,
approve with rewritten input, substitute a result, deny (with a
reason surfaced to the model as is_error = true), or stop the
entire loop with Error::ToolApprovalStopped.
Sourcepub fn with_approver_fn<F, Fut>(self, handler: F) -> Self
pub fn with_approver_fn<F, Fut>(self, handler: F) -> Self
Closure-based shortcut for Self::with_approver.
Sourcepub fn max_iterations_value(&self) -> u32
pub fn max_iterations_value(&self) -> u32
Borrow the configured iteration cap.
Trait Implementations§
Source§impl Debug for RunOptions
impl Debug for RunOptions
Auto Trait Implementations§
impl Freeze for RunOptions
impl !RefUnwindSafe for RunOptions
impl Send for RunOptions
impl Sync for RunOptions
impl Unpin for RunOptions
impl UnsafeUnpin for RunOptions
impl !UnwindSafe for RunOptions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more