fix: add product context fallback for subchanne;#252
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 channel sub-channel extraction in the hosting observability layer by falling back to channel_data.productContext when sub_channel isn’t explicitly provided on the activity, addressing scenarios like productContext="COPILOT" impacting downstream activity views.
Changes:
- Update
get_channel_pairs()to derivesub_channelfromactivity.channel_data["productContext"](including JSON-stringchannel_data) whensub_channelis unset. - Add middleware tests verifying
productContextfallback behavior and that explicitsub_channeltakes precedence.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| tests/observability/hosting/middleware/test_baggage_middleware.py | Adds tests asserting BaggageMiddleware sets channel link baggage from productContext and honors sub_channel precedence. |
| libraries/microsoft-agents-a365-observability-hosting/microsoft_agents_a365/observability/hosting/scope_helpers/utils.py | Extends get_channel_pairs() to fallback sub_channel from channel_data.productContext (dict/JSON string/object __dict__). |
added 2 commits
May 7, 2026 16:06
- Replace 'any' type annotation with 'object' for channel_data parameter - Move CHANNEL_LINK_KEY import to module level to avoid redefinition - Remove duplicate inline imports of json and CHANNEL_LINK_KEY - Use double quotes for string literals per ruff-format - Remove trailing whitespace from blank lines - Rename test to clarify it only affects channel link, not all baggage
sellakumaran
reviewed
May 8, 2026
ajmfehr
approved these changes
May 8, 2026
sellakumaran
approved these changes
May 11, 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 the extraction and handling of channel and sub-channel information from activity data, particularly improving how the
sub_channelis determined when not explicitly set. It also adds comprehensive test coverage to ensure correct behavior, especially around precedence betweensub_channelandproductContext.Enhancements to channel and sub-channel extraction:
get_channel_pairs(inutils.py) to extractsub_channelfrom theproductContextfield inchannel_datawhensub_channelis not set, supporting both string and dictionary formats forchannel_data. Parsing errors are handled gracefully.Testing improvements:
test_baggage_middleware.pyto verify thatBaggageMiddlewarecorrectly extracts theproductContextassub_channelwhen not set, and that an explicitsub_channeltakes precedence overproductContext.