Skip to main content

RuntimeState

Struct RuntimeState 

Source
pub struct RuntimeState {
    pub provider_capabilities: ProviderCapabilitySnapshot,
    pub processes: Vec<ManagedProcess>,
    pub timeline: Vec<RuntimeTimelineEvent>,
    pub builtin_tool_schema_tokens: usize,
    pub ollama_context: Option<OllamaContextInfo>,
    pub ollama_placement: Option<OllamaPlacement>,
    pub hinted_models: HashSet<String>,
    pub offload_warned: HashSet<String>,
    pub ollama_converged_num_ctx: HashMap<String, u32>,
    pub run_started: Option<SystemTime>,
    pub run_committed_tokens: usize,
    pub truncation_recoveries: u32,
}
Expand description

Runtime state that is not part of the chat transcript sent to a model, but is useful for UI, slash commands, and debugging.

Fields§

§provider_capabilities: ProviderCapabilitySnapshot§processes: Vec<ManagedProcess>§timeline: Vec<RuntimeTimelineEvent>§builtin_tool_schema_tokens: usize

Estimated token cost of the built-in tool schemas the effect runner appends to every model request during dispatch. The reducer’s /context preview builds an MCP-only request and can’t see these, so the runner reports the figure via Msg::BuiltinToolSchemaTokens and /context folds it in to match what dispatch actually decides.

§ollama_context: Option<OllamaContextInfo>

Resolved Ollama context window for the active model (None until the first turn probes it, or for non-Ollama providers).

§ollama_placement: Option<OllamaPlacement>

Post-turn /api/ps memory placement for the active model (None until a turn probes it). Volatile, so it’s tracked separately from the window.

§hinted_models: HashSet<String>

Models we’ve already shown the proactive auto-fit hint for this session. Session-only (not persisted) so the gentle reminder reappears each launch.

§offload_warned: HashSet<String>

Models we’ve already warned about VRAM offload this session. Session-only, so the once-per-session warning behaves like the auto-fit hint.

§ollama_converged_num_ctx: HashMap<String, u32>

Auto-converge: per-model num_ctx that the post-turn /api/ps check found fits VRAM, keyed by model id. Session-only (not persisted) because it depends on whatever else is using VRAM right now; re-derived each session. Read by build_chat_request below a user override.

§run_started: Option<SystemTime>

When the current user interaction began. One “turn” in Mermaid is a single model call + its tools; an agentic run spans many such turns (each tool follow-up mints a fresh TurnId). This anchors the spinner’s elapsed timer to the whole run so it doesn’t reset to 0 at every tool step. Set on submit, read only while generating/executing tools. Session-only.

§run_committed_tokens: usize

Estimated tokens generated in completed phases of the current run, so the spinner’s token counter accumulates across tool steps instead of resetting each model call. The live phase’s estimate is added on top at render time.

§truncation_recoveries: u32

Consecutive auto-compact-and-continue recoveries in the current run after a context-window truncation. Bounded by settings.compaction.max_truncation_recoveries (0 = uncapped) and reset whenever the run makes progress, so it caps only no-progress thrashing on a too-small window. Session-only.

Implementations§

Source§

impl RuntimeState

Source

pub fn new(model_id: &str) -> Self

Source

pub fn set_model(&mut self, model_id: &str)

Source

pub fn record_signal(&mut self, signal: RuntimeSignal)

Source

pub fn register_process(&mut self, process: ManagedProcess)

Trait Implementations§

Source§

impl Clone for RuntimeState

Source§

fn clone(&self) -> RuntimeState

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 RuntimeState

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for RuntimeState

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for RuntimeState

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for RuntimeState

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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: Sized + 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: Sized + 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<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