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

オープン 初心者向け
#62,305 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
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 が、要求された tool、call、session、operation、server の属性を OTLP トレースで公開することです。

索引モデルが 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分
マージ済み PR(30日)
494

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

anomalyco/opencode のほかの issue

anomalyco/opencode の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。