[bot] Anthropic tool_runner agentic loop not instrumented
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 58/100
- issue の種類
- 機能追加
- 明瞭さ
- 明確に書かれている
- 活発さ
- 静か
- 技術スタック
- ruby
調査の方向性
lib/braintrust/contrib/anthropic/patcher.rb と instrumentation/beta_messages.rb から始め、その後、issue で指定されている Anthropic SDK の tool_runner メソッドを調べます。lib/braintrust/contrib/ruby_llm/instrumentation/chat.rb にあるネストされた tool span パターンと比較します。runner に全体の trace があり、各 BaseTool#call に子の tool span があり、列挙されたすべての実行モードがカバーされていれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- Ruby
- スター
- 9
- フォーク
- 10
- 平均マージ
- 3日 43分
- マージ済み PR(30日)
- 9
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
braintrustdata/braintrust-sdk-ruby のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
ruby
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
-
ruby
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
braintrustdata/braintrust-sdk-ruby の issue をすべて見る
似ている issue
-
content good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
rubyevents/rubyevents#2182 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
Homebrew/homebrew-cask#293134 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
notch8/iiif_print#430 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
メンテナーはふだん 1 日以内に返信