pub struct SharedInfra {
pub state: Arc<StateStore>,
pub log: Arc<Mutex<EventLog>>,
pub policies: Arc<RwLock<PolicyEngine>>,
pub budget: Arc<CoordinationBudget>,
}Expand description
Factory for creating Runtime instances with shared state, event log, and policies.
In a multi-agent system, all agents see the same state store and write to the same event log. Each agent gets its own tool set and executor.
A CoordinationBudget is always present (unbounded by default). Patterns
gate each spawn through begin_agent and report spend
through record_output, so budget enforcement is a
uniform, always-on code path that costs nothing when no limits are set.
Fields§
§state: Arc<StateStore>§log: Arc<Mutex<EventLog>>§policies: Arc<RwLock<PolicyEngine>>§budget: Arc<CoordinationBudget>Implementations§
pub fn new() -> Self
Sourcepub fn with_budget(self, limits: BudgetLimits) -> Self
pub fn with_budget(self, limits: BudgetLimits) -> Self
Attach a coordination budget built from the given limits. Patterns run against this infra will refuse to start agents once a limit is crossed.
Attach a pre-built (possibly shared) coordination budget.
Sourcepub fn begin_agent(&self) -> Result<(), BudgetError>
pub fn begin_agent(&self) -> Result<(), BudgetError>
Reserve a budget slot for one agent. Ok(()) means the agent may run;
Err carries why it was denied. Patterns call this immediately before a
spawn and record a budget_skipped_output
on denial.
Sourcepub fn record_output(&self, out: &AgentOutput)
pub fn record_output(&self, out: &AgentOutput)
Record an agent’s reported token/cost spend against the budget.
Sourcepub fn make_runtime(&self) -> Runtime
pub fn make_runtime(&self) -> Runtime
Create a Runtime that shares this infra’s state, log, and policies.
Each runtime gets its own tool set, executor, and idempotency cache.
Sourcepub fn make_isolated_runtime(&self, agent_name: &str) -> (Runtime, AgentContext)
pub fn make_isolated_runtime(&self, agent_name: &str) -> (Runtime, AgentContext)
Create a Runtime with per-agent isolated state overlay.
Writes go to a local StateStore; reads fall through to shared state.
Call AgentContext::merge_to_parent() after the agent completes.
Trait Implementations§
Auto Trait Implementations§
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<T> ErasedDestructor for Twhere
T: 'static,
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 more