From 3b81f4fd958398a1b4f9d27a0cccaaae995f1845 Mon Sep 17 00:00:00 2001 From: Peng Fan Date: Wed, 13 May 2026 14:27:36 -0700 Subject: [PATCH 1/2] Revert "Fix getCallerBaggagePairs: resolve userId across all channels (#116)" This reverts commit d0409a3919e0268ff256abb708d62a6bdfdb2da4. --- .claude/settings.local.json | 10 ++++ src/a365/hosting/turnContextUtils.ts | 2 +- src/a365/hosting/types.ts | 1 - .../a365/hosting/turnContextUtils.test.ts | 58 ------------------- 4 files changed, 11 insertions(+), 60 deletions(-) create mode 100644 .claude/settings.local.json diff --git a/.claude/settings.local.json b/.claude/settings.local.json new file mode 100644 index 0000000..85355fc --- /dev/null +++ b/.claude/settings.local.json @@ -0,0 +1,10 @@ +{ + "permissions": { + "allow": [ + "Bash(gh pr:*)", + "Bash(npm ls:*)", + "Bash(npm info:*)", + "WebSearch" + ] + } +} diff --git a/src/a365/hosting/turnContextUtils.ts b/src/a365/hosting/turnContextUtils.ts index b4f847e..f2557a1 100644 --- a/src/a365/hosting/turnContextUtils.ts +++ b/src/a365/hosting/turnContextUtils.ts @@ -25,7 +25,7 @@ export function getCallerBaggagePairs(turnContext: TurnContextLike): Array<[stri } const from = turnContext.activity.from; const pairs: Array<[string, string | undefined]> = [ - [OpenTelemetryConstants.USER_ID_KEY, from.aadObjectId || from.agenticUserId || from.id], + [OpenTelemetryConstants.USER_ID_KEY, from.aadObjectId], [OpenTelemetryConstants.USER_NAME_KEY, from.name], [OpenTelemetryConstants.USER_EMAIL_KEY, from.agenticUserId], [OpenTelemetryConstants.GEN_AI_CALLER_AGENT_APPLICATION_ID_KEY, from.agenticAppBlueprintId], diff --git a/src/a365/hosting/types.ts b/src/a365/hosting/types.ts index eb4b93f..b7c3791 100644 --- a/src/a365/hosting/types.ts +++ b/src/a365/hosting/types.ts @@ -21,7 +21,6 @@ export interface ActivityLike { channelData?: unknown; serviceUrl?: string; from?: { - id?: string; aadObjectId?: string; name?: string; role?: string; diff --git a/test/internal/unit/a365/hosting/turnContextUtils.test.ts b/test/internal/unit/a365/hosting/turnContextUtils.test.ts index 7490d4c..5cc5454 100644 --- a/test/internal/unit/a365/hosting/turnContextUtils.test.ts +++ b/test/internal/unit/a365/hosting/turnContextUtils.test.ts @@ -82,64 +82,6 @@ describe("TurnContextUtils", () => { expect(pairs).toEqual([]); }); - it("should fall back to from.id when aadObjectId is undefined (non-Teams channel)", () => { - const ctx: TurnContextLike = { - activity: { - from: { id: "webchat-user-123", name: "Web User" }, - }, - turnState: new Map(), - }; - const pairs = getCallerBaggagePairs(ctx); - const obj = Object.fromEntries(pairs); - expect(obj[OpenTelemetryConstants.USER_ID_KEY]).toBe("webchat-user-123"); - expect(obj[OpenTelemetryConstants.USER_NAME_KEY]).toBe("Web User"); - }); - - it("should fall back to agenticUserId when aadObjectId is undefined (A2A)", () => { - const ctx: TurnContextLike = { - activity: { - from: { agenticUserId: "agent@contoso.com", name: "Upstream Agent" }, - }, - turnState: new Map(), - }; - const pairs = getCallerBaggagePairs(ctx); - const obj = Object.fromEntries(pairs); - expect(obj[OpenTelemetryConstants.USER_ID_KEY]).toBe("agent@contoso.com"); - }); - - it("should resolve userId to agenticUserId when it is a GUID (A2A with GUID)", () => { - const ctx: TurnContextLike = { - activity: { - from: { - id: "29:1sH5NArUwkWAX", - agenticUserId: "bef730f4-d6f5-4ffb-b759-26ffa449ed7e", - name: "Agent", - }, - }, - turnState: new Map(), - }; - const pairs = getCallerBaggagePairs(ctx); - const obj = Object.fromEntries(pairs); - expect(obj[OpenTelemetryConstants.USER_ID_KEY]).toBe("bef730f4-d6f5-4ffb-b759-26ffa449ed7e"); - }); - - it("should prefer aadObjectId over agenticUserId and from.id", () => { - const ctx: TurnContextLike = { - activity: { - from: { - id: "fallback-id", - aadObjectId: "aad-oid", - agenticUserId: "agent@contoso.com", - name: "User", - }, - }, - turnState: new Map(), - }; - const pairs = getCallerBaggagePairs(ctx); - const obj = Object.fromEntries(pairs); - expect(obj[OpenTelemetryConstants.USER_ID_KEY]).toBe("aad-oid"); - }); - it("should filter out undefined/empty values", () => { const ctx: TurnContextLike = { activity: { from: { name: "User", aadObjectId: "" } }, From 53892404055094c8fe7913ff40b0c4564e472407 Mon Sep 17 00:00:00 2001 From: Peng Fan Date: Wed, 13 May 2026 15:14:42 -0700 Subject: [PATCH 2/2] Remove unintended .claude/settings.local.json --- .claude/settings.local.json | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 .claude/settings.local.json diff --git a/.claude/settings.local.json b/.claude/settings.local.json deleted file mode 100644 index 85355fc..0000000 --- a/.claude/settings.local.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "permissions": { - "allow": [ - "Bash(gh pr:*)", - "Bash(npm ls:*)", - "Bash(npm info:*)", - "WebSearch" - ] - } -}