pub struct Containment {
pub max_total_agents: u32,
pub max_concurrent: u32,
pub max_depth: u32,
pub max_total_tokens: u64,
pub max_total_cost: Option<u64>,
pub max_total_duration: Option<Duration>,
}Expand description
The caps a whole agent tree runs under. Tokens are the hard spend ceiling (no price telemetry exists, so spend is counted in tokens); an optional cost and duration are carried for callers that supply them.
use io_harness::Containment;
// Twelve agents in the tree, four running at once, two levels of nesting, and
// 200k tokens for all of them together. A spawned contract can tighten any of
// these and can raise none of them.
let containment = Containment::new(12, 4, 2, 200_000);
// The ceiling actually enforced is the token one: a provider reports tokens
// and never money, so `max_total_cost` is inert and stays `None`.
assert_eq!(containment.max_total_tokens, 200_000);
assert_eq!(containment.max_total_cost, None);
// Serde, so an operator's config file is the source of the caps rather than a
// recompile.
let stored = serde_json::to_string(&containment).unwrap();
let loaded: Containment = serde_json::from_str(&stored).unwrap();
assert_eq!(loaded, containment);Fields§
§max_total_agents: u32Maximum number of agents that may exist in the tree, root included.
max_concurrent: u32Maximum number of agents that may run at once.
max_depth: u32Maximum nesting depth, counted from the root (the root is depth 0).
max_total_tokens: u64Aggregate token ceiling drawn down by the entire tree together.
max_total_cost: Option<u64>Optional aggregate cost ceiling, in whatever unit the caller supplies (there is no price telemetry, so the crate never derives this itself). Reserved, and not enforced. Setting it has no effect.
Enforcing a cost ceiling needs a price per token, and the crate has no price telemetry — a provider reports tokens, never money, so any figure the harness compared against would be one it invented. The field is kept rather than removed because it serialises in callers’ stored configuration and deleting it would break their deserialisation for no gain; it is documented as inert instead, which is the honest state.
Spend that is enforced is Self::max_total_tokens. To bound money,
convert your budget to tokens at your provider’s rate and set that.
max_total_duration: Option<Duration>Optional wall-clock ceiling for the whole tree, measured from when the ROOT run started — so it counts a 24-hour tree’s whole life, including time the process was down, not the age of whichever agent notices.
Crossing it halts the tree with
RunOutcome::BudgetCeilingReached,
the same way the token ceiling does, and a child’s own contract cannot
raise it. Declared in 0.5.0 and not actually enforced until 0.12.0.
Implementations§
Trait Implementations§
Source§impl Clone for Containment
impl Clone for Containment
Source§fn clone(&self) -> Containment
fn clone(&self) -> Containment
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Containment
impl Debug for Containment
Source§impl<'de> Deserialize<'de> for Containment
impl<'de> Deserialize<'de> for Containment
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Containment
Source§impl PartialEq for Containment
impl PartialEq for Containment
Source§impl Serialize for Containment
impl Serialize for Containment
impl StructuralPartialEq for Containment
Auto Trait Implementations§
impl Freeze for Containment
impl RefUnwindSafe for Containment
impl Send for Containment
impl Sync for Containment
impl Unpin for Containment
impl UnsafeUnpin for Containment
impl UnwindSafe for Containment
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> Scalar for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.