From c012bff246350d4ed384802a3369bdffe41cc45e Mon Sep 17 00:00:00 2001 From: Jiayuan Zhang Date: Sun, 15 Feb 2026 18:47:44 +0800 Subject: [PATCH] fix(tools): show findings and full runId in sessions_list list view Grouped runs now display findings for completed sub-agents (up to 4000 chars). Ungrouped runs increased truncation from 200 to 4000 chars. All status lines include full runId for subsequent API queries. Co-Authored-By: Claude Opus 4.6 --- .../src/agent/tools/sessions-list.test.ts | 49 +++++++++++++++++++ .../core/src/agent/tools/sessions-list.ts | 13 +++-- 2 files changed, 57 insertions(+), 5 deletions(-) diff --git a/packages/core/src/agent/tools/sessions-list.test.ts b/packages/core/src/agent/tools/sessions-list.test.ts index 230d8997..637a8537 100644 --- a/packages/core/src/agent/tools/sessions-list.test.ts +++ b/packages/core/src/agent/tools/sessions-list.test.ts @@ -47,6 +47,8 @@ describe("sessions_list tool", () => { startedAt: now - 60000, endedAt: now - 30000, outcome: { status: "ok" }, + findings: "All tests passed successfully.", + findingsCaptured: true, }), ); seedSubagentRunForTests( @@ -56,6 +58,8 @@ describe("sessions_list tool", () => { startedAt: now - 60000, endedAt: now, outcome: { status: "error", error: "timeout" }, + findings: "Lint check timed out.", + findingsCaptured: true, }), ); @@ -71,6 +75,13 @@ describe("sessions_list tool", () => { expect((text as { text: string }).text).toContain("Code Review"); expect((text as { text: string }).text).toContain("Test Analysis"); expect((text as { text: string }).text).toContain("Lint Check"); + // Verify full runId is shown for completed runs + expect((text as { text: string }).text).toContain("id:run-aaa"); + expect((text as { text: string }).text).toContain("id:run-bbb"); + expect((text as { text: string }).text).toContain("id:run-ccc"); + // Verify findings are shown for completed runs + expect((text as { text: string }).text).toContain("All tests passed successfully."); + expect((text as { text: string }).text).toContain("Lint check timed out."); expect(result.details!.runs).toHaveLength(3); expect(result.details!.runs[0]!.status).toBe("running"); @@ -141,6 +152,44 @@ describe("sessions_list tool", () => { expect(result.details).toEqual({ runs: [] }); }); + it("shows findings for grouped completed runs", async () => { + const now = Date.now(); + const groupId = "group-001"; + seedSubagentRunForTests( + makeRecord({ + runId: "run-g1", + label: "Bull Case Research", + startedAt: now - 60000, + endedAt: now - 10000, + outcome: { status: "ok" }, + findings: "AI infrastructure capex growing 40% YoY.", + findingsCaptured: true, + groupId, + }), + ); + seedSubagentRunForTests( + makeRecord({ + runId: "run-g2", + label: "Bear Case Research", + startedAt: now - 60000, + endedAt: now - 5000, + outcome: { status: "ok" }, + findings: "Valuation risk: forward P/E above historical average.", + findingsCaptured: true, + groupId, + }), + ); + + const tool = createSessionsListTool({ sessionId: "parent-001" }); + const result = await tool.execute("call-1", {}); + + const text = (result.content[0] as { text: string }).text; + expect(text).toContain("id:run-g1"); + expect(text).toContain("id:run-g2"); + expect(text).toContain("AI infrastructure capex growing 40% YoY."); + expect(text).toContain("Valuation risk: forward P/E above historical average."); + }); + it("shows findings status for running task", async () => { const now = Date.now(); seedSubagentRunForTests( diff --git a/packages/core/src/agent/tools/sessions-list.ts b/packages/core/src/agent/tools/sessions-list.ts index 93ef896c..8905b943 100644 --- a/packages/core/src/agent/tools/sessions-list.ts +++ b/packages/core/src/agent/tools/sessions-list.ts @@ -212,10 +212,13 @@ export function createSessionsListTool( const status = resolveStatus(r); if (status === "running") { const elapsed = r.startedAt ? formatElapsed(now - r.startedAt) : "just spawned"; - statusLines.push(` ${idx}. [RUNNING] "${displayName}" (${elapsed})`); + statusLines.push(` ${idx}. [RUNNING] "${displayName}" (${elapsed}) id:${r.runId}`); } else { const elapsed = r.startedAt && r.endedAt ? formatElapsed(r.endedAt - r.startedAt) : ""; - statusLines.push(` ${idx}. [${status.toUpperCase()}] "${displayName}" (${elapsed})`); + const findings = r.findingsCaptured + ? (r.findings ? r.findings.slice(0, 4000) + (r.findings.length > 4000 ? "…" : "") : "(no output)") + : "(findings not yet captured)"; + statusLines.push(` ${idx}. [${status.toUpperCase()}] "${displayName}" (${elapsed}) id:${r.runId}\n Findings: ${findings}`); } } } @@ -227,13 +230,13 @@ export function createSessionsListTool( const status = resolveStatus(r); if (status === "running") { const elapsed = r.startedAt ? formatElapsed(now - r.startedAt) : "just spawned"; - statusLines.push(` ${idx}. [RUNNING] "${displayName}" (${elapsed})`); + statusLines.push(` ${idx}. [RUNNING] "${displayName}" (${elapsed}) id:${r.runId}`); } else { const elapsed = r.startedAt && r.endedAt ? formatElapsed(r.endedAt - r.startedAt) : ""; const findings = r.findingsCaptured - ? (r.findings ? r.findings.slice(0, 200) + (r.findings.length > 200 ? "…" : "") : "(no output)") + ? (r.findings ? r.findings.slice(0, 4000) + (r.findings.length > 4000 ? "…" : "") : "(no output)") : "(findings not yet captured)"; - statusLines.push(` ${idx}. [${status.toUpperCase()}] "${displayName}" (${elapsed})\n Findings: ${findings}`); + statusLines.push(` ${idx}. [${status.toUpperCase()}] "${displayName}" (${elapsed}) id:${r.runId}\n Findings: ${findings}`); } }