Fix GetCallerBaggagePairs: resolve userId across all channels#251
Fix GetCallerBaggagePairs: resolve userId across all channels#251
Conversation
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>
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
There was a problem hiding this comment.
Pull request overview
This PR updates observability hosting caller identity extraction so get_caller_pairs can still populate user.id when aad_object_id is absent, improving telemetry coverage for non-Teams and A2A scenarios.
Changes:
- Changed caller ID resolution in
get_caller_pairsto useaad_object_id -> agentic_user_id -> from.id. - Added regression tests for non-Teams fallback to
from.id. - Added tests for A2A fallback and identifier precedence when multiple values are present.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
libraries/microsoft-agents-a365-observability-hosting/microsoft_agents_a365/observability/hosting/scope_helpers/utils.py |
Updates caller user.id derivation used by hosting scope helpers. |
tests/observability/hosting/scope_helpers/test_scope_helper_utils.py |
Adds focused tests for fallback behavior and precedence. |
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
| if not frm: | ||
| return | ||
| yield USER_ID_KEY, frm.aad_object_id | ||
| yield USER_ID_KEY, frm.aad_object_id or frm.agentic_user_id or frm.id |
There was a problem hiding this comment.
It is not breaking. since for human call, agentic user id is null. it will be used only when it is presented and aad_object_id is not null.
| from_account = ChannelAccount( | ||
| id="from-id-456", | ||
| name="Agent Caller", | ||
| agentic_user_id="a2a-agent-guid", |
There was a problem hiding this comment.
The test is correct. In an A2A scenario, agentic_user_id is populated and aad_object_id is null — that is exactly what the test sets up. For human callers on non-Teams channels, agentic_user_id is null, so the fallback skips it and goes to frm.id (covered by test_get_caller_pairs_non_teams_fallback_to_from_id). The test tests the path the case when the presence of agentic_user_id but no aad_object_id.
As for agentic_user_id is being used to set user email, for real user, agentic_user_id is null, user.email will not be set. It can be set manually. TurnContext has no éxplicit field for user email. For agentic user(agent) using host agent, agentic_user_id is upn. How to set user email is out of scope of this bug fix PR>
| if not frm: | ||
| return | ||
| yield USER_ID_KEY, frm.aad_object_id | ||
| yield USER_ID_KEY, frm.aad_object_id or frm.agentic_user_id or frm.id |
| from_account = ChannelAccount( | ||
| id="from-id-456", | ||
| name="Agent Caller", | ||
| agentic_user_id="a2a-agent-guid", |
|
Re: Copilot comment on test_scope_helper_utils.py:106 — The test is correct. In an A2A scenario, |
Summary
aad_object_id, which isNoneon non-Teams channels and A2A callsaad_object_id → agentic_user_id → frm.idChannel behavior after fix
Test plan
🤖 Generated with Claude Code