Skip to content

[Eval] Integrate Langfuse tracing and evaluation for Agent / Deep Research runs #14

Closed

Description

@helsome

Background

当前项目需要把 Agent / Deep Research 的运行过程和评测结果统一纳入 Langfuse,不能只记录最终文本,也不能只完成 SDK 初始化。目标是让一次真实研究任务从输入、检索、工具调用、模型生成、最终报告到评测结果都能在 Langfuse 中被追踪和复现。

Requirements

  • 接入 Langfuse,至少覆盖一次 Agent / Deep Research run 的完整 trace。
  • Trace 中需要有稳定的 run/session 标识,并可关联:
    • user query / task input
    • model / provider / prompt version(如可获取)
    • retrieval / search / tool calls
      -关键中间步骤或 agent spans
    • final answer / research report
    • token / latency / cost 等可获取指标
    • errors / retries
  • 设计统一的 metadata / tag 约定,至少能够区分:
    • normal run
    • evaluation run
    • gold case id / dataset version
    • model / agent version
  • 评测结果能够写回 Langfuse score / evaluation 体系,不应仅存在本地日志。
  • 评测 score 至少预留并实现可落地的维度:
    • task / answer correctness(或业务目标达成)
    • groundedness / evidence support
    • citation / claim coverage(与 claim-evidence issue 对接)
    • tool/retrieval success
    • latency / token / cost 等工程指标
  • Langfuse 不可用、网络异常或 telemetry 写入失败时,不应导致核心 Agent 任务整体失败;需要有明确降级策略。
  • API key / secret 必须通过环境变量或现有 secret/config 机制读取,禁止提交到仓库。

Acceptance Criteria

  • 本地/测试环境可以通过配置开启或关闭 Langfuse tracing。
  • 一次真实 Deep Research 运行可以在 Langfuse 中看到完整 trace,而不是只有单个 LLM span。
  • Trace 能关联输入、检索/工具、最终报告及 run metadata。
  • 至少 2 个评测 score 能真实写回对应 trace/run,其中至少包含 groundedness 或等价的 evidence support 指标。
  • evaluation run 能关联到具体 gold case id / dataset version。
  • Langfuse 服务不可达时,Agent 主流程仍可完成,并有可诊断日志。
  • 有 unit / integration test 覆盖 tracing wrapper / score writeback / failure fallback。
  • 必须完成至少 1 次真实模型 + 实际检索/工具链路的运行,并在 PR 中提供 Langfuse trace 链接或截图。只完成 mock、SDK 初始化、hello-world trace 不算完成。

Deliverables

PR 描述中请附:

  1. 配置方式与所需环境变量;
  2. trace/span 结构说明;
  3. score schema;
  4. 一次真实运行的 trace 证据;
  5. telemetry 失败情况下的降级测试结果。

Notes

这项工作重点是 observability + evaluation infrastructure,不是单纯“接入 Langfuse SDK”。尽量将 tracing 封装在统一边界,避免业务代码到处散落 Langfuse-specific 调用。

Activity

  1. TINGyu123644 commented on Sep 11, 2026

    @TINGyu123644

    认领这个 issue 👋

    我来负责这个任务:集成 Langfuse tracing 和 evaluation for Agent / Deep Research runs。

    我会按照 acceptance criteria 逐步推进:

    1. 先梳理现有 trace 事件结构(FolioTrace、AgentEvent、ToolCallRecord)
    2. 设计 FolioTrace → Langfuse span/trace 的映射方案
    3. 接入 Langfuse SDK,把工具调用、LLM 调用、token 预算都上报
    4. 评测结果(groundedness、decision-usefulness 等)回传到 Langfuse score
    5. 加配置项:endpoint、public key、开关、采样率
    6. 确保脱敏([Privacy] Centralize redaction and data minimization for logs, diagnostics, traces, and eval artifacts #19)在上报前生效

    如果有任何优先级调整或额外要求,请随时告诉我。

  2. zncrcr commented on Sep 11, 2026

    @zncrcr
    Contributor

    /claim

  3. added
    claimed
    on Sep 11, 2026
  4. github-actions commented on Sep 11, 2026

    @github-actions

    @zncrcr 已认领该 Issue,并已自动设为 Assignee。提交 PR 时请在描述中写 Closes #14。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

claimed

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions