pub struct TurnBudget {
pub max_provider_rounds: u32,
pub max_tool_calls: u32,
pub max_elapsed: Option<Duration>,
pub max_accumulated_tool_result_bytes: usize,
pub max_context_tokens: Option<u64>,
pub max_cost_usd: Option<f64>,
pub max_round_renewals: u32,
}Expand description
Per-turn limits (spec §8.1).
Fields§
§max_provider_rounds: u32§max_tool_calls: u32§max_elapsed: Option<Duration>Wall-clock limit for one turn. None (the default for every role)
means no limit: a turn that is still making progress is never cut off
for taking long. Opt in with turn_budget.<role>.max_elapsed_secs or
/budget time. Rounds, tool calls and tool-result bytes stay bounded.
max_accumulated_tool_result_bytes: usize§max_context_tokens: Option<u64>§max_cost_usd: Option<f64>§max_round_renewals: u32Bounded auto-renewals of the provider-round allowance (spec §8.1).
On exhaustion the stream loop may reset the round counter this many
times so a long, legitimate task continues instead of hard-failing.
Round renewal never resets wall-clock (durable context successors do); a
value of 0 means no graceful continuation (immediate hard stop).
Implementations§
Source§impl TurnBudget
impl TurnBudget
Sourcepub fn for_role(role: TurnRole) -> Self
pub fn for_role(role: TurnRole) -> Self
Compiled per-role defaults. Foreground is the most generous (a human is watching); autonomous is the tightest (nobody is); workers sit between (bounded delegation with a supervising turn).
Sourcepub fn has_time_limit(&self) -> bool
pub fn has_time_limit(&self) -> bool
Whether a wall-clock limit can end (or checkpoint) a turn. A zero limit counts as exhausted at once and never as a time checkpoint.
Sourcepub fn max_elapsed_secs(&self) -> Option<u64>
pub fn max_elapsed_secs(&self) -> Option<u64>
The wall-clock limit in seconds, for diagnostics (None = no limit).
Sourcepub fn from_config(role: TurnRole, config: &TurnBudgetsConfig) -> Self
pub fn from_config(role: TurnRole, config: &TurnBudgetsConfig) -> Self
Role defaults overlaid with the typed config (unset fields keep the compiled defaults).
Trait Implementations§
Source§impl Clone for TurnBudget
impl Clone for TurnBudget
Source§impl Debug for TurnBudget
impl Debug for TurnBudget
Source§impl PartialEq for TurnBudget
impl PartialEq for TurnBudget
impl StructuralPartialEq for TurnBudget
Auto Trait Implementations§
impl Freeze for TurnBudget
impl RefUnwindSafe for TurnBudget
impl Send for TurnBudget
impl Sync for TurnBudget
impl Unpin for TurnBudget
impl UnsafeUnpin for TurnBudget
impl UnwindSafe for TurnBudget
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.