Skip to content

[sight] feat(sight): add trajectory grader for agent quality evaluation #1304

Description

@haoowa

Feature: 为 AgentSight 增加轨迹 grader,用于 Agent 运行质量评估

背景

AgentSight 已经能够采集 Agent 运行过程中的丰富证据,包括 LLM 调用、工具调用、Token 用量、中断记录、安全 verdict、session、trace、conversation,以及 ATIF 轨迹导出。

不过,当前能力主要回答的是“Agent 运行过程中发生了什么”。对于用户来说,还缺少一个一等公民能力来回答:“这次 Agent 运行得好不好?任务是否完成?如果失败,失败在哪里?”

这个 issue 建议为 AgentSight 增加一个 first-class grader 层,对已采集的 Agent 轨迹进行结构化评估,并输出任务质量 verdict。

动机

原始 trace 对调试很有价值,但用户仍然需要人工阅读大量日志,才能判断:

  • Agent 是否完成了用户任务?
  • 失败原因是规划错误、工具调用错误、环境问题、中断,还是幻觉?
  • 工具调用是否必要,是否被观测到的证据支持?
  • 是否存在重复调用、循环、Token 浪费或成本异常?
  • 修改 prompt、模型、工具或运行策略后,Agent 行为质量是否变好?

grader 可以把 AgentSight 从“轨迹观测系统”进一步扩展为“Agent 质量分析系统”。

设计建议

新增一个 post-run evaluation pipeline,支持按 trace_idconversation_idsession_id 对 Agent 运行结果进行评估。

MVP 建议先做确定性的 rule-based grader,不依赖外部 LLM:

  • 检测未完成或被中断的 LLM 调用。
  • 检测 LLM error、SSE truncation、timeout 或异常状态。
  • 检测重复调用、循环、Token/成本异常和工具调用失败。
  • 将现有 security verdict 和 interruption record 纳入评估证据。
  • 输出结构化结果,包括 verdict、score、dimension、reason 和 evidence reference。

后续可以在此基础上扩展 rubric-based LLM-as-a-Judge,以及更强的 Agent-as-a-Judge。ATIF 轨迹可以作为语义化、标准化的 grader 输入格式。

建议输出结构

{
  "target_type": "conversation",
  "target_id": "conv_xxx",
  "grader_type": "rule",
  "verdict": "pass | warn | fail",
  "score": 0.82,
  "summary": "The agent completed the main task but had repeated tool calls.",
  "dimensions": [
    {
      "name": "completion",
      "score": 1.0,
      "verdict": "pass",
      "reason": "The trace completed without interruption.",
      "evidence_refs": ["genai_event:123"]
    }
  ]
}

实现范围

  • src/agentsight/src/grader/ 下新增独立 grader 模块。
  • 复用 GenAISqliteStore 读取 trace、session 和 conversation 事件。
  • 尽量复用 ATIF 转换逻辑,作为标准化轨迹输入。
  • 新增 SQLite 表,持久化 evaluation run 和 evaluation result。
  • 新增 API,用于触发评估和查询评估结果。
  • 在 trace、conversation、session 页面增加 Evaluation 面板。

MVP 非目标

  • 不改变 Agent 运行时行为。
  • 不在第一版中做阻断、重试或自愈。
  • 第一版不要求外部 LLM 访问权限。
  • 不替代已有 security verdict 或 interruption detection。

验收标准

  • 用户可以在 trace、conversation 或 session 结束后触发评估。
  • 评估结果可以持久化,并通过 API 查询。
  • 结果包含 verdict、score、dimensions、reasons 和 evidence references。
  • Dashboard 能展示最近一次评估结果,并跳转到支撑结论的 trace 证据。
  • Rule-based grader 在无网络、无外部模型凭证的环境下也能工作。

Metadata

Metadata

Labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions