Multiplayer agent harness for work.
Show a subagent's delegated task in its transcript (#2150)
Regan Bell978aa7b92b4f
diff --git a/src/core/orchestrator.ts b/src/core/orchestrator.tsindex e63f8b1e5..744218cae 100644--- a/src/core/orchestrator.ts+++ b/src/core/orchestrator.ts@@ -3344,9 +3344,11 @@ export function createOrchestrator(deps: OrchestratorDeps): Orchestrator {let firstChunkAt: number | undefined;let lastChunkAt: number | undefined;const emittedEntries: SessionEntry[] = [];+ const delegatedTask =+ automatedTurn && !!input.sessionSenderId && session.parentSessionId === input.sessionSenderId;const syntheticPrompt =(input.proactiveOpener && !input.text.trim()) ||- automatedTurn ||+ (automatedTurn && !delegatedTask) ||partial ||approvalReplay ||!!releasedToolOutput;diff --git a/src/sessions/session-syscalls.ts b/src/sessions/session-syscalls.tsindex bd1809743..114ce840a 100644--- a/src/sessions/session-syscalls.ts+++ b/src/sessions/session-syscalls.ts@@ -880,7 +880,7 @@ export function createSessionSyscalls(deps: SessionSyscallDeps): SessionSyscalls? { privateSessionMessage: true as const, sessionMessageDepth: messageDepth }: {}),text: stamped,- displayText: stamped,+ displayText: text,},maxAttempts: deps.maxAttempts,});diff --git a/test/subagent-task-visibility.test.ts b/test/subagent-task-visibility.test.tsnew file mode 100644index 000000000..a9a279520--- /dev/null+++ b/test/subagent-task-visibility.test.ts@@ -0,0 +1,63 @@+import "./support/auto-fake-sprites.ts";+import { test } from "node:test";+import assert from "node:assert/strict";+import { buildApp } from "../src/wiring.ts";+import { testConfig } from "./support/test-config.ts";+import { settle } from "./support/settle.ts";+import { createSessionSyscalls } from "../src/sessions/session-syscalls.ts";+import { createSessionMailbox, type SessionMessage } from "../src/sessions/session-mailbox.ts";+import { createMemoryMap } from "../src/persistence/durable-map.ts";+import type { Run } from "../src/runs/run-store.ts";++test("a subagent shows its delegated tasks while the parent's completion wake stays hidden", async (t) => {+ const built = buildApp(testConfig({ memoryCapture: "off" }));+ t.after(async () => {+ built.scheduler.stop();+ built.deploymentLayerRefresh.stop();+ await built.runtime.stop();+ });+ const threadRef = "dm:U1:subagent-visibility";+ await built.app.turn({+ surface: "test",+ surfaceTools: true,+ actor: { externalId: "U1" },+ conversation: { kind: "dm", threadRef },+ text: "hello",+ });+ const parentRun = (await built.runs.latestForThread(threadRef))!;+ const parentSession = (await built.sessions.getByThread(threadRef))!;+ await built.featureFlags.setEnabled("responsive_spine", parentSession.scopeId, true, "U1");+ const syscalls = createSessionSyscalls({+ sessions: built.sessions,+ runs: built.runs,+ signals: built.signals,+ mailbox: createSessionMailbox(createMemoryMap<SessionMessage>()),+ maxAttempts: 1,+ }).forTurn({ session: parentSession, scopeId: parentSession.scopeId, request: parentRun.request });+ const finished = async (lookup: () => Promise<Run | null | undefined>) => {+ let run: Run | null | undefined;+ await settle(async () => ["done", "failed"].includes((run = await lookup())?.status ?? ""));+ assert.equal(run?.result?.status, "ok", JSON.stringify(run?.result));+ return run!;+ };+ const userEntry = async (run: Run) => {+ const session = (await built.sessions.getByThread(run.sessionId))!;+ const entries = await built.sessions.getEntries(session.id);+ const { payload } = entries.find((entry) => entry.type === "user" && entry.seq === run.turnUserSeq)!;+ const { hidden, display } = payload as { hidden?: boolean; display?: string };+ return { hidden: hidden === true, display };+ };++ const opened = await syscalls.open({ task: "Summarize the repo", name: "repo summary" });+ assert.ok(opened.ok);+ const child = (await built.sessions.get(opened.sessionId))!;+ built.runtime.startBackground();+ const first = await finished(() => built.runs.latestForThread(child.threadRef));+ assert.deepEqual(await userEntry(first), { hidden: false, display: "Summarize the repo" });+ const wake = await finished(() => built.runs.getByDedupKey(`subagent-return:${first.id}`));+ assert.equal((await userEntry(wake)).hidden, true);++ assert.ok((await syscalls.write({ followup: true, target: child.id, text: "Check the tests too" })).ok);+ const second = await finished(() => built.runs.latestForThread(child.threadRef));+ assert.deepEqual(await userEntry(second), { hidden: false, display: "Check the tests too" });+});