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

Aperta Adatta ai principianti
#62,305 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
76/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
observability

Direzione di ricerca

Inizia da packages/core/src/tool.ts e packages/core/src/mcp/index.ts, dove, secondo l’issue, vengono creati gli span, e verifica come sono stati registrati gli attributi v1 in #22531 e #25452. I valori da aggiungere sono già nello scope e anche l’hook tool.execute.after li riceve. Il lavoro è completato quando gli span tool e MCP espongono gli attributi richiesti relativi a tool, chiamata, sessione, operazione e server nelle tracce OTLP.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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)

Lingua principale
TypeScript
Stelle
224k
Fork
30k
Merge medio
5h 25m
PR unite (30g)
494

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di anomalyco/opencode

Tutte le issue di anomalyco/opencode

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.