Skip to content

Fix getCallerBaggagePairs: resolve userId across all channels#250

Merged
fpfp100 merged 1 commit into
mainfrom
fix/userid-fallback-chain
May 5, 2026
Merged

Fix getCallerBaggagePairs: resolve userId across all channels#250
fpfp100 merged 1 commit into
mainfrom
fix/userid-fallback-chain

Conversation

@fpfp100
Copy link
Copy Markdown
Contributor

@fpfp100 fpfp100 commented May 5, 2026

Summary

Channel behavior after fix

Field Teams Other channels (aadObjectId null) A2A (user) A2A (agent)
userId aadObjectId from.id aadObjectId agenticUserId

Test plan

  • Existing tests pass
  • New test: non-Teams channel — userId falls back to from.id
  • New test: A2A — userId falls back to agenticUserId
  • New test: precedence — aadObjectId wins when all set

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings May 5, 2026 01:44
@fpfp100 fpfp100 requested review from a team as code owners May 5, 2026 01:44
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 caller userId OpenTelemetry baggage population in the observability hosting utilities so that user.id is resolved consistently when aadObjectId is missing (e.g., non-Teams channels and A2A scenarios). It aligns the Node implementation with the referenced .NET behavior and adds test coverage for the new precedence rules.

Changes:

  • Update getCallerBaggagePairs to resolve userId via aadObjectId → agenticUserId → from.id.
  • Add/adjust unit tests to cover non-Teams fallback, A2A fallback, and precedence when all fields are present.
  • Add Jest module mapping for @microsoft/agents-a365-observability-hosting to ensure tests resolve local source.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
tests/observability/extension/hosting/TurnContextUtils.test.ts Adds coverage for new userId fallback/precedence behavior in caller baggage extraction.
tests/observability/extension/hosting/BaggageBuilderUtils.test.ts Updates expectation to reflect new caller userId baggage population via fallback chain.
tests/jest.config.cjs Adds moduleNameMapper entry so tests can import @microsoft/agents-a365-observability-hosting from workspace source.
packages/agents-a365-observability-hosting/src/utils/TurnContextUtils.ts Implements userId fallback chain when building caller baggage pairs.

userId was only set from aadObjectId, which is undefined on non-Teams
channels and A2A calls. Add fallback chain: aadObjectId → agenticUserId → from.id

Port of microsoft/Agent365-dotnet#246

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@fpfp100 fpfp100 force-pushed the fix/userid-fallback-chain branch from feb3b9f to 71ff10d Compare May 5, 2026 01:51
@fpfp100 fpfp100 merged commit 1711b65 into main May 5, 2026
7 checks passed
@fpfp100 fpfp100 deleted the fix/userid-fallback-chain branch May 5, 2026 20:37
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.

5 participants