Skip to main content

RuntimeSessionState

Struct RuntimeSessionState 

Source
pub struct RuntimeSessionState {
Show 21 fields pub session_id: String, pub policy: SessionPolicy, pub agent_frames: Vec<AgentFrameRecord>, pub current_agent_frame_id: AgentFrameId, pub session_graph: SessionGraph, pub turn_index: usize, pub token_usage: TokenUsage, pub last_prompt_usage: Option<PromptUsage>, pub protocol_turn_options: ProtocolTurnOptions, pub tool_state_ref: Option<BlobRef>, pub tool_state_generation: Option<u64>, pub tool_state_snapshot: Option<ToolState>, pub plugin_snapshot_ref: Option<BlobRef>, pub plugin_snapshot_revision: Option<u64>, pub plugin_snapshot: Option<PluginSessionSnapshot>, pub execution_state_ref: Option<BlobRef>, pub execution_state_snapshot: Option<Vec<u8>>, pub token_ledger: Vec<TokenLedgerEntry>, pub checkpoint_ref: Option<BlobRef>, pub head_revision: Option<u64>, pub graph_replace_required: bool,
}
Expand description

The runtime’s view of a session: the persistable snapshot fields plus scratch fields the runtime tracks but never persists (head-revision CAS guard, pending dirty-write buffers, replace-graph flag). Public serialization goes through RuntimeSessionState::to_snapshot, which drops runtime-only fields by construction.

Fields§

§session_id: String§policy: SessionPolicy§agent_frames: Vec<AgentFrameRecord>§current_agent_frame_id: AgentFrameId§session_graph: SessionGraph§turn_index: usize§token_usage: TokenUsage§last_prompt_usage: Option<PromptUsage>§protocol_turn_options: ProtocolTurnOptions§tool_state_ref: Option<BlobRef>§tool_state_generation: Option<u64>§tool_state_snapshot: Option<ToolState>§plugin_snapshot_ref: Option<BlobRef>§plugin_snapshot_revision: Option<u64>§plugin_snapshot: Option<PluginSessionSnapshot>§execution_state_ref: Option<BlobRef>§execution_state_snapshot: Option<Vec<u8>>§token_ledger: Vec<TokenLedgerEntry>

Cost-accounting ledger. Every LLM call (parent turns, subagent children, compaction, observers, background helpers) contributes an entry keyed by (source, model). Separate from token_usage which tracks context-window accounting only.

§checkpoint_ref: Option<BlobRef>§head_revision: Option<u64>

Store head revision observed by the runtime. Commits use it for optimistic concurrency; None means the runtime is creating the first persisted head.

§graph_replace_required: bool

Signals that the next commit must write the full graph (a destructive rewrite happened, e.g. heal_orphaned_leaf). Cleared after the next commit.

Implementations§

Source§

impl RuntimeSessionState

Source

pub fn from_snapshot(snapshot: SessionSnapshot) -> Self

Source

pub fn to_snapshot(&self) -> SessionSnapshot

Source

pub fn apply_snapshot(&mut self, snapshot: &SessionSnapshot)

Source

pub fn stamp_runtime_state( &mut self, tool_state: Option<&ToolState>, plugin_snapshot: Option<&PluginSessionSnapshot>, )

Source

pub fn usage_report(&self) -> SessionUsageReport

Source

pub fn replace_active_read_state(&mut self, messages: &[Message])

Source

pub fn append_active_read_delta(&mut self, messages: &[Message])

Source

pub fn append_active_conversation_messages(&mut self, messages: &[Message])

Source

pub fn read_view(&self) -> SessionReadView

Source

pub fn session_graph(&self) -> &SessionGraph

Source

pub fn policy(&self) -> &SessionPolicy

Source

pub fn turn_state(&self) -> PersistedTurnState

Source

pub fn token_ledger(&self) -> &[TokenLedgerEntry]

Source

pub fn apply_persisted_commit_result(&mut self, result: RuntimeCommitResult)

Source

pub fn discard_runtime_snapshots(&mut self)

Source

pub fn set_execution_state_snapshot( &mut self, execution_state_snapshot: Option<Vec<u8>>, )

Source

pub fn execution_state_snapshot(&self) -> Option<&[u8]>

Source

pub fn refresh_plugin_snapshots(&mut self, plugins: &PluginSession)

Source§

impl RuntimeSessionState

Trait Implementations§

Source§

impl Clone for RuntimeSessionState

Source§

fn clone(&self) -> RuntimeSessionState

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 RuntimeSessionState

Source§

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

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

impl Default for RuntimeSessionState

Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for RuntimeSessionState

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 RuntimeSessionState

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