Skip to content

feat(anthropic): instrument beta tool runner with parent chain and child tool spans - #3531

Open
Aryan-Pardeshi wants to merge 1 commit into
Arize-ai:mainfrom
Aryan-Pardeshi:feat/anthropic-tool-runner-instrumentation
Open

feat(anthropic): instrument beta tool runner with parent chain and child tool spans#3531
Aryan-Pardeshi wants to merge 1 commit into
Arize-ai:mainfrom
Aryan-Pardeshi:feat/anthropic-tool-runner-instrumentation

Conversation

@Aryan-Pardeshi

Copy link
Copy Markdown

Closes #3392

The instrumentor wraps completions.create, messages.create, messages.stream, messages.parse and the beta.messages equivalents, but not the beta tool runner. A run that lets the SDK resolve tool calls automatically therefore produces a set of disconnected single-LLM-span traces, with no span for any tool actually invoked and nothing tying the turns together.

This wraps beta.messages.tool_runner (sync and async) so a run emits a parent span for the runner with child TOOL spans for each tool invocation, using the existing OpenInference tool attribute conventions. Both wrappers follow the structure already in _wrappers.py and are unwound in _uninstrument, so instrumenting and uninstrumenting stays symmetric.

Also adds examples/tool_runner.py, mirroring the existing end_to_end_tool_use.py, and a CHANGELOG entry.

Written and verified against anthropic 0.84.0. Worth flagging that this is a beta SDK surface: the entry point was confirmed by inspecting anthropic.resources.beta.messages.Messages on that version rather than taken from the docs, but it can move.

Full package suite passes: 53 passed. ruff check and ruff format --check are clean across the package.

…ild tool spans

Wraps Messages.tool_runner / AsyncMessages.tool_runner (anthropic>=0.84.0
beta surface) so a tool-runner run produces one CHAIN parent span named
beta.messages.tool_runner with TOOL child spans for each tool invocation,
instead of a set of disconnected single-LLM spans. Adds sync/async tests
with mocked HTTP responses and a tool_runner example.

Closes Arize-ai#3392
@Aryan-Pardeshi
Aryan-Pardeshi requested a review from a team as a code owner August 9, 2026 07:48
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Aug 9, 2026
@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@Aryan-Pardeshi

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Aug 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Add support for Anthropic tool helpers

1 participant