pub struct Limits {
pub max_turns: u32,
pub max_tokens: Option<u64>,
pub max_tool_calls: Option<u32>,
pub timeout: Option<Duration>,
pub tool_timeout: Duration,
pub max_tool_output_chars: usize,
pub max_idle_continuations: u32,
pub hook_timeout: Duration,
}Expand description
Hard budgets for one run. Turns, tokens and tool calls are checked at the
top of every turn; tool calls and wall-clock time are also checked before
every call in a batch, and the model call and each tool are bounded by the
remaining wall-clock budget. max_turns cannot be switched off: it is
clamped to HARD_TURN_CAP.
Fields§
§max_turns: u32§max_tokens: Option<u64>Billable tokens for this run (cached input excluded).
max_tool_calls: Option<u32>§timeout: Option<Duration>Wall-clock budget for the whole run, summed across resumes.
tool_timeout: DurationPer-call timeout for tools.
max_tool_output_chars: usizeTool output beyond this many characters is cut to head + tail.
max_idle_continuations: u32How many times in a row on_stop hooks may send the model back with
no new successful tool call in between. Counting progress rather than
turns stops a hook and a refusing model from circling forever while
leaving long, productive runs alone.
hook_timeout: DurationHow long one hook call may take (see crate::Hook::timeout).