Skip to content

fix: add product context fallback for subchanne;#252

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

fix: add product context fallback for subchanne;#252
gwharris7 merged 6 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 and handling of channel and sub-channel information from activity data, particularly improving how the sub_channel is determined when not explicitly set. It also adds comprehensive test coverage to ensure correct behavior, especially around precedence between sub_channel and productContext.

Enhancements to channel and sub-channel extraction:

  • Improved logic in get_channel_pairs (in utils.py) to extract sub_channel from the productContext field in channel_data when sub_channel is not set, supporting both string and dictionary formats for channel_data. Parsing errors are handled gracefully.

Testing improvements:

  • Added tests in test_baggage_middleware.py to verify that BaggageMiddleware correctly extracts the productContext as sub_channel when not set, and that an explicit sub_channel takes precedence over productContext.

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

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 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 derive sub_channel from activity.channel_data["productContext"] (including JSON-string channel_data) when sub_channel is unset.
  • Add middleware tests verifying productContext fallback behavior and that explicit sub_channel takes 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__).

Comment thread tests/observability/hosting/middleware/test_baggage_middleware.py Outdated
Comment thread tests/observability/hosting/middleware/test_baggage_middleware.py Outdated
Comment thread tests/observability/hosting/middleware/test_baggage_middleware.py Outdated
Comment thread tests/observability/hosting/middleware/test_baggage_middleware.py Outdated
Copilot AI review requested due to automatic review settings May 7, 2026 23:18
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 tests/observability/hosting/middleware/test_baggage_middleware.py
Comment thread tests/observability/hosting/middleware/test_baggage_middleware.py
gwharris7 and others added 2 commits May 7, 2026 17:31
- 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
Copilot AI review requested due to automatic review settings May 8, 2026 00:33
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 1 comment.

@gwharris7 gwharris7 merged commit bf4b362 into main May 11, 2026
9 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