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: u64Monotonic 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: ResolvedContextOptimizationPhase 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
impl RuntimeSnapshot
pub fn bare(nexo_config: Arc<AgentConfig>, version: u64) -> Self
pub fn build( nexo_config: Arc<AgentConfig>, llm_registry: &LlmRegistry, llm_cfg: &LlmConfig, version: u64, ) -> Result<Self>
Sourcepub fn policy_for(
&self,
binding_index: Option<usize>,
) -> Option<Arc<EffectiveBindingPolicy>>
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)).
Sourcepub fn tools_for(
&self,
agent_id: &str,
binding_index: Option<usize>,
base: &ToolRegistry,
allowed_tools: &[String],
) -> Arc<ToolRegistry> ⓘ
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).
Sourcepub 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> ⓘ
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
impl Clone for RuntimeSnapshot
Source§fn clone(&self) -> RuntimeSnapshot
fn clone(&self) -> RuntimeSnapshot
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for RuntimeSnapshot
impl !RefUnwindSafe for RuntimeSnapshot
impl Send for RuntimeSnapshot
impl Sync for RuntimeSnapshot
impl Unpin for RuntimeSnapshot
impl UnsafeUnpin for RuntimeSnapshot
impl !UnwindSafe for RuntimeSnapshot
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> 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