[bot] Anthropic tool_runner agentic loop not instrumented
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 58/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bien especificado
- Estado de actividad
- Tranquilo
- Stack tecnológico
- ruby
- Área
- observability
Línea de trabajo
Empieza por lib/braintrust/contrib/anthropic/patcher.rb e instrumentation/beta_messages.rb y, después, inspecciona los métodos tool_runner del Anthropic SDK mencionados en el issue. Compara el patrón de tool span anidado en lib/braintrust/contrib/ruby_llm/instrumentation/chat.rb. Se considera terminado cuando el runner tiene un trace general, cada BaseTool#call tiene un tool span hijo y todos los modos de ejecución enumerados están cubiertos.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Summary
The Anthropic Ruby SDK provides client.beta.messages.tool_runner(...), a beta agentic loop API that automatically executes tools and manages the multi-turn conversation cycle. This surface is not instrumented. The SDK currently instruments beta.messages.create() and beta.messages.stream() (via BetaMessagesPatcher), so individual LLM calls within the runner may produce spans, but the tool executions and overall agentic run are invisible in traces.
What is missing
The tool_runner API (Anthropic::Resources::Beta::Messages#tool_runner) returns a runner object with these execution methods:
each_message { |msg| ... }— iterates through the agentic loop, auto-executing tools viaBaseTool#callbetween iterationsrun_until_finished— runs the full loop and returns all messagesnext_message— step-by-step manual iterationeach_streaming { |event| ... }— streaming variant of the agentic loop
At each iteration, the runner:
- Sends a message to Claude (this call IS traced via existing
BetaMessagesPatcher) - Detects tool_use blocks in Claude's response
- Executes
BaseTool#callon the matching tool (NOT traced) - Sends tool results back and loops
What instrumentation should capture
Parent span for the agentic run (e.g., anthropic.tool_runner):
- Input: initial messages and tool definitions
- Output: final response after all tool loops complete
- Metrics: aggregate token usage across all iterations, total duration
Child spans for each tool execution (e.g., anthropic.tool.{tool_name}):
- Input: tool name + arguments (from Claude's tool_use block)
- Output: tool result (from
BaseTool#callreturn value) - Span attributes:
{type: "tool"}
This pattern is already established in this repo — the RubyLLM integration creates ruby_llm.tool.{tool_name} child spans with braintrust.span_attributes: {type: "tool"} for each tool execution in lib/braintrust/contrib/ruby_llm/instrumentation/chat.rb.
Braintrust docs status
- Braintrust documents "tool" as a first-class span type: "A tool call made by the model — an external API, code execution, database query, etc." (tracing guide)
- Ruby-specific tool_runner instrumentation: not_found
Upstream sources
- Anthropic tool_runner documentation: https://platform.claude.com/docs/en/agents-and-tools/tool-use/tool-runner
- Anthropic Ruby SDK helpers: https://github.com/anthropics/anthropic-sdk-ruby/blob/main/helpers.md#3-auto-looping-tool-runner-beta
- Anthropic Ruby SDK on RubyGems: https://rubygems.org/gems/anthropic
Local repo files inspected
lib/braintrust/contrib/anthropic/patcher.rb— definesMessagesPatcherandBetaMessagesPatcher; no tool_runner patcherlib/braintrust/contrib/anthropic/instrumentation/beta_messages.rb— wrapscreate()andstream()only; notool_runnerwrapper- Grep for
tool_runner,BaseTool,each_message,run_until_finishedacrosslib/— zero matches lib/braintrust/contrib/ruby_llm/instrumentation/chat.rb— demonstrates the existing pattern for tool execution tracing with nested spans
- Lenguaje dominante
- Ruby
- Estrellas
- 9
- Forks
- 10
- Merge medio
- 3 d 43 min
- PR fusionados (30 d)
- 9
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de braintrustdata/braintrust-sdk-ruby
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
[BOT ISSUE] OpenAI Chat Completions missing reasoning model and web search metadata parametersAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
-
ruby
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
-
ruby
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
Todos los issues de braintrustdata/braintrust-sdk-ruby
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Homebrew/homebrew-cask#293134 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
notch8/iiif_print#430 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
Los mantenedores suelen responder en 1 día
-
ActionText::Content#to_markdown: <br> in a table cell and empty <tr> produce malformed Markdown tablesPosiblemente ocupada @azmi2409 la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
Los mantenedores suelen responder en 2 días