Skip to content

A local-first multi-agent app development platform, built on PenguinHarness

fix(web): running subagents stay visible across tasks (#1110)

lmliheng8d334447797c
diff --git a/changelog/unreleased/2026-10-14-running-subagents-panel.md b/changelog/unreleased/2026-10-14-running-subagents-panel.md
new file mode 100644
index 00000000..973f06ee
--- /dev/null
+++ b/changelog/unreleased/2026-10-14-running-subagents-panel.md
@@ -0,0 +1,17 @@
+# Running subagents stay visible across tasks
+
+- **Date:** 2026-10-14
+- **Type:** fix
+- **Scope:** `web`
+
+[中文版](2026-10-14-running-subagents-panel.zh.md)
+
+Ported from upstream PenguinHarness (#1110, commit `355d6b10`).
+
+The agents panel replaced its graph when a later message started a new task, so a background child
+that was still running disappeared from the panel while the runtime kept reporting it running. Now
+the default graph keeps the loaded children the runtime reports running beside the latest task's
+children; each keeps its original description and its own conversation, and one that settles drops
+out again. Selecting a historical subagent chip still shows that task's own graph only.
+
+Interfaces and the stored data are unchanged.
diff --git a/changelog/unreleased/2026-10-14-running-subagents-panel.zh.md b/changelog/unreleased/2026-10-14-running-subagents-panel.zh.md
new file mode 100644
index 00000000..b0acb4e6
--- /dev/null
+++ b/changelog/unreleased/2026-10-14-running-subagents-panel.zh.md
@@ -0,0 +1,16 @@
+# 跨轮次保留运行中的子智能体
+
+- **Date:** 2026-10-14
+- **Type:** fix
+- **Scope:** `web`
+
+[English](2026-10-14-running-subagents-panel.md)
+
+移植自上游 PenguinHarness(#1110,提交 `355d6b10`)。
+
+后来的一条消息开启新一轮任务时,智能体面板会整张换掉调用图 —— 于是仍在后台运行、运行时也仍报告为「运行中」
+的子智能体从面板上消失了。现在默认调用图会把「运行时报告为运行中」的已加载子节点与最新一轮任务派生的子智能体
+一并留下:每个都保留原有的任务描述与自己那条会话,任务结束后它自己再消失。点击历史子智能体快捷行时,显示的
+仍只有那一轮自己的调用图。
+
+接口与已存数据都没有变化。
diff --git a/packages/web/src/features/chat/agent-topology.ts b/packages/web/src/features/chat/agent-topology.ts
index 64ec06e1..e34bbe7a 100644
--- a/packages/web/src/features/chat/agent-topology.ts
+++ b/packages/web/src/features/chat/agent-topology.ts
@@ -7,11 +7,11 @@
* Task that REFERENCES A SUBAGENT (task boundaries from the "starts a new Task" predicate
* the reducer uses — user_text / user_image; user_steering never starts one — so a plain
* user message never wipes the panel), or, for a chip clicked on an older turn, the
- * HISTORICAL Task slice containing that chip's child (extractTopologyForChild). It collects
- * spawned children from bound run_subagent tool cards and standalone SubagentItems, then
+ * HISTORICAL Task slice containing that chip's child (extractTopologyForChild). The default
+ * view also keeps children the runtime reports running, even when an earlier Task spawned
+ * them. It collects children from bound run_subagent tool cards and standalone SubagentItems, then
* recurses into each child model's own items for deeper spawns. Nodes are deduped by session id
- * (an input_subagent repoll can reference the same child twice); a new Task therefore starts
- * from a graph of just the root again. Each child node also carries its elapsed-time sources
+ * (an input_subagent repoll can reference the same child twice). Each child node carries its elapsed-time sources
* (from the nested model's activity stamps — wall clock of the whole spawn, never a sum of its
* items).
*
@@ -201,6 +201,15 @@ export function extractTopology(
// root never reads as running.
{ running: end === items.length && taskRunning },
liveStates,
+ items.filter((item) => {
+ const sessionId =
+ item.kind === "tool_call"
+ ? item.subagentSessionId
+ : item.kind === "subagent"
+ ? item.sessionId
+ : undefined;
+ return sessionId !== undefined && liveStates?.get(sessionId) === true;
+ }),
);
}
@@ -295,6 +304,7 @@ function extractFromSlice(
rootSessionId: string,
root: { running: boolean },
liveStates?: ReadonlyMap<string, boolean>,
+ runningChildren: readonly ChatItem[] = [],
): TopologyNode[] {
const nodes: TopologyNode[] = [
{
@@ -377,6 +387,10 @@ function extractFromSlice(
};
walk(slice, rootSessionId, []);
+ // A background child can outlive the Task that launched it. Keep its original card
+ // and nested conversation reachable while another Task owns the default graph. The
+ // historical extractor passes no extras, so an explicit chip selection stays scoped.
+ walk(runningChildren, rootSessionId, []);
return nodes;
}
diff --git a/packages/web/test/agent-topology.test.ts b/packages/web/test/agent-topology.test.ts
index dab55f2f..f1e21152 100644
--- a/packages/web/test/agent-topology.test.ts
+++ b/packages/web/test/agent-topology.test.ts
@@ -6,6 +6,13 @@
* resolution (session_meta capture vs. the run_subagent agent_id argument, agent_state path
* parsing), the pending-approval subtree predicate, and layered-tree layout
* determinism/geometry.
+ *
+ * - Given an earlier child is still running, when a later task spawns another child,
+ * then the default panel keeps both visible with their own conversations.
+ * - Given two children are spawned during one task, when both continue streaming,
+ * then neither node nor conversation replaces the other.
+ * - Given an explicit historical task selection, when another task has a running child,
+ * then the historical graph stays scoped to the requested task.
*/
import { describe, expect, it, vi } from "vitest";
import {
@@ -73,6 +80,74 @@ function at<M extends OmniMessage>(msg: M, ts: string): M {
}
describe("extractTopology", () => {
+ it("keeps an earlier running child visible beside the latest task's children", () => {
+ const m = createStreamModel();
+ pushMessage(m, userText("write the paper"));
+ spawnChild(m, "paper-call", "paper", '{"description":"Write version 9"}');
+ pushMessage(m, withOrigin(assistantText("Working on version 9"), "paper"));
+ pushMessage(m, toolCallOutput({ output: "yielded", toolCallId: "paper-call" }));
+ pushMessage(m, userText("check the references"));
+ spawnChild(m, "references-call", "references");
+ const live = new Map([
+ ["paper", true],
+ ["references", true],
+ ]);
+ const nodes = extractTopology(m, "root", true, live);
+ expect(nodes.map((n) => n.sessionId)).toEqual(["root", "references", "paper"]);
+ expect(nodes.filter((n) => n.depth > 0).every((n) => n.running)).toBe(true);
+ expect(nodes.find((n) => n.sessionId === "paper")).toMatchObject({
+ description: "Write version 9",
+ running: true,
+ origin: ["paper"],
+ parentId: "root",
+ });
+ expect(modelAtOrigin(m, nodes.find((n) => n.sessionId === "paper")!.origin)?.items).toEqual(
+ expect.arrayContaining([expect.objectContaining({ text: "Working on version 9" })]),
+ );
+ // A settled older child no longer crowds the current graph.
+ live.set("paper", false);
+ expect(extractTopology(m, "root", true, live).map((n) => n.sessionId)).toEqual([
+ "root",
+ "references",
+ ]);
+ });
+
+ it("keeps both running children and their conversations during the same task", () => {
+ const m = createStreamModel();
+ pushMessage(m, userText("write the paper and check its references"));
+ spawnChild(m, "paper-call", "paper", '{"description":"Write version 9"}');
+ pushMessage(m, withOrigin(assistantText("Writing the paper"), "paper"));
+ pushMessage(m, toolCallOutput({ output: "yielded", toolCallId: "paper-call" }));
+ spawnChild(m, "references-call", "references", '{"description":"Check references"}');
+ pushMessage(m, withOrigin(assistantText("Checking references"), "references"));
+ pushMessage(m, withOrigin(assistantText("Paper progress"), "paper"));
+
+ const nodes = extractTopology(
+ m,
+ "root",
+ true,
+ new Map([
+ ["paper", true],
+ ["references", true],
+ ]),
+ );
+ expect(nodes.map((n) => n.sessionId)).toEqual(["root", "paper", "references"]);
+ expect(nodes.slice(1).map((n) => [n.description, n.running])).toEqual([
+ ["Write version 9", true],
+ ["Check references", true],
+ ]);
+ for (const node of nodes.slice(1)) {
+ const texts = modelAtOrigin(m, node.origin)?.items.flatMap((item) =>
+ item.kind === "assistant_text" ? [item.text] : [],
+ );
+ expect(texts).toEqual(
+ node.sessionId === "paper"
+ ? ["Writing the paper", "Paper progress"]
+ : ["Checking references"],
+ );
+ }
+ });
+
it("returns only the root (with the Task's running state) when nothing is spawned", () => {
const m = createStreamModel();
pushMessage(m, userText("hello"));
@@ -241,6 +316,10 @@ describe("extractTopologyForChild (historical Task slice)", () => {
// done even while the LATEST Task is running.
expect(historical[0]!.running).toBe(false);
expect(historical[1]!.running).toBe(false);
+ const live = new Map([["child2", true]]);
+ expect(
+ extractTopologyForChild(m, "root", true, "child1", live)!.map((n) => n.sessionId),
+ ).toEqual(["root", "child1"]);
});
it("anchoring on a latest-Task child returns the live latest slice (root keeps the running state)", () => {