Skip to main content

aagt_core/agent/
session.rs

1use crate::agent::message::Message;
2use serde::{Deserialize, Serialize};
3
4/// Status of an agent session
5#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
6#[serde(rename_all = "snake_case")]
7pub enum SessionStatus {
8    /// Agent is thinking or waiting for provider
9    Thinking,
10    /// Agent has generated tool calls and is waiting for execution/approval
11    PendingTools,
12    /// Agent is waiting for manual user approval for a specific tool
13    AwaitingApproval {
14        tool_name: String,
15        arguments: String,
16    },
17    /// Agent is executing tools
18    Executing,
19    /// Agent has completed the task
20    Completed,
21    /// Agent has failed
22    Failed(String),
23}
24
25/// A persistent session representing an agent's current state and history
26#[derive(Debug, Clone, Serialize, Deserialize)]
27pub struct AgentSession {
28    /// Unique identifier for the session
29    pub id: String,
30    /// Dialogue history
31    pub messages: Vec<Message>,
32    /// Current step in the reasoning loop
33    pub step: usize,
34    /// Current status of the agent
35    pub status: SessionStatus,
36    /// Timestamp of the last update
37    pub updated_at: chrono::DateTime<chrono::Utc>,
38}
39
40impl AgentSession {
41    /// Create a new session
42    pub fn new(id: String) -> Self {
43        Self {
44            id,
45            messages: Vec::new(),
46            step: 0,
47            status: SessionStatus::Thinking,
48            updated_at: chrono::Utc::now(),
49        }
50    }
51}