From 08ecf784126dff98685a955d6cc3795d959e25e9 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 9 May 2026 00:20:50 +0100 Subject: [PATCH] test: simplify subagent reply text collection --- src/agents/subagent-control.test.ts | 30 +++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/agents/subagent-control.test.ts b/src/agents/subagent-control.test.ts index 4ed37737569..95234534c97 100644 --- a/src/agents/subagent-control.test.ts +++ b/src/agents/subagent-control.test.ts @@ -44,20 +44,22 @@ vi.mock("./run-wait.js", () => { continue; } const content = (message as { content?: unknown }).content; - const text = Array.isArray(content) - ? content - .map((block) => - block && - typeof block === "object" && - typeof (block as { text?: unknown }).text === "string" - ? (block as { text: string }).text - : "", - ) - .filter(Boolean) - .join("\n") - : typeof content === "string" - ? content - : ""; + let text = ""; + if (Array.isArray(content)) { + const textBlocks: string[] = []; + for (const block of content) { + if ( + block && + typeof block === "object" && + typeof (block as { text?: unknown }).text === "string" + ) { + textBlocks.push((block as { text: string }).text); + } + } + text = textBlocks.join("\n"); + } else if (typeof content === "string") { + text = content; + } if (text.trim()) { return { text, fingerprint: JSON.stringify(message) }; }