pub struct Session {Show 24 fields
pub id: String,
pub title: String,
pub pinned: bool,
pub kind: SessionKind,
pub parent_session_id: Option<String>,
pub root_session_id: String,
pub spawn_depth: u32,
pub messages: Vec<Message>,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
pub task_list: Option<TaskList>,
pub pending_question: Option<PendingQuestion>,
pub model: String,
pub model_ref: Option<ProviderModelRef>,
pub reasoning_effort: Option<ReasoningEffort>,
pub metadata: HashMap<String, String>,
pub token_budget: Option<TokenBudget>,
pub token_usage: Option<TokenBudgetUsage>,
pub conversation_summary: Option<ConversationSummary>,
pub prompt_snapshot: Option<PromptSnapshot>,
pub compression_events: Vec<CompressionEvent>,
pub compression_instructions: Option<String>,
pub agent_runtime_state: Option<AgentRuntimeState>,
pub force_manual_compression: Option<String>,
}Expand description
A complete conversation session with state management.
Fields§
§id: String§title: String§pinned: bool§kind: SessionKind§parent_session_id: Option<String>§root_session_id: String§spawn_depth: u32§messages: Vec<Message>§created_at: DateTime<Utc>§updated_at: DateTime<Utc>§task_list: Option<TaskList>§pending_question: Option<PendingQuestion>§model: String§model_ref: Option<ProviderModelRef>§reasoning_effort: Option<ReasoningEffort>§metadata: HashMap<String, String>§token_budget: Option<TokenBudget>§token_usage: Option<TokenBudgetUsage>§conversation_summary: Option<ConversationSummary>§prompt_snapshot: Option<PromptSnapshot>§compression_events: Vec<CompressionEvent>§compression_instructions: Option<String>Custom instructions for conversation summarization at the session level.
Overrides config-level compression_instructions when set.
agent_runtime_state: Option<AgentRuntimeState>§force_manual_compression: Option<String>Runtime-only flag: when set, the next mid-turn compression check should
force compression regardless of threshold. Set by compact_context tool.
Implementations§
Source§impl Session
impl Session
pub fn new(id: impl Into<String>, model: impl Into<String>) -> Session
pub fn new_child( id: impl Into<String>, root_session_id: impl Into<String>, model: impl Into<String>, title: impl Into<String>, ) -> Session
pub fn add_message(&mut self, message: Message)
pub fn compact_oversized_tool_messages(&mut self) -> usize
Sourcepub fn clear_derived_context_state(&mut self)
pub fn clear_derived_context_state(&mut self)
Clear all ephemeral/derived state that should not persist across turns.
Resets token usage, compression state, previous response metadata, and message compression flags. Typically called before a truncation or when refreshing session state for a new execution.
pub fn set_task_list(&mut self, task_list: TaskList)
pub fn update_task_item( &mut self, item_id: &str, status: TaskItemStatus, notes: Option<&str>, criteria_met: Option<&[String]>, ) -> Result<String, String>
pub fn format_task_list_for_prompt(&self) -> String
pub fn set_pending_question( &mut self, tool_call_id: String, tool_name: String, question: String, options: Vec<String>, allow_custom: bool, )
pub fn clear_pending_question(&mut self)
pub fn has_pending_question(&self) -> bool
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Session
impl<'de> Deserialize<'de> for Session
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Session, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Session, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for Session
impl Serialize for Session
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl Freeze for Session
impl RefUnwindSafe for Session
impl Send for Session
impl Sync for Session
impl Unpin for Session
impl UnsafeUnpin for Session
impl UnwindSafe for Session
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