[opentelemetry-instrumentation-google-genai] Add tool definitions attribute on interactions API, other minor changes#271
Conversation
There was a problem hiding this comment.
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.definitionscapture oninteractions.createspans by mapping Interactions “tools” inputs intoToolDefinitionmodels. - Emit
invoke_agentspans (viaTelemetryHandler.invoke_remote_agent) when anagentis 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. |
|
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. |
…entelemetry-python-genai into interactions_api_changes
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_contentinstrumentation. The user is on the hook for calling their own functions..I used
GenericToolDefinitionto 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
agentis specified instead of aninferencespan 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.
How has this been tested?
Unit tests
Checklist
See CONTRIBUTING.md
for the style guide, changelog guidance, and more.