Skip to content

Fix GetCallerBaggagePairs: resolve userId across all channels#246

Merged
fpfp100 merged 2 commits intomainfrom
fix/caller-baggage-email-word-channels
May 4, 2026
Merged

Fix GetCallerBaggagePairs: resolve userId across all channels#246
fpfp100 merged 2 commits intomainfrom
fix/caller-baggage-email-word-channels

Conversation

@fpfp100
Copy link
Copy Markdown
Contributor

@fpfp100 fpfp100 commented May 4, 2026

Summary

  • userId (user.id): Previously only set from From.AadObjectId, which is null on non-Teams channels and A2A calls. Now uses fallback chain: AadObjectId → AgenticUserId → From.Id

Channel behavior after fix

Field Teams Other channels (AadObjectId null) A2A (user) A2A (agent)
userId AadObjectId From.Id AadObjectId AgenticUserId
userName From.Name From.Name From.Name From.Name

Test plan

  • Existing tests pass (66)
  • New test: non-Teams channel — userId falls back to From.Id when AadObjectId is null
  • New test: A2A — userId falls back to AgenticUserId when AadObjectId is null
  • New test: precedence — AadObjectId wins when both AadObjectId and AgenticUserId are set
  • New test: A2A with GUID AgenticUserIduserId resolves to AgenticUserId

🤖 Generated with Claude Code

…channels

GetCallerBaggagePairs previously only used From.AadObjectId for userId
(null on email/Word channels) and never set userEmail.

Changes:
- userId: fallback chain AadObjectId → AgenticUserId → From.Id
- userEmail: use From.Id when SubChannel is present (email/Word/SPO) or
  From.Id matches email format; also check AgenticUserId for A2A calls
  where the calling agent has an email-based identity

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 4, 2026 19:58
@fpfp100 fpfp100 requested a review from a team as a code owner May 4, 2026 19:58
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 4, 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.

This PR updates caller telemetry baggage so userId can be resolved for non-Teams scenarios where From.AadObjectId is missing, using the fallback chain AadObjectId → AgenticUserId → From.Id. Tests cover all fallback paths and precedence.

Comment thread src/Observability/Hosting/Extensions/TurnContextExtensions.cs Outdated
Comment thread src/Observability/Hosting/Extensions/TurnContextExtensions.cs Outdated
Comment thread src/Observability/Hosting/Extensions/TurnContextExtensions.cs
Comment thread src/Observability/Hosting/Extensions/TurnContextExtensions.cs Outdated
Comment thread src/Observability/Hosting/Extensions/TurnContextExtensions.cs Fixed
Copy link
Copy Markdown
Contributor Author

@fpfp100 fpfp100 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 7c20291.

- Remove SubChannel check, IsEmail helper, EmailPattern regex, and userEmail field
- Keep userId fallback: AadObjectId → AgenticUserId → From.Id
- Replace email-specific tests with userId-focused tests covering all fallback paths
- Add precedence test: AadObjectId wins when both AadObjectId and AgenticUserId are set
- Rename capturedCallerId → capturedUserId in new tests
- Use realistic channel names (msteams, outlook) instead of test-channel

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@fpfp100 fpfp100 changed the title Fix GetCallerBaggagePairs: resolve userId and userEmail across all channels Fix GetCallerBaggagePairs: resolve userId across all channels May 4, 2026
@fpfp100 fpfp100 merged commit 30bde75 into main May 4, 2026
7 checks passed
@fpfp100 fpfp100 deleted the fix/caller-baggage-email-word-channels branch May 4, 2026 23:47
fpfp100 pushed a commit to microsoft/Agent365-nodejs that referenced this pull request May 5, 2026
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 pushed a commit to microsoft/Agent365-nodejs that referenced this pull request May 5, 2026
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>
rads-1996 pushed a commit to microsoft/opentelemetry-distro-python that referenced this pull request May 5, 2026
* Fix get_caller_pairs: resolve userId across all channels

userId was only set from aad_object_id, which is None on non-Teams
channels and A2A calls. Add fallback chain: aad_object_id → agentic_user_id → frm.id

Port of microsoft/Agent365-dotnet#246

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Add GUID AgenticUserId test to match .NET PR #246

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Peng Fan <pefan@microsoft.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
fpfp100 added a commit to microsoft/opentelemetry-distro-dotnet that referenced this pull request May 5, 2026
* Fix GetCallerBaggagePairs: resolve userId across all channels

userId was only set from AadObjectId, which is null 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>

* Address Copilot review feedback: clean up misleading comments

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Address review: extract from variable, add GUID test to match .NET PR #246

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Peng Fan <pefan@microsoft.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
fpfp100 added a commit to microsoft/Agent365-nodejs that referenced this pull request May 5, 2026
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: Peng Fan <pefan@microsoft.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
hectorhdzg pushed a commit to microsoft/opentelemetry-distro-javascript that referenced this pull request May 6, 2026
* Fix getCallerBaggagePairs: resolve userId across all channels

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>

* Address review: inline fallback, add GUID test to match .NET PR #246

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Format turnContextUtils test file to fix PR build

---------

Co-authored-by: Peng Fan <pefan@microsoft.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
fpfp100 added a commit to microsoft/Agent365-python that referenced this pull request May 6, 2026
* Fix GetCallerBaggagePairs: resolve userId across all channels

userId was only set from aad_object_id, which is None on non-Teams
channels and A2A calls. Add fallback chain: aad_object_id → agentic_user_id → frm.id

Port of microsoft/Agent365-dotnet#246

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Address Copilot review feedback: clean up misleading comments

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Address review: inline fallback, add GUID test to match .NET PR #246

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Peng Fan <pefan@microsoft.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: Grant Harris <96964444+gwharris7@users.noreply.github.com>
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