""" Agent 事件定义 """ from dataclasses import dataclass from typing import Dict, Any, Literal AgentEventType = Literal[ # Trace 生命周期 "trace_started", # Trace 开始 "trace_completed", # Trace 完成 "trace_failed", # Trace 失败 # 记忆 "memory_loaded", # 记忆加载完成(skills, experiences) "experience_extracted", # 提取了经验 # 步骤 "step_started", # 步骤开始 "llm_delta", # LLM 输出增量 "llm_call_completed", # LLM 调用完成 "tool_executing", # 工具执行中 "tool_result", # 工具结果 "conclusion", # 结论(中间或最终) # 反馈 "feedback_received", # 收到人工反馈 # 等待用户 "awaiting_user_action", # 等待用户确认(工具调用) ] @dataclass class AgentEvent: """Agent 事件""" type: AgentEventType data: Dict[str, Any] def to_dict(self) -> Dict[str, Any]: return {"type": self.type, "data": self.data} def __repr__(self) -> str: return f"AgentEvent(type={self.type!r}, data={self.data!r})"