Skip to main content

RuntimeState

Struct RuntimeState 

Source
pub struct RuntimeState {
Show 19 fields pub provider_capabilities: ProviderCapabilitySnapshot, pub processes: Vec<ManagedProcess>, pub background_agents: Vec<BackgroundAgent>, 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 calls_since_task_update: u32, pub vision_warned: HashSet<String>, pub ollama_converged_num_ctx: HashMap<String, u32>, pub run_started: Option<SystemTime>, pub run_tokens: RunTokenCounter, pub run_line_changes: RunLineChanges, pub truncation_recoveries: u32, pub empty_continuations: u32, pub continue_recoveries: u32, pub auto_compact_suppressed: bool,
}
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>§background_agents: Vec<BackgroundAgent>

Subagents detached from their turn via Ctrl+B, newest last.

§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.

§calls_since_task_update: u32

Model-call cycles since the task checklist last changed, while a task sits in_progress. Drives the staleness nudge (see push_call_model); session-only, reset by every Msg::TasksUpdated.

§vision_warned: HashSet<String>

Models we’ve already shown the no-vision-model notice for this session. Session-only (not persisted), so the one-shot warning behaves like the auto-fit hint and offload warning.

§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_tokens: RunTokenCounter

Output tokens committed in completed phases of the current run (parent turns, subagents, mid-run compactions), so the spinner’s token counter accumulates across tool steps instead of resetting each model call. The live phase’s char-based estimate is added on top at render time.

§run_line_changes: RunLineChanges

Lines added/removed by file-mutating tools (write_file, apply_patch) across the whole run, summed from each outcome’s exact metadata counts so the end-of-run summary can show +N/-M without the user totting up per-call diffs. Reset on submit alongside run_tokens. Session-only.

§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.

§empty_continuations: u32

Consecutive turns in the current run that produced no visible output (no assistant text and no tool calls) — even if the model spent the turn on hidden reasoning. Under MAX_EMPTY_CONTINUATIONS the run auto-retries the model call so a stalled turn isn’t left silent; at the cap it stops with a hint. Reset on a fresh run and whenever a turn makes progress. Session-only.

§continue_recoveries: u32

Consecutive auto-continuations in the current run after a response hit the provider’s per-response OUTPUT cap with window room to spare (compaction can’t help those — the reply is continued in a fresh turn instead). Bounded by MAX_OUTPUT_CONTINUATIONS; reset whenever a turn ends any other way. Session-only.

§auto_compact_suppressed: bool

Auto-threshold compaction failed, so it is paused until a compaction succeeds, the user runs /compact, or the conversation is switched. Without this, a summarizer that keeps failing (e.g. a model that can’t produce the required checkpoint structure) silently retries — and pays for — a draft + review model call on every subsequent turn. 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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