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: RunLimitsHard run limits enforced fail-closed by the agent loop.
unknown_tool: UnknownToolPolicyHow the loop reacts to a model call for an unregistered tool.
invalid_args: InvalidArgsPolicyHow the loop reacts when a registered tool’s arguments fail schema validation.
retry: RetryPolicyRetry 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: PayloadCaptureWhether 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: CachePolicyDefault 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: boolWhen 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: u32Number 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.