Skip to content

fix: add product context fallback for subchannels#248

Merged
gwharris7 merged 9 commits into
mainfrom
users/gwharris7/product-context-fallback
May 11, 2026
Merged

fix: add product context fallback for subchannels#248
gwharris7 merged 9 commits into
mainfrom
users/gwharris7/product-context-fallback

Conversation

@gwharris7
Copy link
Copy Markdown
Contributor

Previously, when the subchannel was being sent via the productContext property, it was not set correctly by the SDK. This fixes a bug where having productContext="COPILOT" was causing issues with the agent activity view.

This pull request enhances how the channel "subchannel" (used for observability and tracing) is extracted from incoming activities. The code now attempts to retrieve the subchannel from the ChannelId property first, and if not present, falls back to extracting a productContext value from the ChannelData JSON. Additionally, new tests are added to verify this fallback logic and precedence.

Channel subchannel extraction improvements:

  • Updated GetChannelBaggagePairs in TurnContextExtensions.cs to extract the subchannel from ChannelId.SubChannel, and if missing, parse the productContext from the ChannelData JSON. This ensures better support for channels that provide subchannel information in different locations.

Testing enhancements:

  • Added a test to BaggageTurnMiddlewareTests.cs to verify that the middleware correctly extracts productContext from ChannelData when SubChannel is not present.
  • Added a test to ensure that SubChannel from ChannelId takes precedence over productContext in ChannelData if both are present.
  • Included necessary System.Text.Json import for test JSON parsing.

Copilot AI review requested due to automatic review settings May 7, 2026 21:36
@gwharris7 gwharris7 requested a review from a team as a code owner May 7, 2026 21:36
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 7, 2026

⚠️ Deprecation Warning: The deny-licenses option is deprecated for possible removal in the next major release. For more information, see issue 997.

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Comment thread src/Observability/Hosting/Extensions/TurnContextExtensions.cs Fixed
Comment thread src/Observability/Hosting/Extensions/TurnContextExtensions.cs Fixed
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 subchannel extraction for observability/tracing by preferring ChannelId.SubChannel and falling back to productContext from ChannelData JSON when SubChannel is missing, plus adds tests validating the fallback and precedence behavior.

Changes:

  • Updated GetChannelBaggagePairs to derive the subchannel from ChannelId.SubChannel, with a fallback to ChannelData.productContext.
  • Added middleware tests covering productContext fallback and SubChannel precedence.

Reviewed changes

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

File Description
src/Observability/Hosting/Extensions/TurnContextExtensions.cs Adds subchannel extraction fallback logic from ChannelData.productContext when SubChannel is empty.
src/Tests/Microsoft.Agents.A365.Observability.Hosting.Tests/Middleware/BaggageTurnMiddlewareTests.cs Adds tests to validate fallback and precedence behavior for subchannel extraction.

Comment thread src/Observability/Hosting/Extensions/TurnContextExtensions.cs
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 7, 2026 22:37
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

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

Comment thread src/Observability/Hosting/Extensions/TurnContextExtensions.cs Outdated
Grant Harris and others added 2 commits May 7, 2026 16:05
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 7, 2026 23:07
Comment thread src/Observability/Hosting/Extensions/TurnContextExtensions.cs Dismissed
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

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

Comment thread src/Observability/Hosting/Extensions/TurnContextExtensions.cs
Grant Harris and others added 3 commits May 7, 2026 16:17
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 7, 2026 23:19
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

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

Comment thread src/Observability/Hosting/Extensions/TurnContextExtensions.cs
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 8, 2026 00:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

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

Comment thread src/Observability/Hosting/Extensions/TurnContextExtensions.cs
Comment thread src/Observability/Hosting/Extensions/TurnContextExtensions.cs
@gwharris7 gwharris7 enabled auto-merge (squash) May 11, 2026 15:55
@gwharris7 gwharris7 merged commit a5a3a6f into main May 11, 2026
7 checks passed
@gwharris7 gwharris7 deleted the users/gwharris7/product-context-fallback branch May 11, 2026 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants