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<AgentSession, AppError>
pub fn new_sandbox(model: Option<String>) -> Result<AgentSession, AppError>
Create a new session with an auto-generated sandbox workspace.
Sourcepub fn new_with_workspace(
workspace_dir: PathBuf,
model: Option<String>,
) -> Result<AgentSession, AppError>
pub fn new_with_workspace( workspace_dir: PathBuf, model: Option<String>, ) -> Result<AgentSession, AppError>
Create a new session using an existing directory as its workspace.
Sourcepub fn fork(&self) -> AgentSession
pub fn fork(&self) -> AgentSession
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<AgentSession, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<AgentSession, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for AgentSession
impl Serialize for AgentSession
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,
Auto Trait Implementations§
impl Freeze for AgentSession
impl RefUnwindSafe for AgentSession
impl Send for AgentSession
impl Sync for AgentSession
impl Unpin 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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§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>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§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].