pub struct Session {
pub id: u64,
pub agent: String,
pub history: Vec<Message>,
pub created_by: String,
pub title: String,
pub uptime_secs: u64,
pub created_at: Instant,
pub file_path: Option<PathBuf>,
}Expand description
A conversation session tied to a specific agent.
Fields§
§id: u64Unique session identifier (monotonic counter, runtime-only).
agent: StringName of the agent this session is bound to.
history: Vec<Message>Conversation history (the working context for the LLM).
created_by: StringOrigin of this session (e.g. “user”, “tg:12345”).
title: StringConversation title (set by the set_title tool).
uptime_secs: u64Accumulated active time in seconds (persisted to meta).
created_at: InstantWhen this session was loaded/created in this process.
file_path: Option<PathBuf>Path to the JSONL persistence file.
Implementations§
Source§impl Session
impl Session
Sourcepub fn new(
id: u64,
agent: impl Into<String>,
created_by: impl Into<String>,
) -> Self
pub fn new( id: u64, agent: impl Into<String>, created_by: impl Into<String>, ) -> Self
Create a new session with an empty history.
Sourcepub fn init_file(&mut self, sessions_dir: &Path)
pub fn init_file(&mut self, sessions_dir: &Path)
Initialize a new JSONL file in the flat sessions directory.
Creates {sessions_dir}/{agent}_{sender}_{seq}.jsonl with
seq auto-incremented globally per identity.
Sourcepub fn set_title(&mut self, title: &str)
pub fn set_title(&mut self, title: &str)
Set the conversation title and rename the file to include the title slug.
Sourcepub fn rewrite_meta(&self)
pub fn rewrite_meta(&self)
Rewrite the meta line (first line) of the JSONL file.
Sourcepub fn append_messages(&self, messages: &[Message])
pub fn append_messages(&self, messages: &[Message])
Append messages to the JSONL file. Skips auto-injected messages.
Sourcepub fn append_compact(&self, summary: &str)
pub fn append_compact(&self, summary: &str)
Append a compact marker to the JSONL file.