pub struct SessionContext {
pub session_id: SessionId,
pub conversation_history: TokenEfficientHistory,
pub task_context: TaskContext,
pub agent_state: AgentState,
pub workspace_state: WorkspaceState,
pub metadata: HashMap<String, Value>,
pub config: SessionConfig,
}
Expand description
Session context containing AI-relevant state
Fields§
§session_id: SessionId
Session ID
conversation_history: TokenEfficientHistory
Conversation history (token-efficient)
task_context: TaskContext
Current task context
agent_state: AgentState
Agent state
workspace_state: WorkspaceState
Workspace state
metadata: HashMap<String, Value>
Context metadata
config: SessionConfig
Session configuration
Implementations§
Source§impl SessionContext
impl SessionContext
Sourcepub fn add_message(&mut self, message: Message)
pub fn add_message(&mut self, message: Message)
Add a message to the conversation history (takes Message struct)
Sourcepub fn add_message_raw(&mut self, role: MessageRole, content: String)
pub fn add_message_raw(&mut self, role: MessageRole, content: String)
Add a message to the conversation history (legacy method)
Sourcepub fn get_message_count(&self) -> usize
pub fn get_message_count(&self) -> usize
Get the total number of messages in the conversation history
Sourcepub fn get_total_tokens(&self) -> usize
pub fn get_total_tokens(&self) -> usize
Get the total estimated token count
Sourcepub fn get_recent_messages(&self, n: usize) -> Vec<&Message>
pub fn get_recent_messages(&self, n: usize) -> Vec<&Message>
Get the most recent n messages
Sourcepub async fn compress_context(&mut self) -> bool
pub async fn compress_context(&mut self) -> bool
Compress the context if needed, returns true if compression occurred
Sourcepub fn update_task(&mut self, task: TaskContext)
pub fn update_task(&mut self, task: TaskContext)
Update the task context
Sourcepub fn summarize(&self) -> ContextSummary
pub fn summarize(&self) -> ContextSummary
Get a summary of the context
Trait Implementations§
Source§impl Clone for SessionContext
impl Clone for SessionContext
Source§fn clone(&self) -> SessionContext
fn clone(&self) -> SessionContext
Returns a duplicate of the value. Read more
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for SessionContext
impl Debug for SessionContext
Source§impl<'de> Deserialize<'de> for SessionContext
impl<'de> Deserialize<'de> for SessionContext
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
Auto Trait Implementations§
impl Freeze for SessionContext
impl RefUnwindSafe for SessionContext
impl Send for SessionContext
impl Sync for SessionContext
impl Unpin for SessionContext
impl UnwindSafe for SessionContext
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
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>
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)
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)
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.