From c041fcc04dcb38de162396514827fcebb39ed08b Mon Sep 17 00:00:00 2001 From: Tak Hoffman <781889+Takhoffman@users.noreply.github.com> Date: Thu, 26 Mar 2026 12:18:19 -0500 Subject: [PATCH] fix: expose parent session keys in sessions list --- src/agents/openclaw-tools.sessions.test.ts | 13 ++++++++++++- src/agents/tools/sessions-helpers.ts | 1 + src/agents/tools/sessions-list-tool.ts | 8 ++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/agents/openclaw-tools.sessions.test.ts b/src/agents/openclaw-tools.sessions.test.ts index 91f0a343898..d301893067b 100644 --- a/src/agents/openclaw-tools.sessions.test.ts +++ b/src/agents/openclaw-tools.sessions.test.ts @@ -160,6 +160,13 @@ describe("sessions tools", () => { estimatedCostUsd: 0.0042, childSessions: ["agent:main:subagent:worker"], }, + { + key: "agent:main:dashboard:child", + kind: "direct", + sessionId: "s-dashboard-child", + updatedAt: 12, + parentSessionKey: "agent:main:main", + }, { key: "cron:job-1", kind: "direct", @@ -201,10 +208,11 @@ describe("sessions tools", () => { runtimeMs?: number; estimatedCostUsd?: number; childSessions?: string[]; + parentSessionKey?: string; messages?: Array<{ role?: string }>; }>; }; - expect(details.sessions).toHaveLength(3); + expect(details.sessions).toHaveLength(4); const main = details.sessions?.find((s) => s.key === "main"); expect(main?.channel).toBe("whatsapp"); expect(main?.messages?.length).toBe(1); @@ -217,6 +225,9 @@ describe("sessions tools", () => { expect(group?.estimatedCostUsd).toBe(0.0042); expect(group?.childSessions).toEqual(["agent:main:subagent:worker"]); + const dashboardChild = details.sessions?.find((s) => s.key === "agent:main:dashboard:child"); + expect(dashboardChild?.parentSessionKey).toBe("agent:main:main"); + const cronOnly = await tool.execute("call2", { kinds: ["cron"] }); const cronDetails = cronOnly.details as { sessions?: Array>; diff --git a/src/agents/tools/sessions-helpers.ts b/src/agents/tools/sessions-helpers.ts index f87ef38f7c1..4ea24d00b7b 100644 --- a/src/agents/tools/sessions-helpers.ts +++ b/src/agents/tools/sessions-helpers.ts @@ -54,6 +54,7 @@ export type SessionListRow = { channel: string; label?: string; displayName?: string; + parentSessionKey?: string; deliveryContext?: SessionListDeliveryContext; updatedAt?: number | null; sessionId?: string; diff --git a/src/agents/tools/sessions-list-tool.ts b/src/agents/tools/sessions-list-tool.ts index d4dd84e2fa8..32a09c2bd5b 100644 --- a/src/agents/tools/sessions-list-tool.ts +++ b/src/agents/tools/sessions-list-tool.ts @@ -195,6 +195,14 @@ export function createSessionsListTool(opts?: { channel: derivedChannel, label: typeof entry.label === "string" ? entry.label : undefined, displayName: typeof entry.displayName === "string" ? entry.displayName : undefined, + parentSessionKey: + typeof entry.parentSessionKey === "string" + ? resolveDisplaySessionKey({ + key: entry.parentSessionKey, + alias, + mainKey, + }) + : undefined, deliveryContext: deliveryChannel || deliveryTo || deliveryAccountId ? {