Skip to content

fix: add product context fallback for subchannel#251

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

fix: add product context fallback for subchannel#251
gwharris7 merged 4 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 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 productContext field from channelData is used as a fallback for channelIdSubChannel when the latter is not set, improving robustness in channel identification.

Channel metadata extraction improvements:

  • Updated getChannelBaggagePairs in TurnContextUtils.ts to extract subChannel from productContext in channelData if channelIdSubChannel is not set, including safe parsing of channelData when 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:

  • Added tests to baggage-middleware.test.ts to verify:
    • Extraction of productContext from channelData when channelIdSubChannel is missing.
    • Precedence of channelIdSubChannel over productContext when both are present. ([tests/observability/extension/hosting/baggage-middleware.test.tsR143-R185](https://github.com/microsoft/Agent365-nodejs/pull/251/files#diff-dd5f4f01750f559bf2297eca7b73f062d5e37849fc73a568af42694f6b0c6e05R143-R185))

@gwharris7 gwharris7 requested a review from a team as a code owner May 7, 2026 21:37
Copilot AI review requested due to automatic review settings May 7, 2026 21: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

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 getChannelBaggagePairs to derive subchannel from activity.channelData.productContext when activity.channelIdSubChannel is missing, including parsing support when channelData is a JSON string.
  • Added unit tests to validate the productContext fallback 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.

Comment thread packages/agents-a365-observability-hosting/src/utils/TurnContextUtils.ts Outdated
Comment thread packages/agents-a365-observability-hosting/src/utils/TurnContextUtils.ts Outdated
Copilot AI review requested due to automatic review settings May 8, 2026 00:03
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 tests/observability/extension/hosting/baggage-middleware.test.ts
Comment thread tests/observability/extension/hosting/baggage-middleware.test.ts Outdated
- Handle empty/whitespace channelIdSubChannel by checking trim()
- Remove trailing whitespace from test code
- Rename test to be more specific about what is not set
@gwharris7 gwharris7 merged commit 8df745e into main May 11, 2026
7 checks passed
@gwharris7 gwharris7 deleted the users/gwharris7/product-context-fallback branch May 11, 2026 15:54
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