Skip to main content

RuntimeSnapshot

Struct RuntimeSnapshot 

Source
pub struct RuntimeSnapshot {
    pub nexo_config: Arc<AgentConfig>,
    pub effective_policies: Arc<DashMap<Option<usize>, Arc<EffectiveBindingPolicy>>>,
    pub tool_cache: Arc<ToolRegistryCache>,
    pub llm_client: Option<Arc<dyn LlmClient>>,
    pub version: u64,
    pub context_optimization: ResolvedContextOptimization,
}
Expand description

Immutable snapshot of everything hot-reload can swap on an agent.

Held behind Arc<ArcSwap<RuntimeSnapshot>> by AgentRuntime; the intake hot path calls .load() per event (lock-free). Fields that never change across reloads (the mpsc senders, the tokio JoinSet, the shutdown token) stay on AgentRuntime itself.

Fields§

§nexo_config: Arc<AgentConfig>

The AgentConfig this snapshot was built from. Downstream consumers (delegation ACL, heartbeat interval lookups) read agent-level fields from here instead of holding a separate Arc<AgentConfig>.

§effective_policies: Arc<DashMap<Option<usize>, Arc<EffectiveBindingPolicy>>>

Pre-resolved per-binding capability policies, keyed by binding_index (Some(n) for real bindings, None for the legacy agent-level fallback). Built at snapshot construction so the intake path is an Arc lookup, not a resolve.

§tool_cache: Arc<ToolRegistryCache>

Per-binding filtered tool registry cache. Keyed by (agent_id, binding_index); entries built lazily the first time a binding sees traffic. Fresh per snapshot so a reload that changes allowed_tools does not serve a stale filtered clone.

§llm_client: Option<Arc<dyn LlmClient>>

LLM client for this agent. None in early-boot snapshots built before the LlmRegistry is wired in (tests, scaffolding). Production snapshots constructed via the reload coordinator always populate this; consumers that fall back read the behavior-owned llm field.

§version: u64

Monotonic version per agent. The intake path tags log lines with this so operators can correlate “session X used version Y” when debugging a reload.

§context_optimization: ResolvedContextOptimization

Phase F follow-up — the four context-optimization enables, already resolved against llm.context_optimization and the agent’s per-agent override. Captured at snapshot-build time so the agent loop reads the current enables on every turn (a reload that swaps the snapshot is observed on the next snapshot_ref.load()). The boot-time wiring on LlmAgentBehavior (compactor / token_counter / workspace_cache instances) stays put — these flags only gate whether the agent loop uses those instances on a given turn.

Implementations§

Source§

impl RuntimeSnapshot

Source

pub fn bare(nexo_config: Arc<AgentConfig>, version: u64) -> Self

Source

pub fn build( nexo_config: Arc<AgentConfig>, llm_registry: &LlmRegistry, llm_cfg: &LlmConfig, version: u64, ) -> Result<Self>

Source

pub fn policy_for( &self, binding_index: Option<usize>, ) -> Option<Arc<EffectiveBindingPolicy>>

Convenience: look up the pre-resolved policy for a binding index. Returns None only when the policy map is missing the slot (never happens for a snapshot built via build — the legacy path seeds None and each real binding seeds Some(n)).

Source

pub fn tools_for( &self, agent_id: &str, binding_index: Option<usize>, base: &ToolRegistry, allowed_tools: &[String], ) -> Arc<ToolRegistry>

Fetch or build the filtered tool registry for a binding. Thin delegation to the per-snapshot ToolRegistryCache; the base registry stays external to the snapshot because it is owned by the AgentRuntime and typically shared across reloads (plugin hot-reload is Phase 19).

Source

pub fn tools_for_with_dispatch( &self, agent_id: &str, binding_index: Option<usize>, base: &ToolRegistry, allowed_tools: &[String], dispatch_policy: &DispatchPolicy, is_admin: bool, ) -> Arc<ToolRegistry>

PT-2 — dispatch-aware variant. Same lazy cache, but the filtered registry also has apply_dispatch_capability applied so dispatch tools the binding’s DispatchPolicy disallows are not registered.

Trait Implementations§

Source§

impl Clone for RuntimeSnapshot

Source§

fn clone(&self) -> RuntimeSnapshot

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RuntimeSnapshot

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more