fix: add product context fallback for subchannels#248
Merged
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Contributor
There was a problem hiding this comment.
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
GetChannelBaggagePairsto derive the subchannel fromChannelId.SubChannel, with a fallback toChannelData.productContext. - Added middleware tests covering
productContextfallback andSubChannelprecedence.
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. |
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>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…thub.com/microsoft/Agent365-dotnet into users/gwharris7/product-context-fallback
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
sellakumaran
approved these changes
May 8, 2026
ajmfehr
approved these changes
May 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, when the subchannel was being sent via the
productContextproperty, it was not set correctly by the SDK. This fixes a bug where havingproductContext="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
ChannelIdproperty first, and if not present, falls back to extracting aproductContextvalue from theChannelDataJSON. Additionally, new tests are added to verify this fallback logic and precedence.Channel subchannel extraction improvements:
GetChannelBaggagePairsinTurnContextExtensions.csto extract the subchannel fromChannelId.SubChannel, and if missing, parse theproductContextfrom theChannelDataJSON. This ensures better support for channels that provide subchannel information in different locations.Testing enhancements:
BaggageTurnMiddlewareTests.csto verify that the middleware correctly extractsproductContextfromChannelDatawhenSubChannelis not present.SubChannelfromChannelIdtakes precedence overproductContextinChannelDataif both are present.System.Text.Jsonimport for test JSON parsing.