Skip to content

[opentelemetry-instrumentation-google-genai] Add tool definitions attribute on interactions API, other minor changes#271

Merged
lmolkova merged 11 commits into
open-telemetry:mainfrom
DylanRussell:interactions_api_changes
Jul 16, 2026
Merged

[opentelemetry-instrumentation-google-genai] Add tool definitions attribute on interactions API, other minor changes#271
lmolkova merged 11 commits into
open-telemetry:mainfrom
DylanRussell:interactions_api_changes

Conversation

@DylanRussell

Copy link
Copy Markdown
Contributor

Description

Added tool definitions attribute on the interactions API spans.

Function calling for interactions API is described at: https://ai.google.dev/gemini-api/docs/function-calling

Note that automatic function calling is not yet supported, so we can't get the execute tool spans like we do with generate_content instrumentation. The user is on the hook for calling their own functions..

I used GenericToolDefinition to capture built in tools and MCP server being provided as tools to the API..

I also updated the code to use the invoke remote agent span when an agent is specified instead of an inference span since a remote agent is being called.

I deleted obsolete TODOs and updated the README.

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

How has this been tested?

Unit tests

Checklist

See CONTRIBUTING.md
for the style guide, changelog guidance, and more.

  • Followed the style guidelines of this project
  • Changelog updated if the change requires an entry
  • Unit tests added
  • Documentation updated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Google GenAI SDK instrumentation to better reflect the Interactions API’s tool usage and agent invocation semantics, and aligns user-facing docs/tests accordingly.

Changes:

  • Add gen_ai.tool.definitions capture on interactions.create spans by mapping Interactions “tools” inputs into ToolDefinition models.
  • Emit invoke_agent spans (via TelemetryHandler.invoke_remote_agent) when an agent is provided, instead of using an inference span shape.
  • Remove obsolete TODO documentation and update the package README to describe current limitations/behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

File Description
instrumentation/opentelemetry-instrumentation-google-genai/TODOS.md Removes obsolete TODO list now that README describes current limitations.
instrumentation/opentelemetry-instrumentation-google-genai/tests/interactions/base.py Adds unit coverage for agent spans and tool definition serialization on interactions spans.
instrumentation/opentelemetry-instrumentation-google-genai/src/opentelemetry/instrumentation/google_genai/interactions.py Implements tool definition extraction for Interactions API and switches to invoke_agent when agent is specified.
instrumentation/opentelemetry-instrumentation-google-genai/README.rst Updates docs to reflect newly instrumented APIs and limitations around function calling for interactions.

Comment thread instrumentation/opentelemetry-instrumentation-google-genai/README.rst Outdated
@opentelemetry-pr-dashboard

Copy link
Copy Markdown

This PR has review comments. Review suggestions, whether from maintainers or automated reviewers, aren't always correct or required. Please evaluate each comment on its merits, then make sure each thread has a clear outcome.

For example, link to the commit if you applied a suggestion, explain why it wasn't applied, or ask a follow-up question.

Automation flags a PR for human review once every review thread has a reply or is marked as resolved.

Status across open PRs is visible on the pull request dashboard.

@lmolkova
lmolkova added this pull request to the merge queue Jul 16, 2026
Merged via the queue into open-telemetry:main with commit 9a629b0 Jul 16, 2026
67 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants