Skip to content

Fix tool definitions emission regardless of sensitivity setting - #7346

Merged
stephentoub merged 2 commits into
mainfrom
copilot/update-tool-definitions-emission
Feb 27, 2026
Merged

stephentoub merged 2 commits into
mainfrom
copilot/update-tool-definitions-emission

Conversation

Copilot AI commented Feb 27, 2026 •

Copy link
Copy Markdown
Contributor
  • Understand the code change needed
  • Move tool definitions block outside the EnableSensitiveData guard in OpenTelemetryChatClient.cs
  • Update tests in OpenTelemetryChatClientTests.cs to expect tool definitions emitted regardless of EnableSensitiveData
  • Run CodeQL checks

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Microsoft Reviewers: Open in CodeFlow

…tryChatClient

Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
@stephentoub
stephentoub marked this pull request as ready for review February 27, 2026 15:21
@stephentoub
stephentoub requested a review from a team as a code owner February 27, 2026 15:21
Copilot AI review requested due to automatic review settings February 27, 2026 15:21
@stephentoub stephentoub changed the title [WIP] Fix tool definitions emission regardless of sensitivity setting Fix tool definitions emission regardless of sensitivity setting Feb 27, 2026
@stephentoub
stephentoub requested a review from tarekgh February 27, 2026 15:21

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 fixes the emission of tool definitions in OpenTelemetry telemetry by moving them outside the EnableSensitiveData guard. Previously, tool definitions were only emitted when sensitive data tracking was enabled, but they should always be emitted as they represent non-sensitive metadata about available tools (schemas, parameter types, descriptions) rather than actual message content or results.

Changes:

  • Moved tool definitions telemetry emission outside EnableSensitiveData guard in OpenTelemetryChatClient.cs
  • Updated test expectations to verify tool definitions are emitted regardless of EnableSensitiveData setting

Reviewed changes

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

File Description
src/Libraries/Microsoft.Extensions.AI/ChatCompletion/OpenTelemetryChatClient.cs Moved tool definitions block (lines 635-649) outside the EnableSensitiveData conditional block, aligning it with other non-sensitive request parameters
test/Libraries/Microsoft.Extensions.AI.Tests/ChatCompletion/OpenTelemetryChatClientTests.cs Changed test assertion from Assert.False(tags.ContainsKey("gen_ai.tool.definitions")) to verify tool definitions are present with correct content even when EnableSensitiveData is false

@stephentoub
stephentoub merged commit e7223b0 into main Feb 27, 2026
10 checks passed
@stephentoub
stephentoub deleted the copilot/update-tool-definitions-emission branch February 27, 2026 17:02
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants