fix: add product context fallback for subchannel#251
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes channel metadata extraction in the observability hosting utilities so that channelData.productContext can be used as a fallback source for the channelIdSubChannel value when the latter isn’t set, preventing incorrect/empty channel linkage in downstream telemetry views.
Changes:
- Updated
getChannelBaggagePairsto derive subchannel fromactivity.channelData.productContextwhenactivity.channelIdSubChannelis missing, including parsing support whenchannelDatais a JSON string. - Added unit tests to validate the
productContextfallback and precedence rules when both fields are present.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/agents-a365-observability-hosting/src/utils/TurnContextUtils.ts | Adds subchannel fallback extraction from channelData.productContext, including string parsing. |
| tests/observability/extension/hosting/baggage-middleware.test.ts | Adds tests for productContext fallback behavior and precedence over/under channelIdSubChannel. |
- Handle empty/whitespace channelIdSubChannel by checking trim() - Remove trailing whitespace from test code - Rename test to be more specific about what is not set
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 the extraction logic for channel metadata in the observability hosting utilities and adds comprehensive tests to ensure correct behavior. The main improvement is to ensure that the
productContextfield fromchannelDatais used as a fallback forchannelIdSubChannelwhen the latter is not set, improving robustness in channel identification.Channel metadata extraction improvements:
getChannelBaggagePairsinTurnContextUtils.tsto extractsubChannelfromproductContextinchannelDataifchannelIdSubChannelis not set, including safe parsing ofchannelDatawhen it's a string. ([packages/agents-a365-observability-hosting/src/utils/TurnContextUtils.tsR103-R130](https://github.com/microsoft/Agent365-nodejs/pull/251/files#diff-112092129e451c5bdec1315001940704ec79ea745988cbcdc83aea7b5cf485a2R103-R130))Test coverage enhancements:
baggage-middleware.test.tsto verify:productContextfromchannelDatawhenchannelIdSubChannelis missing.channelIdSubChanneloverproductContextwhen both are present. ([tests/observability/extension/hosting/baggage-middleware.test.tsR143-R185](https://github.com/microsoft/Agent365-nodejs/pull/251/files#diff-dd5f4f01750f559bf2297eca7b73f062d5e37849fc73a568af42694f6b0c6e05R143-R185))