claude-agent-sdk: report tool_calls / inference_calls counts on invoke_agent

Open
#1,106 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
observability

Research direction

Read the LocalAgentInvocation implementation and its _on_stream_end and _on_stream_error handlers. Check how ToolUseBlock.id and message_id are exposed across SDK versions, then verify that both counts are recorded when content capture is disabled. Done means unique tool and inference calls populate the corresponding gen_ai.invoke_agent metrics, with inference_calls left unset for older SDK releases.

Written by the indexing model from the issue text.

Description

Follow-up to #1060, from lmolkova's review there:

LocalAgentInvocation has tool_calls and inference_calls, recorded as the gen_ai.invoke_agent.tool_calls / gen_ai.invoke_agent.inference_calls metrics. Both are available regardless of content capture: count unique ToolUseBlock.ids and unique message_ids, and set them in _on_stream_end / _on_stream_error.

I'll send the PR once #1060 lands.

message_id is not available on older SDK releases (e.g. 0.1.19); inference_calls stays unset there.

Dominant language
Python
Stars
52
Forks
110
Avg merge
2d 32m
Merged PRs (30d)
96

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from open-telemetry/opentelemetry-python-genai

All issues in open-telemetry/opentelemetry-python-genai

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.