pub struct ContextState {Show 15 fields
pub kind: ContextKind,
pub version: u64,
pub summary: Summary,
pub messages: Vec<Msg>,
pub skills: Vec<SkillRef>,
pub plan: Option<Plan>,
pub preflight: Option<Value>,
pub est_tokens: u64,
pub model_window: u64,
pub principal: Option<String>,
pub task: Option<String>,
pub turns: u64,
pub created: u64,
pub updated: u64,
pub dirty: bool,
}Expand description
The durable context record: everything about a conversation that must survive a restart.
Fields§
§kind: ContextKind§version: u64§summary: Summary§messages: Vec<Msg>§skills: Vec<SkillRef>§plan: Option<Plan>§preflight: Option<Value>§est_tokens: u64§model_window: u64§principal: Option<String>§task: Option<String>The A2A task the conversation’s current work is attached to.
turns: u64§created: u64§updated: u64§dirty: boolWhether the record has changed since its last checkpoint (never stored).
Implementations§
Source§impl ContextState
impl ContextState
pub fn new(kind: ContextKind, model_window: u64) -> ContextState
pub fn append(&mut self, msg: Msg)
pub fn append_all(&mut self, msgs: impl IntoIterator<Item = Msg>)
pub fn touch(&mut self)
Sourcepub fn recount(&mut self)
pub fn recount(&mut self)
Recompute the token estimate from scratch (after compaction / restore).
Sourcepub fn needs_compaction(&self, compact_at: f64) -> bool
pub fn needs_compaction(&self, compact_at: f64) -> bool
Whether the compaction threshold is crossed (compact_at × window).
Sourcepub fn slice(&self) -> Vec<Msg>
pub fn slice(&self) -> Vec<Msg>
The transcript slice a turn worker receives: summary block (if any) + plan block (if any) as system messages, then the messages verbatim.
Sourcepub fn to_wire(&self) -> Vec<Message>
pub fn to_wire(&self) -> Vec<Message>
The prompt slice for a turn: summary block (if any) + plan block (if any) as system messages, then the messages verbatim.
Sourcepub fn skill_names(&self) -> BTreeSet<String>
pub fn skill_names(&self) -> BTreeSet<String>
The loaded skill names.
pub fn load_skill( &mut self, name: &str, hash: &str, max_loaded: usize, ) -> Result<(), String>
pub fn unload_skill(&mut self, name: &str) -> bool
Trait Implementations§
Source§impl Clone for ContextState
impl Clone for ContextState
Source§fn clone(&self) -> ContextState
fn clone(&self) -> ContextState
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ContextState
impl Debug for ContextState
Source§impl<'de> Deserialize<'de> for ContextState
impl<'de> Deserialize<'de> for ContextState
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
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 PartialEq for ContextState
impl PartialEq for ContextState
Source§impl Serialize for ContextState
impl Serialize for ContextState
impl StructuralPartialEq for ContextState
Auto Trait Implementations§
impl Freeze for ContextState
impl RefUnwindSafe for ContextState
impl Send for ContextState
impl Sync for ContextState
impl Unpin for ContextState
impl UnsafeUnpin for ContextState
impl UnwindSafe for ContextState
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
Mutably borrows from an owned value. Read more