agentscope-ai / agentscope-ai/QwenPaw
[Bug]: 启用langfuse监控,工具输出空白
- Vorherrschende Sprache
- TypeScript
- Sterne
- 35k
- Forks
- 3.1k
- Ø Merge
- 1 T. 13 Std.
- Gemergte PRs (30 T.)
- 228
Beschreibung
## QwenPaw 版本
QwenPaw 2.1.0
## 问题描述
启用 Langfuse 监控后,Agent 调用工具时,工具本身能够正常执行,执行结果也能够正常返回给 Agent,但 Langfuse 中对应工具 Observation/Span 的 `output` 字段为空字符串或 `null`。
这会导致 Langfuse trace 中只能查看工具名称和输入参数,无法查看实际工具输出,影响工具调用链路的观测和问题排查。
**预期行为:**
Langfuse trace 中应完整记录工具的输入参数和输出结果。工具执行成功后,对应 Tool Observation/Span 的 `output` 字段应包含实际的 `ToolResponse` 内容。
**实际行为:**
Agent 能够正常获取工具执行结果并完成回复,但 Langfuse 中对应工具调用的 `output` 字段为空字符串或 `null`。
初步判断,该问题与工具事件通过异步生成器传递有关。当前逻辑在完整消费工具事件流后才更新 Langfuse Observation;如果上游在收到最终 `ToolResponse` 后停止消费或关闭异步生成器,事件循环之后的 Observation 更新逻辑可能不会执行,从而出现工具执行成功但 Langfuse Output 为空的问题。
**相关 PR:** #7532
**安全考虑:**
不涉及认证、权限绕过或敏感信息泄露,仅为可观测性数据缺失问题。提交日志或截图时,需要隐藏 `LANGFUSE_SECRET_KEY`、`LANGFUSE_PUBLIC_KEY`、模型 API Key 以及工具输出中可能包含的业务敏感数据。
## 受影响组件
- [x] Core / Backend (app, agents, config, providers, utils, local_models)
- [ ] Console(前端 Web UI)
- [ ] Channels(DingTalk、Feishu、QQ、Discord、iMessage 等)
- [ ] Skills
- [ ] CLI
- [ ] Documentation(文档网站)
- [ ] Tests
- [ ] CI/CD
- [ ] Scripts / Deploy
## 运行环境
- **QwenPaw 版本:** 2.1.0
- **操作系统:** Windows 11
- **安装方式:** 源码构建
- **Python 版本:** 3.11
- **Langfuse SDK 版本:** 4.10.0
## 复现步骤
1. 安装 Langfuse SDK,并为 QwenPaw 配置有效的 `LANGFUSE_SECRET_KEY`、`LANGFUSE_PUBLIC_KEY` 和 `LANGFUSE_BASE_URL`。
2. 启动 QwenPaw,确认 Langfuse trace 已成功启用。
3. 向 Agent 发送一条需要触发工具调用的消息,例如查询天气、搜索信息或读取文件。
4. 等待 Agent 完成工具调用,并确认 Agent 能够正常获得工具返回结果。
5. 打开 Langfuse Dashboard,找到本次会话对应的 trace。
6. 查看其中的工具调用 Observation/Span。
7. 检查该工具调用的 `output` 字段。
## 实际表现 vs 预期表现
- **实际表现:** 工具执行成功,Agent 能够获得工具返回结果并正常生成最终回复,但 Langfuse 中对应工具调用 Observation/Span 的 `output` 字段为空字符串或 `null`。
- **预期表现:** Langfuse 中对应工具调用 Observation/Span 的 `output` 字段应完整记录工具的实际返回内容,并与 Agent 收到的工具执行结果一致。
## 日志 / 截图
Beitragsleitfaden
Rechercherichtung
No file or test is named. Start by tracing the Langfuse monitoring path for tool events and the asynchronous generator handling described in the report, then compare the final ToolResponse with the Observation/Span update timing. Done means successful tool calls record their actual output in Langfuse while the Agent still receives the result.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- backend, observability
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Aktiv
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100