v2: Tool.execute and MCP.callTool spans no longer carry tool.name / tool.call_id

未关闭 适合新手
#62,305 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
76/100
Issue 类型
功能
描述清晰度
描述清楚
活跃度
活跃
技术栈
typescript
领域
observability

调研方向

从 packages/core/src/tool.ts 和 packages/core/src/mcp/index.ts 开始,issue 指出 span 在这里创建;然后检查 #22531 和 #25452 中 v1 属性的记录方式。要添加的值已经在作用域内,hook tool.execute.after 也会收到这些值。完成标准是:tool 和 MCP span 在 OTLP trace 中公开所请求的 tool、调用、会话、操作和服务器属性。

由索引模型根据 Issue 内容生成。

描述

pending close
Description

In v2, the Tool.execute and MCP.callTool spans no longer say which tool ran. In v1 they had tool.name and tool.call_id (#22531, and #25452 for MCP and plugin tools). Since the v2 rewrite, Tool.execute in packages/core/src/tool.ts is a bare Effect.fn("Tool.execute"), and MCP.callTool in packages/core/src/mcp/index.ts has no attributes either.

In a trace backend, every tool call now looks the same: status and duration only. The only way to tell which tool a span ran is the error message, and only when the call fails (MCP tool "github-get_file_contents" on server "litellm" failed: …).

Expected: the attributes from v1, ideally also with the OTel GenAI names, so GenAI-aware backends can show the calls:

  • tool.name / gen_ai.tool.name
  • tool.call_id / gen_ai.tool.call.id
  • gen_ai.operation.name = execute_tool
  • session.id
  • for MCP: the server name, e.g. mcp.server.name

The values are already in scope there (name, context.id, context.sessionID, input.server). The tool.execute.after hook receives them too.

Related: #46856 (trace context on MCP calls). Together these two would let MCP calls show up properly inside the agent trace.

Plugins

none

OpenCode version

2.1.2 (checked the code on v2.2.5)

Steps to reproduce
  1. Set OTEL_EXPORTER_OTLP_ENDPOINT and run opencode run with a prompt that uses a few tools (built-in and MCP).
  2. Open the trace in any OTLP backend.
  3. Tool.execute / MCP.callTool spans have no tool.name or call id. On v1 they did.
Operating System

Linux (container)

Terminal

n/a (opencode run)

主要语言
TypeScript
星标
224k
派生
30k
平均合并
5 小时 25 分钟
30 天内合并 PR
494

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

anomalyco/opencode 的其他 Issue

查看 anomalyco/opencode 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。