use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::collections::HashMap;
pub struct Handoff {
pub target_agent: String,
pub task: String,
pub context: Option<HandoffContext>,
}
pub struct HandoffContext {
pub original_request: String,
pub current_result: Option<String>,
pub metadata: HashMap<String, Value>,
}
pub struct HandoffResult {
pub agent_name: String,
pub result: String,
pub next_handoff: Option<Box<Handoff>>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct HandoffRecord {
pub from_agent: String,
pub to_agent: String,
pub task: String,
pub result: String,
pub timestamp: String,
}
#[derive(Debug)]
pub enum HandoffError {
AgentNotFound(String),
ExecutionError(String),
}
impl std::fmt::Display for HandoffError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
HandoffError::AgentNotFound(name) => {
write!(f, "Agent 不存在: {}", name)
}
HandoffError::ExecutionError(msg) => write!(f, "Agent 执行错误: {}", msg),
}
}
}
impl std::error::Error for HandoffError {}