Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

fix: a sub-agent's turn end is not news — only the main agent's rings the dial

0xdiego25fcccbf01b2d0
diff --git a/cli/src/backendSocket.ts b/cli/src/backendSocket.ts
index 40c3784a3..29811fec3 100644
--- a/cli/src/backendSocket.ts
+++ b/cli/src/backendSocket.ts
@@ -464,6 +464,10 @@ export class BackendSocket {
this.orchestratorService?.delivery(event)
}
private orchestratorService: OrchestratorService | null = null
+ /** The commander asks this for every turn that ends — see OrchestratorService.roleOf. */
+ orchestratorRoleOf(agentId: string): ReturnType<OrchestratorService['roleOf']> {
+ return this.orchestration().roleOf(agentId)
+ }
private orchestration(): OrchestratorService {
return this.orchestratorService ??= new OrchestratorService({
stateDir: join(env.ADAPTER_DATA_DIR, 'orchestrator'),
diff --git a/cli/src/cable/cableHost.spec.ts b/cli/src/cable/cableHost.spec.ts
index 388726b71..a5f2d670e 100644
--- a/cli/src/cable/cableHost.spec.ts
+++ b/cli/src/cable/cableHost.spec.ts
@@ -1,7 +1,7 @@
// How the wheel's rows are composed: the local row, and the fleet's rows around it.
import { describe, expect, it, vi } from 'vitest'
-import { DaemonCableHost, type CableHostWiring } from './cableHost.js'
+import { DaemonCableHost, cableEventFor, type CableHostWiring } from './cableHost.js'
import type { FleetMachine, MachineFleet } from './machineFleet.js'
const AGENTS: Array<{ agentId: string; registeredAt: number; active: boolean; terminalAvailable: boolean; engine: string }> = []
@@ -648,3 +648,13 @@ describe('DaemonCableHost.listSwarms', () => {
expect(host.listSwarms()).toEqual({ selected: '', swarms: [] })
})
})
+
+describe('cableEventFor', () => {
+ it('carries whether the card is a sub-agent\'s turn end, and nothing else about it', () => {
+ const base = { type: 'commander_event', agentId: 'a1', payload: { kind: 'summary', text: 'body', recap: 'recap' } }
+ expect(cableEventFor(base)).toEqual({ kind: 'summary', agentId: 'a1', text: 'body', recap: 'recap', subagent: false })
+ expect(cableEventFor({ ...base, payload: { ...base.payload, subagent: true } })?.subagent).toBe(true)
+ expect(cableEventFor({ ...base, payload: { ...base.payload, subagent: 'yes' } })?.subagent).toBe(false)
+ expect(cableEventFor({ ...base, payload: { kind: 'tool', text: 'Bash' } })).toBeNull()
+ })
+})
diff --git a/cli/src/cable/cableHost.ts b/cli/src/cable/cableHost.ts
index fc4cb47e2..f9ca10fcc 100644
--- a/cli/src/cable/cableHost.ts
+++ b/cli/src/cable/cableHost.ts
@@ -987,12 +987,13 @@ export function multipart(file: Buffer, filename: string, mimeType: string, boun
* kind reaches the cable the day it reaches the socket.
*/
export function cableEventFor(
- frame: { type?: string; agentId?: string; payload?: { kind?: string; text?: string; recap?: string } },
-): { kind: 'processing' | 'done' | 'summary' | 'error'; agentId: string; text: string; recap: string } | null {
+ frame: { type?: string; agentId?: string; payload?: { kind?: string; text?: string; recap?: string; subagent?: unknown } },
+): { kind: 'processing' | 'done' | 'summary' | 'error'; agentId: string; text: string; recap: string; subagent: boolean } | null {
if (frame.type !== 'commander_event' || !frame.agentId) return null
const kind = frame.payload?.kind
if (kind !== 'processing' && kind !== 'done' && kind !== 'summary' && kind !== 'error') return null
- return { kind, agentId: frame.agentId, text: frame.payload?.text ?? '', recap: frame.payload?.recap ?? '' }
+ // `subagent`: a sub-agent's turn end — the tile redraws, nobody is told (CommanderMirrorOpts.isSubagent).
+ return { kind, agentId: frame.agentId, text: frame.payload?.text ?? '', recap: frame.payload?.recap ?? '', subagent: frame.payload?.subagent === true }
}
/**
diff --git a/cli/src/cable/cableSession.spec.ts b/cli/src/cable/cableSession.spec.ts
index b55757099..e45506afd 100644
--- a/cli/src/cable/cableSession.spec.ts
+++ b/cli/src/cable/cableSession.spec.ts
@@ -994,6 +994,12 @@ describe('cable session', () => {
expect(sent.find((m) => m.agentId === 'a1')).not.toHaveProperty('quiet')
// The recap still travels — the tile draws it either way. Only the beep and the drawer are withheld.
expect(sent.find((m) => m.agentId === 'a2')).toMatchObject({ quiet: true, recap: 'recap two' })
+
+ // A sub-agent's turn: silent — no beep, no drawer row — and the recap still travels.
+ await session.summary('a1', 'recap three', 'body three', false, true)
+ const silent = port.sent.filter((m) => m.t === 'summary' && m.agentId === 'a1').pop()
+ expect(silent).toMatchObject({ silent: true, recap: 'recap three' })
+ expect(silent).not.toHaveProperty('quiet')
})
it('redraws a reattached dial with what each agent was last doing', async () => {
diff --git a/cli/src/cable/cableSession.ts b/cli/src/cable/cableSession.ts
index 86caf4f8c..faeec60c3 100644
--- a/cli/src/cable/cableSession.ts
+++ b/cli/src/cable/cableSession.ts
@@ -1385,13 +1385,15 @@ export class CableSession {
* A finished turn's recap.
*
* `quiet` means the window already has this agent on screen: draw the tile,
- * skip the beep and the notification drawer. An extra field rather than a
- * different frame, so firmware that predates it simply notifies as it always
- * did instead of losing the recap.
+ * skip the notification drawer (the beep still sounds). `silent` means the
+ * turn was a sub-agent's: draw the tile, skip the beep AND the drawer — the
+ * main agent's own end is the one the person is waiting for. Extra fields
+ * rather than different frames, so firmware that predates them simply
+ * notifies as it always did instead of losing the recap.
*/
- async summary(agentId: string, recap: string, text: string, quiet = false): Promise<void> {
+ async summary(agentId: string, recap: string, text: string, quiet = false, silent = false): Promise<void> {
const who = this.whoIs(agentId)
- await this.send(quiet ? { t: 'summary', agentId, ...who, recap, text, quiet: true } : { t: 'summary', agentId, ...who, recap, text })
+ await this.send({ t: 'summary', agentId, ...who, recap, text, ...(quiet ? { quiet: true } : {}), ...(silent ? { silent: true } : {}) })
}
/**
diff --git a/cli/src/cable/machineFleet.ts b/cli/src/cable/machineFleet.ts
index 75b51385b..7c6a93822 100644
--- a/cli/src/cable/machineFleet.ts
+++ b/cli/src/cable/machineFleet.ts
@@ -30,7 +30,7 @@ export class FleetError extends Error {
/** A card from an attached machine, already translated into the dial's four kinds. */
export type FleetEvent =
- | { machineId: string; kind: 'processing' | 'done' | 'summary' | 'error'; agentId: string; text: string; recap: string }
+ | { machineId: string; kind: 'processing' | 'done' | 'summary' | 'error'; agentId: string; text: string; recap: string; subagent?: boolean }
| { machineId: string; kind: 'question'; agentId: string; requestId: string; questions: unknown }
| { machineId: string; kind: 'state'; state: FleetMachine['state'] }
diff --git a/cli/src/cli.ts b/cli/src/cli.ts
index 228bad0ed..7e73d11ea 100644
--- a/cli/src/cli.ts
+++ b/cli/src/cli.ts
@@ -150,7 +150,7 @@ import { RemoteRelayPool } from './lib/remoteRelay.js'
import { TERMINAL_BINARY_VERSION } from './lib/terminalBinary.js'
import { foldTranscript, lastTurnTextFromRawLines, lineToEvents, newTurnState, type LiveEvent, type TurnState } from './lib/normalize.js'
import { AskQuestionController, pollsQuestions, QuestionWatcher } from './lib/askQuestion.js'
-import { CommanderMirror, type CommanderMirrorOpts } from './lib/commander.js'
+import { CommanderMirror, SUBAGENT_IDLE_MS, type CommanderMirrorOpts } from './lib/commander.js'
import {
setSummaryPoolDeviceConnected,
shutdownSummaryPool,
@@ -2375,6 +2375,25 @@ async function runForeground(session: AuthSession): Promise<void> {
...summarizer,
nameFor: (sessionId) => { const s = registry.bySession(sessionId); return s ? projectDisplayName(s) : undefined },
agentIdFor: (sessionId) => registry.bySession(sessionId)?.agentId,
+ // An Orchestrator specialist's turn end, or the Director's while specialists are still out, is not
+ // announced: the person asked to hear from the main agent once, not from every sub-agent.
+ isSubagent: (sessionId) => {
+ const agentId = registry.bySession(sessionId)?.agentId
+ if (!agentId) return false
+ const role = backend.orchestratorRoleOf(agentId)
+ return role?.role === 'worker' || (role?.role === 'director' && role.busy)
+ },
+ // A claude sub-agent still at work is one whose transcript is still growing:
+ // `<session>/subagents/agent-<id>.jsonl` beside the parent's (the same file enrichSubagentStats
+ // reads). Written in the last SUBAGENT_IDLE_MS = alive; the held turn end waits for it.
+ subagentActive: (sessionId, agentId) => {
+ const transcriptPath = registry.bySession(sessionId)?.transcriptPath
+ if (!transcriptPath) return false
+ try {
+ const at = statSync(join(transcriptPath.replace(/\.jsonl$/, ''), 'subagents', `agent-${agentId}.jsonl`)).mtimeMs
+ return Date.now() - at < SUBAGENT_IDLE_MS
+ } catch { return false }
+ },
readLastTurn: async (sessionId) => {
const s = registry.bySession(sessionId)
if (!s) return null
@@ -5413,10 +5432,10 @@ async function runForeground(session: AuthSession): Promise<void> {
if (event.kind === 'processing') void cable.turnStarted(event.agentId, event.text)
else if (event.kind === 'done') void cable.turnDone(event.agentId)
else if (event.kind === 'summary') {
- // Quiet when the window already has this agent on screen. The tile still
- // updates — the recap is what it draws — only the beep and the drawer
- // entry are withheld, because they exist for a turn nobody is watching.
- void cable.summary(event.agentId, event.recap || event.text, event.text, openPaneAgents.has(event.agentId))
+ // Quiet when the window already has this agent on screen; silent when the
+ // turn was a sub-agent's. The tile still updates — the recap is what it
+ // draws — only the beep and the drawer entry are withheld.
+ void cable.summary(event.agentId, event.recap || event.text, event.text, openPaneAgents.has(event.agentId), event.subagent)
}
else void cable.turnError(event.agentId, event.text)
}
@@ -5439,10 +5458,11 @@ async function runForeground(session: AuthSession): Promise<void> {
if (event.kind === 'processing') void cable.turnStarted(event.agentId, event.text)
else if (event.kind === 'done') void cable.turnDone(event.agentId)
else if (event.kind === 'summary') {
- // Quiet when the window already has this agent on screen. The tile still
+ // Quiet when the window already has this agent on screen; silent when the
+ // turn was a sub-agent's (decided on its own machine). The tile still
// updates — the recap is what it draws — only the beep and the drawer
- // entry are withheld, because they exist for a turn nobody is watching.
- void cable.summary(event.agentId, event.recap || event.text, event.text, openPaneAgents.has(event.agentId))
+ // entry are withheld.
+ void cable.summary(event.agentId, event.recap || event.text, event.text, openPaneAgents.has(event.agentId), event.subagent === true)
}
else void cable.turnError(event.agentId, event.text)
})
diff --git a/cli/src/device/deviceFleet.ts b/cli/src/device/deviceFleet.ts
index e0c35c8a7..b13280e06 100644
--- a/cli/src/device/deviceFleet.ts
+++ b/cli/src/device/deviceFleet.ts
@@ -362,6 +362,8 @@ export class DeviceFleet implements MachineFleet {
agentId: frame.agentId,
text: typeof payload.text === 'string' ? payload.text : '',
recap: typeof payload.recap === 'string' ? payload.recap : '',
+ // A specialist on another Mac is as silent here as one on this one.
+ ...(payload.subagent === true ? { subagent: true } : {}),
})
return
}
diff --git a/cli/src/lib/commander.spec.ts b/cli/src/lib/commander.spec.ts
index d90db1e79..2d25fffd6 100644
--- a/cli/src/lib/commander.spec.ts
+++ b/cli/src/lib/commander.spec.ts
@@ -207,6 +207,93 @@ describe('CommanderMirror recap events', () => {
expect((last?.payload.agents as Array<{ text: string }>).map((r) => r.text)).toEqual(['› still going', '› second'])
})
+ it('marks a sub-agent\'s turn end so the dial redraws the tile and tells nobody', async () => {
+ // An Orchestrator specialist (or the Director while specialists are still out): its `done`/`summary`
+ // carry `subagent: true`; the live stream does not, so the tile still moves.
+ const deviceFrames: CommanderFrame[] = []
+ const mirror = new CommanderMirror({
+ send: (frame) => deviceFrames.push(frame),
+ sendWeb: () => {},
+ hasDevice: () => true,
+ summarize: async () => 'Short recap\n\nLong body',
+ isSubagent: (sessionId) => sessionId === 'specialist',
+ dataDir,
+ })
+ for (const sessionId of ['specialist', 'director']) {
+ mirror.ingest([
+ { type: 'turn_started', payload: { userMessage: 'go' } },
+ { type: 'text_delta', payload: { content: 'answered.' } },
+ { type: 'turn_ended', payload: {} },
+ ] as LiveEvent[], sessionId)
+ }
+ await vi.runAllTimersAsync()
+ await Promise.resolve()
+ const of = (id: string) => deviceFrames.filter((f) => f.dbSessionId === id)
+ expect(of('specialist').map((f) => [f.payload.kind, f.payload.subagent])).toEqual([
+ ['processing', undefined], ['processing', undefined], ['done', true], ['summary', true],
+ ])
+ expect(of('director').every((f) => f.payload.subagent === undefined)).toBe(true)
+ })
+
+ it('keeps holding the turn end past the old cap while a sub-agent is still writing, then gives up silently', async () => {
+ // A fixed ten minutes released the hold under long sub-agents: one ring for a turn that was not
+ // over, another when it was. Now the sub-agents' transcripts are asked every minute.
+ const deviceFrames: CommanderFrame[] = []
+ let writing = true
+ const mirror = new CommanderMirror({
+ send: (frame) => deviceFrames.push(frame),
+ sendWeb: () => {},
+ hasDevice: () => true,
+ summarize: async () => 'Short recap\n\nLong body',
+ subagentActive: (_sessionId, agentId) => agentId === 'a1' && writing,
+ dataDir,
+ })
+ mirror.ingest([
+ { type: 'turn_started', payload: { userMessage: 'delegate' } },
+ { type: 'tool_start', payload: { id: 'a1', tool: 'Agent', input: { description: 'long job' } } },
+ { type: 'tool_end', payload: { id: 'a1', tool: 'Agent', output: 'Async agent launched successfully.', isError: false, summary: '' } },
+ { type: 'text_delta', payload: { content: 'Launched the long job.' } },
+ { type: 'turn_ended', payload: {} },
+ ] as LiveEvent[], 'session-long')
+ const ends = () => deviceFrames.filter((f) => f.payload.kind === 'summary')
+
+ await vi.advanceTimersByTimeAsync(25 * 60_000)
+ expect(ends()).toHaveLength(0) // 25 minutes in, still writing: still held
+
+ writing = false
+ await vi.advanceTimersByTimeAsync(2 * 60_000)
+ await vi.runAllTimersAsync()
+ await Promise.resolve()
+ expect(ends()).toHaveLength(1)
+ // Given up on, not done — silent, so the person is not rung for an answer that never came.
+ expect(ends()[0].payload).toMatchObject({ subagent: true, recap: 'Short recap' })
+ })
+
+ it('a sub-agent that finishes releases the hold with an ordinary, audible summary', async () => {
+ const deviceFrames: CommanderFrame[] = []
+ const mirror = new CommanderMirror({
+ send: (frame) => deviceFrames.push(frame),
+ sendWeb: () => {},
+ hasDevice: () => true,
+ summarize: async () => 'Short recap\n\nLong body',
+ subagentActive: () => true,
+ dataDir,
+ })
+ mirror.ingest([
+ { type: 'turn_started', payload: { userMessage: 'delegate' } },
+ { type: 'tool_start', payload: { id: 'a1', tool: 'Agent', input: { description: 'short job' } } },
+ { type: 'turn_ended', payload: {} },
+ { type: 'subagent_finished', payload: { id: 'a1', status: 'completed' } },
+ { type: 'text_delta', payload: { content: 'Both done.' } },
+ ] as LiveEvent[], 'session-short')
+ mirror.noteEngineStopped('session-short')
+ await vi.runAllTimersAsync()
+ await Promise.resolve()
+ const ends = deviceFrames.filter((f) => f.payload.kind === 'summary')
+ expect(ends).toHaveLength(1)
+ expect(ends[0].payload).not.toHaveProperty('subagent')
+ })
+
it('emits done before summary when recap succeeds', async () => {
const deviceFrames: CommanderFrame[] = []
const webFrames: Record<string, unknown>[] = []
diff --git a/cli/src/lib/commander.ts b/cli/src/lib/commander.ts
index 2880ed948..5a365e018 100644
--- a/cli/src/lib/commander.ts
+++ b/cli/src/lib/commander.ts
@@ -59,6 +59,20 @@ export interface CommanderMirrorOpts {
* `/clear` rotation); `dbSessionId` stays the engine session, which is what the device echoes back to
* cancel a turn and what the backend keys its voice queue on. */
agentIdFor?: (sessionId: string) => string | undefined
+ /**
+ * True for a session whose turn end is nobody's news: an Orchestrator specialist, or its Director while
+ * specialists are still out. The terminal cards (`done`, `summary`, `error`) then carry `subagent: true`
+ * and the dial redraws the tile without the beep or a drawer row (cable_client.c). The person asked for
+ * one notification per project — the main agent's — not one per sub-agent (owner, 2026-09-21).
+ */
+ isSubagent?: (sessionId: string) => boolean
+ /**
+ * Whether a sub-agent of this session is still at work — its transcript
+ * (`<session>/subagents/agent-<id>.jsonl`) written recently. Consulted while a turn end is held, so a
+ * long sub-agent keeps the hold and only a silent one is given up on. Absent → the hold is bounded by
+ * time alone, as before.
+ */
+ subagentActive?: (sessionId: string, agentId: string) => boolean
dataDir: string
recapForce?: boolean
alwaysGenerate?: boolean
@@ -80,6 +94,8 @@ interface SessionState {
agents: Array<{ id: string; desc: string; startedAt: number; doneMs: number | null; carried?: true }>
/** A turn_ended is being HELD because sub-agents this turn spawned are still running (see below). */
endPending: boolean
+ /** The hold was given up on (a sub-agent went quiet), not completed: the recap goes out silent. */
+ abandoned: boolean
/** Fires the held turn-end once the last sub-agent has finished AND the wrap-up text has stopped. */
endSettle: NodeJS.Timeout | null
/** Backstop: a sub-agent that never reports back must not cost the turn its recap. */
@@ -170,8 +186,17 @@ const ASYNC_LAUNCH_ACK = /Async agent launched successfully/i
*/
const SUBAGENT_SETTLE_MS = 12_000
const SUBAGENT_TEXT_SETTLE_MS = 2_000
-/** A sub-agent that never reports back must not cost the turn its recap forever. */
+/**
+ * A sub-agent that never reports back must not cost the turn its recap forever — but a sub-agent that IS
+ * still writing is not "never": a fixed ten minutes released the hold under long sub-agents, which rang
+ * the dial for a turn that was not over and then rang it again when it was. So the deadline is checked
+ * every minute against the sub-agents' own transcripts (`subagentActive`): held while any of them wrote
+ * in the last SUBAGENT_IDLE_MS, given up only once all of them have gone quiet for that long. Without
+ * the probe, the old ten minutes stand.
+ */
const SUBAGENT_MAX_WAIT_MS = 10 * 60_000
+export const SUBAGENT_IDLE_MS = 2 * 60_000
+const SUBAGENT_CHECK_MS = 60_000
/**
* The device renders ONE line per sub-agent and does no formatting of its own: `› desc` while it runs,
@@ -304,7 +329,7 @@ export class CommanderMirror {
private stateFor(sessionId: string): SessionState {
let st = this.states.get(sessionId)
if (!st) {
- st = { lastAssistantText: '', lastUserMessage: '', turnOpen: false, everOpened: false, summarizing: false, lastTool: null, lastTodos: null, agents: [], endPending: false, endSettle: null, endDeadline: null, abort: null }
+ st = { lastAssistantText: '', lastUserMessage: '', turnOpen: false, everOpened: false, summarizing: false, lastTool: null, lastTodos: null, agents: [], endPending: false, abandoned: false, endSettle: null, endDeadline: null, abort: null }
this.states.set(sessionId, st)
}
return st
@@ -325,7 +350,11 @@ export class CommanderMirror {
if (!terminal && !active && !this.opts.recapForce) return
// Agent name on the summary's outer frame → background-machine device notif line 2 (see nameFor).
const name = terminal && this.opts.nameFor ? this.opts.nameFor(sessionId) : undefined
- this.opts.send({ type: 'commander_event', agentId: this.opts.agentIdFor?.(sessionId) ?? sessionId, dbSessionId: sessionId, ...(name ? { name } : {}), payload })
+ // A sub-agent's turn end is not announced: the flag rides the terminal cards only, so the live stream
+ // (processing/tool/todos) is untouched and the tile still moves.
+ const ending = payload.kind === 'summary' || payload.kind === 'done' || payload.kind === 'error'
+ const subagent = ending && ((this.opts.isSubagent?.(sessionId) ?? false) || (this.states.get(sessionId)?.abandoned ?? false))
+ this.opts.send({ type: 'commander_event', agentId: this.opts.agentIdFor?.(sessionId) ?? sessionId, dbSessionId: sessionId, ...(name ? { name } : {}), payload: subagent ? { ...payload, subagent: true } : payload })
}
/** Recap diagnostics stay in the adapter log; the web only gets summary pending/done state. */
@@ -362,6 +391,7 @@ export class CommanderMirror {
this.rememberAsk(sessionId, e.payload.userMessage || '')
st.turnOpen = true
st.everOpened = true
+ st.abandoned = false
st.lastTool = null
st.lastTodos = null
// Drop the previous turn's finished rows, KEEP the ones still running. Two reasons, both
@@ -484,11 +514,36 @@ export class CommanderMirror {
const running = st.agents.filter(holdsTurn).length
console.log(`[subagents] ${sessionId.slice(0, 8)} turn-end HELD · ${running} sub-agent(s) still running`)
this.clearEndTimers(st)
+ this.armDeadline(sessionId, st, Date.now())
+ }
+
+ /**
+ * The hold's backstop. With `subagentActive` the question is asked every minute — is any held sub-agent
+ * still writing? — and the hold outlives the old cap for as long as the answer is yes; a sub-agent quiet
+ * for SUBAGENT_IDLE_MS is abandoned and the hold released without one. Without the probe, one timer at
+ * the old cap, as before.
+ */
+ private armDeadline(sessionId: string, st: SessionState, heldAt: number): void {
+ const probe = this.opts.subagentActive
+ const wait = probe ? SUBAGENT_CHECK_MS : SUBAGENT_MAX_WAIT_MS
st.endDeadline = setTimeout(() => {
- const stuck = st.agents.filter(holdsTurn).map((a) => a.desc).join(', ')
+ st.endDeadline = null
+ if (!st.endPending) return
+ const held = st.agents.filter(holdsTurn)
+ const elapsed = Date.now() - heldAt
+ if (probe && elapsed < SUBAGENT_MAX_WAIT_MS) { this.armDeadline(sessionId, st, heldAt); return }
+ if (probe && held.some((a) => probe(sessionId, a.id))) {
+ console.log(`[subagents] ${sessionId.slice(0, 8)} turn-end still HELD after ${Math.round(elapsed / 60_000)}m · a sub-agent is still writing`)
+ this.armDeadline(sessionId, st, heldAt)
+ return
+ }
+ const stuck = held.map((a) => a.desc).join(', ')
console.log(`[subagents] ${sessionId.slice(0, 8)} turn-end RELEASED by timeout · still running: ${stuck}`)
+ // Given up on, not done: the person did not get their answer, and a beep for that is the very ring
+ // this exists to remove. The tile still gets the recap.
+ st.abandoned = true
this.releaseTurnEnd(sessionId, st)
- }, SUBAGENT_MAX_WAIT_MS)
+ }, wait)
st.endDeadline.unref?.()
}
diff --git a/cli/src/orchestrator/service.spec.ts b/cli/src/orchestrator/service.spec.ts
index d7c743c26..48f59507b 100644
--- a/cli/src/orchestrator/service.spec.ts
+++ b/cli/src/orchestrator/service.spec.ts
@@ -80,6 +80,19 @@ describe('durable orchestrator lifecycle', () => {
expect(sent).toHaveLength(4)
expect(research.agentId).toBeTruthy()
})
+ it('names each agent\'s role: specialists are never news, the Director only once nothing is left to run', async () => {
+ // What the daemon asks before it lets a turn end ring the dial (CommanderMirrorOpts.isSubagent).
+ await start(); await active()
+ expect(service.roleOf(launches[0].name === `Director ${id.slice(0, 8)}` ? 'agent-1' : '')).toEqual({ role: 'director', busy: false })
+ service.plan(id, [task('part')])
+ const part = await running('part')
+ expect(service.roleOf(part.agentId!)).toEqual({ role: 'worker' })
+ expect(service.roleOf('agent-1')).toEqual({ role: 'director', busy: true })
+ expect(service.roleOf('nobody')).toBeNull()
+ await service.finish(id, 'part', 1, 'Done', [])
+ expect(service.roleOf('agent-1')).toEqual({ role: 'director', busy: false })
+ expect(service.roleOf(part.agentId!)).toEqual({ role: 'worker' }) // a finished specialist stays one
+ })
it('limits parallelism and treats a repeated plan as the same work', async () => {
await start(); await active()
const plan = [task('a'), task('b'), task('c')]
diff --git a/cli/src/orchestrator/service.ts b/cli/src/orchestrator/service.ts
index 09935a8a7..ce4522a8a 100644
--- a/cli/src/orchestrator/service.ts
+++ b/cli/src/orchestrator/service.ts
@@ -107,6 +107,23 @@ export class OrchestratorService {
return message
}
catalog(): HarnessChoice[] { return this.deps.catalog() }
+ /**
+ * What an agent is to a project: a specialist (`worker`), the Director (with whether work is still
+ * out — a task queued, launching or running on an active run), or nothing. The daemon asks this for
+ * every turn that ends: a specialist's end is never announced, and the Director's only when nothing is
+ * left to run — the person asked for one notification per project, not one per sub-agent.
+ */
+ roleOf(agentId: string): { role: 'worker' } | { role: 'director'; busy: boolean } | null {
+ this.load()
+ for (const run of this.runs.values()) {
+ if (run.tasks.some(t => t.agentId === agentId)) return { role: 'worker' }
+ if (run.directorId === agentId) {
+ const busy = run.state === 'active' && run.tasks.some(t => t.state === 'queued' || t.state === 'launching' || t.state === 'running')
+ return { role: 'director', busy }
+ }
+ }
+ return null
+ }
list(): Record<string, unknown>[] {
this.load()
return [...this.runs.values()].sort((a, b) => b.updatedAt - a.updatedAt).map(r => ({
diff --git a/devices/harness-device/firmware/main/cable_client.c b/devices/harness-device/firmware/main/cable_client.c
index df207ba8d..c990a93f5 100644
--- a/devices/harness-device/firmware/main/cable_client.c
+++ b/devices/harness-device/firmware/main/cable_client.c
@@ -691,6 +691,12 @@ static void handle_message(const cJSON *root)
// for a day the dial updated its tile in complete silence: no beep, no wake, nothing in the
// drawer — the one part of a finished turn a person is not looking at the screen for.
//
+ // A SUB-AGENT'S turn (`silent`, decided by the daemon: an Orchestrator specialist, or its
+ // Director while specialists are still out) is not news at all — the tile above is redrawn and
+ // that is the whole of it. A project of four specialists used to ring eight times before the one
+ // ring that mattered (owner, 2026-09-21: "chỉ cần báo thằng main thôi"). Absent = false, so an
+ // older daemon rings exactly as before.
+ if (bool_of(p, "silent")) return;
// THE BEEP ALWAYS SOUNDS. A finished turn is news even when the person is looking straight at
// it: they are reading the last one, not watching for the next to end, and three tones is how
// they learn a task is done without moving their eyes.