Skip to content

openai: pass tool definitions to genai utils#4554

Open
Jwrede wants to merge 1 commit intoopen-telemetry:mainfrom
Jwrede:openai-tool-definitions
Open

openai: pass tool definitions to genai utils#4554
Jwrede wants to merge 1 commit intoopen-telemetry:mainfrom
Jwrede:openai-tool-definitions

Conversation

@Jwrede
Copy link
Copy Markdown

@Jwrede Jwrede commented May 7, 2026

Description

Pass tool definitions from the OpenAI tools kwarg through to InferenceInvocation.tool_definitions so they are serialized into gen_ai.tool.definitions span/event attributes and forwarded to the completion hook.

The utils layer already supports tool definitions (PR #4181), but the OpenAI v2 instrumentation was not extracting them from request kwargs.

Fixes #4511

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • Added assertions for gen_ai.tool.definitions in existing sync and async tool call tests (both non-streaming and streaming variants)
  • Verified second span (no tools passed) does not contain the attribute

Does This PR Require a Core Repo Change?

  • No.

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

Extract tool definitions from the `tools` kwarg in chat completion
requests and set them on InferenceInvocation.tool_definitions so they
are serialized into gen_ai.tool.definitions span attributes and
forwarded to the completion hook.

Fixes open-telemetry#4511

Assisted-by: Claude Opus 4.6
@Jwrede Jwrede requested a review from a team as a code owner May 7, 2026 21:07
@github-actions github-actions Bot requested a review from lmolkova May 7, 2026 21:07
@github-actions github-actions Bot added the gen-ai Related to generative AI label May 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gen-ai Related to generative AI

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

openai: pass tool definitions to genai utils

2 participants