From 5341093d8975bbbb3152f4ca24c479bc0387b964 Mon Sep 17 00:00:00 2001 From: Peng Fan Date: Wed, 13 May 2026 14:25:28 -0700 Subject: [PATCH 1/2] Revert "Fix get_caller_pairs: resolve userId across all channels (#118)" This reverts commit 97ec7f30cd1087926910b4f79e0e4e3149c9bca3. --- .../a365/hosting/scope_helpers/utils.py | 2 +- .../scope_helpers/test_scope_helper_utils.py | 58 ------------------- 2 files changed, 1 insertion(+), 59 deletions(-) diff --git a/src/microsoft/opentelemetry/a365/hosting/scope_helpers/utils.py b/src/microsoft/opentelemetry/a365/hosting/scope_helpers/utils.py index 7554f1e6..b5ab7a77 100644 --- a/src/microsoft/opentelemetry/a365/hosting/scope_helpers/utils.py +++ b/src/microsoft/opentelemetry/a365/hosting/scope_helpers/utils.py @@ -63,7 +63,7 @@ def get_caller_pairs(activity: Activity) -> Iterator[tuple[str, Any]]: frm = activity.from_property if not frm: return - yield USER_ID_KEY, frm.aad_object_id or frm.agentic_user_id or frm.id + yield USER_ID_KEY, frm.aad_object_id yield USER_NAME_KEY, frm.name yield USER_EMAIL_KEY, frm.agentic_user_id diff --git a/tests/a365/hosting/scope_helpers/test_scope_helper_utils.py b/tests/a365/hosting/scope_helpers/test_scope_helper_utils.py index 07f5a63f..8d0ee845 100644 --- a/tests/a365/hosting/scope_helpers/test_scope_helper_utils.py +++ b/tests/a365/hosting/scope_helpers/test_scope_helper_utils.py @@ -83,64 +83,6 @@ def test_get_channel_pairs(): assert (CHANNEL_LINK_KEY, None) in result -def test_get_caller_pairs_fallback_to_frm_id(): - """Test get_caller_pairs falls back to frm.id when aad_object_id is None (non-Teams channel).""" - from_account = ChannelAccount( - id="slack-user-123", - name="Slack User", - agentic_user_id=None, - aad_object_id=None, - ) - activity = Activity(type="message", from_property=from_account) - - result = list(get_caller_pairs(activity)) - - assert (USER_ID_KEY, "slack-user-123") in result - - -def test_get_caller_pairs_fallback_to_agentic_user_id(): - """Test get_caller_pairs falls back to agentic_user_id for A2A when aad_object_id is None.""" - from_account = ChannelAccount( - id="raw-id", - name="Agent Caller", - agentic_user_id="agent-auid-456", - aad_object_id=None, - ) - activity = Activity(type="message", from_property=from_account) - - result = list(get_caller_pairs(activity)) - - assert (USER_ID_KEY, "agent-auid-456") in result - - -def test_get_caller_pairs_aad_object_id_takes_precedence(): - """Test get_caller_pairs uses aad_object_id when all identifiers are set.""" - from_account = ChannelAccount( - id="raw-id", - name="Teams User", - agentic_user_id="agent-auid", - aad_object_id="aad-wins", - ) - activity = Activity(type="message", from_property=from_account) - - result = list(get_caller_pairs(activity)) - - assert (USER_ID_KEY, "aad-wins") in result - - -def test_get_caller_pairs_a2a_guid_agentic_user_id(): - """Test userId resolves to GUID AgenticUserId in A2A scenario.""" - from_account = ChannelAccount( - id="29:1sH5NArUwkWAX", - name="Agent Caller", - agentic_user_id="bef730f4-d6f5-4ffb-b759-26ffa449ed7e", - aad_object_id=None, - ) - activity = Activity(type="message", from_property=from_account) - result = list(get_caller_pairs(activity)) - assert (USER_ID_KEY, "bef730f4-d6f5-4ffb-b759-26ffa449ed7e") in result - - def test_get_conversation_pairs(): """Test get_conversation_pairs extracts conversation information.""" conversation = ConversationAccount(id="conversation-123") From 4fa6e8f91220c10a28f751ffadac6d38a598d35f Mon Sep 17 00:00:00 2001 From: Peng Fan Date: Thu, 14 May 2026 12:13:51 -0700 Subject: [PATCH 2/2] Fix mypy error caused by requests 2.34.1 HeadersType change requests 2.34.1 changed HeadersType from Mapping to MutableMapping, which is invariant in its value type. Widen headers annotation from dict[str, str] to dict[str, str | bytes] to match. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../opentelemetry/a365/core/exporters/agent365_exporter.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/microsoft/opentelemetry/a365/core/exporters/agent365_exporter.py b/src/microsoft/opentelemetry/a365/core/exporters/agent365_exporter.py index 4e9dc8fc..89089f48 100644 --- a/src/microsoft/opentelemetry/a365/core/exporters/agent365_exporter.py +++ b/src/microsoft/opentelemetry/a365/core/exporters/agent365_exporter.py @@ -130,7 +130,7 @@ def export(self, spans: Sequence[ReadableSpan]) -> SpanExportResult: agent_id, ) - headers: dict[str, str] = {"content-type": "application/json"} + headers: dict[str, str | bytes] = {"content-type": "application/json"} try: token = self._token_resolver(agent_id, tenant_id) if token: @@ -227,7 +227,7 @@ def _truncate_text(text: str, max_length: int) -> str: return text[:max_length] + "..." return text - def _post_with_retries(self, url: str, body: str, headers: dict[str, str]) -> bool: + def _post_with_retries(self, url: str, body: str, headers: dict[str, str | bytes]) -> bool: for attempt in range(DEFAULT_MAX_RETRIES + 1): try: resp = self._session.post(