pub struct Session {
pub id: SessionId,
pub user_id: String,
pub user_messages: Vec<UserMessage>,
pub agent_responses: Vec<AgentResponse>,
pub trajectory_steps: Vec<TrajectoryStepRecord>,
pub active_seed_id: Option<String>,
pub active_persona_id: Option<String>,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
pub metadata: SessionMetadata,
}Expand description
A session represents a single user conversation.
Sessions track the full message history and metadata for a user conversation. They are created per user interaction and persisted for later retrieval.
Fields§
§id: SessionIdUnique session identifier.
user_id: StringUser ID who owns this session.
user_messages: Vec<UserMessage>All user messages in this session.
agent_responses: Vec<AgentResponse>All agent responses in this session.
trajectory_steps: Vec<TrajectoryStepRecord>RFC-015: tool execution trajectory accumulated for this session. Appended on each orchestrator run; consumed by the Web UI to render the execution timeline when the session is re-opened.
active_seed_id: Option<String>Currently active seed ID (if any).
active_persona_id: Option<String>Currently active persona ID (for future multi-persona support).
created_at: DateTime<Utc>Timestamp when the session was created.
updated_at: DateTime<Utc>Timestamp when the session was last updated.
metadata: SessionMetadataArbitrary key-value metadata.
Implementations§
Source§impl Session
impl Session
Sourcepub fn with_id(user_id: impl Into<String>, session_id: SessionId) -> Self
pub fn with_id(user_id: impl Into<String>, session_id: SessionId) -> Self
Creates a session with a specific ID.
Sourcepub fn add_user_message(&mut self, content: impl Into<String>)
pub fn add_user_message(&mut self, content: impl Into<String>)
Adds a user message to the session.
Sourcepub fn add_agent_response(&mut self, response: AgentResponse)
pub fn add_agent_response(&mut self, response: AgentResponse)
Adds an agent response to the session.
Sourcepub fn extend_trajectory(&mut self, steps: Vec<TrajectoryStepRecord>)
pub fn extend_trajectory(&mut self, steps: Vec<TrajectoryStepRecord>)
Appends trajectory steps to the session (RFC-015).
Called by the orchestrator after each run so the Web UI can re-render the execution timeline when the user re-opens the session.
Sourcepub fn trajectory(&self) -> &[TrajectoryStepRecord]
pub fn trajectory(&self) -> &[TrajectoryStepRecord]
Returns the trajectory steps recorded in this session.
Sourcepub fn set_active_seed(&mut self, seed_id: Option<String>)
pub fn set_active_seed(&mut self, seed_id: Option<String>)
Sets the active seed ID.
Sourcepub fn set_active_persona(&mut self, persona_id: Option<String>)
pub fn set_active_persona(&mut self, persona_id: Option<String>)
Sets the active persona ID.
Sourcepub fn set_metadata(&mut self, key: impl Into<String>, value: Value)
pub fn set_metadata(&mut self, key: impl Into<String>, value: Value)
Sets a metadata value.
Sourcepub fn get_metadata(&self, key: &str) -> Option<&Value>
pub fn get_metadata(&self, key: &str) -> Option<&Value>
Gets a metadata value.
Sourcepub fn exchange_count(&self) -> usize
pub fn exchange_count(&self) -> usize
Returns the total number of exchanges in this session.