pub struct AgentSession {
pub id: String,
pub title: String,
pub created_at: DateTime<Utc>,
pub last_active: DateTime<Utc>,
pub model: Option<String>,
pub state: SessionState,
}Expand description
A persisted agent session.
Fields§
§id: StringUnique session id.
title: StringHuman-friendly title.
created_at: DateTime<Utc>Creation time.
last_active: DateTime<Utc>Last activity time.
model: Option<String>Optional model hint (primarily for CLI).
state: SessionStateUnified session state (conversation history, tool calls, configs, etc.).
Implementations§
Source§impl AgentSession
impl AgentSession
Sourcepub fn new_sandbox(model: Option<String>) -> Result<Self, AppError>
pub fn new_sandbox(model: Option<String>) -> Result<Self, AppError>
Create a new session with an auto-generated sandbox workspace.
Sourcepub fn new_with_workspace(
workspace_dir: PathBuf,
model: Option<String>,
) -> Result<Self, AppError>
pub fn new_with_workspace( workspace_dir: PathBuf, model: Option<String>, ) -> Result<Self, AppError>
Create a new session using an existing directory as its workspace.
Sourcepub fn fork(&self) -> Self
pub fn fork(&self) -> Self
Clone this session into a new persisted session with a fresh identity.
The fork preserves conversation history, model hints, and workspace association while assigning a new session id and fresh timestamps.
Sourcepub fn add_user_message(&mut self, content: &str, source: MessageSource)
pub fn add_user_message(&mut self, content: &str, source: MessageSource)
Append a user message.
Sourcepub fn add_assistant_message(&mut self, content: &str, thinking: Option<String>)
pub fn add_assistant_message(&mut self, content: &str, thinking: Option<String>)
Append an assistant message.
Sourcepub fn add_tool_message(&mut self, tool_call_id: &str, content: &str)
pub fn add_tool_message(&mut self, tool_call_id: &str, content: &str)
Append a tool result message.
Sourcepub fn message_count(&self) -> usize
pub fn message_count(&self) -> usize
Return the message count.
Sourcepub fn workspace_dir(&self) -> Option<&PathBuf>
pub fn workspace_dir(&self) -> Option<&PathBuf>
Return the configured workspace directory.
Sourcepub fn to_pipeline_messages_limited(&self, limit: usize) -> Vec<Message>
pub fn to_pipeline_messages_limited(&self, limit: usize) -> Vec<Message>
Convert the last limit messages into pipeline messages.
Sourcepub fn to_pretty_json(&self) -> Result<String, AppError>
pub fn to_pretty_json(&self) -> Result<String, AppError>
Serialize this session as pretty JSON.
Trait Implementations§
Source§impl Clone for AgentSession
impl Clone for AgentSession
Source§fn clone(&self) -> AgentSession
fn clone(&self) -> AgentSession
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AgentSession
impl Debug for AgentSession
Source§impl<'de> Deserialize<'de> for AgentSession
impl<'de> Deserialize<'de> for AgentSession
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>,
Auto Trait Implementations§
impl Freeze for AgentSession
impl RefUnwindSafe for AgentSession
impl Send for AgentSession
impl Sync for AgentSession
impl Unpin for AgentSession
impl UnsafeUnpin for AgentSession
impl UnwindSafe for AgentSession
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].