tiny-agent 0.3.0

一个小而完整的 Rust LLM Agent 运行时:可中断、可恢复、可观测、可插拔的 agent loop / A small but complete LLM agent runtime in Rust — an interruptible, resumable, observable, pluggable agent loop.
Documentation
use serde::{Deserialize, Serialize};
use uuid::Uuid;

/// agent 在一次运行中的可持久化状态。
///
/// 注意:**工具批次进度**不在这里——它属于状态机变体
/// `Agent::ToolExecuting(_, ToolRunState)` 的载荷;**等待用户输入**则由
/// `Agent::WaitingForUser(_, UserInteraction)` 显式承载。此处只放跨状态延续的
/// 标量计数与最终回复,避免出现第二份易发散的工具状态。
#[derive(Deserialize, Serialize, Debug, Clone)]
pub struct AgentState {
    pub session_id: String,
    pub steps_count: u32,
    pub consecutive_fail_count: u32,
    pub final_resp: Option<String>,
}

impl AgentState {
    pub fn new(session_id: Option<String>) -> Self {
        Self {
            session_id: session_id.unwrap_or_else(|| Uuid::new_v4().to_string()),
            steps_count: 0,
            consecutive_fail_count: 0,
            final_resp: None,
        }
    }
}