pub struct Session {Show 21 fields
pub session_id: SessionId,
pub agent_id: AgentId,
pub state: AgentState,
pub iteration: i32,
pub max_iterations: i32,
pub messages: Vec<Message>,
pub tools_registered: Vec<String>,
pub tool_calls_pending: Vec<ToolCall>,
pub tool_results_cache: Vec<ToolResult>,
pub model: String,
pub temperature: f32,
pub system_prompt: String,
pub tokens_total: i64,
pub tokens_prompt: i64,
pub tokens_completion: i64,
pub cost_estimate: f64,
pub created_at: DateTime<Utc>,
pub last_updated: DateTime<Utc>,
pub checkpoint_count: i32,
pub max_messages: usize,
pub max_tools: usize,
}Expand description
会话状态
Fields§
§session_id: SessionId会话 ID
agent_id: AgentIdAgent ID
state: AgentState当前状态
iteration: i32当前迭代次数
max_iterations: i32最大迭代次数
messages: Vec<Message>消息历史
tools_registered: Vec<String>已注册工具
tool_calls_pending: Vec<ToolCall>待处理的工具调用
tool_results_cache: Vec<ToolResult>工具结果缓存
model: String模型名称
temperature: f32温度参数
system_prompt: String系统提示词
tokens_total: i64Token 使用统计
tokens_prompt: i64§tokens_completion: i64§cost_estimate: f64成本估算
created_at: DateTime<Utc>创建时间
last_updated: DateTime<Utc>最后更新时间
checkpoint_count: i32检查点计数
max_messages: usize最大消息数量
max_tools: usize最大工具数量
Implementations§
Source§impl Session
impl Session
Sourcepub fn new(config: &SessionConfig) -> Self
pub fn new(config: &SessionConfig) -> Self
创建新会话
Sourcepub fn add_user_message(&mut self, content: &str)
pub fn add_user_message(&mut self, content: &str)
添加用户消息
Sourcepub fn add_assistant_message(&mut self, content: &str)
pub fn add_assistant_message(&mut self, content: &str)
添加助手消息
Sourcepub fn add_system_message(&mut self, content: &str)
pub fn add_system_message(&mut self, content: &str)
添加系统消息
Sourcepub fn register_tool(&mut self, tool_name: &str)
pub fn register_tool(&mut self, tool_name: &str)
注册工具,如果超过上限则移除最旧的
Sourcepub fn can_continue(&self) -> bool
pub fn can_continue(&self) -> bool
检查是否可以继续执行
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Session
impl<'de> Deserialize<'de> for Session
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>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Session
impl RefUnwindSafe for Session
impl Send for Session
impl Sync for Session
impl Unpin for Session
impl UnsafeUnpin for Session
impl UnwindSafe for Session
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
Mutably borrows from an owned value. Read more