Skip to main content

RunPolicy

Struct RunPolicy 

Source
pub struct RunPolicy {
    pub limits: RunLimits,
    pub unknown_tool: UnknownToolPolicy,
    pub invalid_args: InvalidArgsPolicy,
    pub retry: RetryPolicy,
    pub fallback: Option<FallbackPolicy>,
    pub default_response_format: Option<ResponseFormat>,
    pub capture: PayloadCapture,
    pub cache: CachePolicy,
    pub error_on_empty_response: bool,
    pub truncated_empty_retries: u32,
}

Fields§

§limits: RunLimits

Hard run limits enforced fail-closed by the agent loop.

§unknown_tool: UnknownToolPolicy

How the loop reacts to a model call for an unregistered tool.

§invalid_args: InvalidArgsPolicy

How the loop reacts when a registered tool’s arguments fail schema validation.

§retry: RetryPolicy

Retry policy applied to each model call.

§fallback: Option<FallbackPolicy>

Optional ordered model fallback chain.

§default_response_format: Option<ResponseFormat>

Response format attached to every model request when set.

§capture: PayloadCapture

Whether the loop captures model/tool payloads onto completion events.

Defaults to PayloadCapture::default (payload-free), preserving the privacy-preserving behavior where events carry only ids and usage.

§cache: CachePolicy

Default caching policy for the run.

The loop consults CachePolicy::response_cache_enabled only when a ResponseCache is attached to the harness and the per-call crate::harness::model::ModelRequest::cache_policy does not override it. A request-level cache_policy always wins over this default.

§error_on_empty_response: bool

When true, an empty provider completion in the finalization branch (no text, no tool calls, and no structured output) fails the run with crate::error::TinyAgentsError::EmptyResponse instead of terminating with a blank final answer.

Defaults to false to preserve the historical behavior for callers who rely on empty finals; opt in to turn a silent blank success into a typed error the caller can re-prompt on.

§truncated_empty_retries: u32

Number of automatic retries when a model call returns a truncated empty completion — finish_reason == "length" with no visible text, no tool calls, and no structured output.

This is the failure mode of local reasoning models (for example qwen3 via Ollama) that intermittently spend the entire token budget on the hidden reasoning channel and emit nothing usable. Because such a response is useless to every caller and the failure is stochastic, retrying — with a doubled token budget when the request set one (capped at 4x the original), or a plain retry when it did not — is strictly better than surfacing a blank success.

The retry runs before Self::error_on_empty_response; only once these retries are exhausted does that guard (if enabled) apply.

Defaults to 1 (one retry, two attempts total). Set to 0 to disable for exact-replay callers that must not re-issue a call.

Trait Implementations§

Source§

impl Clone for RunPolicy

Source§

fn clone(&self) -> RunPolicy

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 RunPolicy

Source§

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

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

impl Default for RunPolicy

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for RunPolicy

Source§

fn eq(&self, other: &RunPolicy) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for RunPolicy

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