tiny-agent 0.2.0

一个小而完整的 Rust LLM Agent 运行时:可中断、可恢复、可观测、可插拔的 agent loop / A small but complete LLM agent runtime in Rust — an interruptible, resumable, observable, pluggable agent loop.
Documentation
use crate::sandbox::Sandbox;
use crate::tools::{ToolCtx, ToolOutcome};
use schemars::JsonSchema;
use serde::Deserialize;
use serde_json::json;
use std::sync::Arc;

#[derive(Deserialize, JsonSchema)]
pub struct KillArgs {
    /// 要终止的后台任务 id(形如 `task_7`)
    pub id: String,
}

pub async fn kill(
    _sandbox: Arc<dyn Sandbox>,
    args: KillArgs,
    ctx: ToolCtx,
) -> Result<ToolOutcome, String> {
    if ctx.tasks.kill(&args.id) {
        Ok(json!({ "status": "killed", "id": args.id }).into())
    } else {
        Err(format!("未找到后台任务: {}", args.id))
    }
}