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.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
Devices: a Swarm worker's failed turn no longer takes over the round dial (#2005)
harness-for-autonomous[bot]7dba926095ee
diff --git a/cli/src/services/devices.spec.ts b/cli/src/services/devices.spec.tsindex e78d77420..a38ff202c 100644--- a/cli/src/services/devices.spec.ts+++ b/cli/src/services/devices.spec.ts@@ -1100,6 +1100,89 @@ describe('the other machines\' cards', () => {})})+// A Swarm Reviewer on Diego's Mac's Harness Team account failed every turn in 1–2 s (2026-10-28), and each failure took+// over the round dial with the engine's raw error for 8 s. A Swarm's workers report to their Lead, not to the person's dial.+describe('a failed turn of a Swarm worker', () => {+ const swarmAgents = (sessions: Array<Partial<RegisteredSession>>) => fakeCore({ dataDir, agents: {+ byAgent: vi.fn((id: string) => sessions.find((s) => s.agentId === id) as RegisteredSession | undefined),+ } })+ const teamAccount = (core: CoreApi) => {+ vi.mocked(core.account.machines).mockResolvedValue({ status: 200, body: { success: true, data: { machines: [+ { machineId: 'team-mac', name: 'Diego’s Mac', sessionKind: 'team' },+ { machineId: 'mac-mini', name: 'Mac mini', sessionKind: 'computer' },+ ] } } })+ return seen.fleet!.deps.machines.refresh()+ }++ it('on a Harness Team account never reaches the dial as an error, and ends its tile quietly', async () => {+ const { core } = start()+ await teamAccount(core)+ seen.fleet!.events!({ machineId: 'team-mac', kind: 'processing', agentId: 'reviewer', text: 'go', recap: '' })+ seen.fleet!.events!({ machineId: 'team-mac', kind: 'error', agentId: 'reviewer', text: 'stream disconnected', recap: '' })+ await vi.waitFor(() => expect(calls('turnDone')).toEqual([['reviewer']]))+ expect(calls('turnError')).toEqual([])+ })++ it('the Swarm started on this computer, a Builder or a Reviewer, never reaches the dial as an error', async () => {+ const { port } = start({ core: swarmAgents([+ { agentId: 'builder', startedBy: 'agent', swarmSkill: { role: 'dev', key: 'k1' } },+ { agentId: 'reviewer', startedBy: 'agent', swarmSkill: { role: 'review', key: 'k2' } },+ ]) })+ port.card({ type: 'commander_event', agentId: 'builder', payload: { kind: 'error', text: 'boom' } })+ port.card({ type: 'commander_event', agentId: 'reviewer', payload: { kind: 'error', text: 'boom' } })+ await vi.waitFor(() => expect(calls('turnDone')).toEqual([['builder'], ['reviewer']]))+ expect(calls('turnError')).toEqual([])+ expect(logs.some((l) => /notify · .* · silent · rule:swarm-worker/.test(l))).toBe(true)+ })++ it('the person has on a desk tab still reaches the dial as an error, as every desk agent\'s does', async () => {+ const { core, port } = start({ core: swarmAgents([+ { agentId: 'builder', startedBy: 'agent', swarmSkill: { role: 'dev', key: 'k1' } },+ { agentId: 'mine' },+ ]) })+ await teamAccount(core)+ port.swarms({ active: 't1', swarms: [+ { id: 't1', name: 'api', agentIds: ['mine'], panes: 1 },+ { id: 't2', name: 'Swarm', agentIds: ['builder'], panes: 1 },+ ], tiles: [] })+ port.desk(['reviewer'], false)+ port.card({ type: 'commander_event', agentId: 'mine', payload: { kind: 'error', text: 'mine broke' } })+ port.card({ type: 'commander_event', agentId: 'builder', payload: { kind: 'error', text: 'builder broke' } })+ seen.fleet!.events!({ machineId: 'team-mac', kind: 'error', agentId: 'reviewer', text: 'reviewer broke', recap: '' })+ // An agent on one of the person's own computers is the person's, whether or not it is on a tab.+ seen.fleet!.events!({ machineId: 'mac-mini', kind: 'error', agentId: 'far', text: 'far broke', recap: '' })+ await vi.waitFor(() => expect(calls('turnError')).toHaveLength(4))+ expect(calls('turnError')).toEqual([['mine', 'mine broke'], ['builder', 'builder broke'], ['reviewer', 'reviewer broke'], ['far', 'far broke']])+ })++ it('a person started by hand still reaches the dial as an error, even with a Builder\'s or Reviewer\'s role', async () => {+ const { port } = start({ core: swarmAgents([+ { agentId: 'builder', swarmSkill: { role: 'dev', key: 'k1' } },+ { agentId: 'reviewer', startedBy: undefined, swarmSkill: { role: 'review', key: 'k2' } },+ ]) })+ port.card({ type: 'commander_event', agentId: 'builder', payload: { kind: 'error', text: 'builder broke' } })+ port.card({ type: 'commander_event', agentId: 'reviewer', payload: { kind: 'error', text: 'reviewer broke' } })+ await vi.waitFor(() => expect(calls('turnError')).toEqual([['builder', 'builder broke'], ['reviewer', 'reviewer broke']]))+ expect(calls('turnDone')).toEqual([])+ })++ it('leaves a Lead\'s own failure as it was', async () => {+ const { port } = start({ core: swarmAgents([{ agentId: 'lead', swarmSkill: { role: 'lead', key: 'k' } }]) })+ port.card({ type: 'commander_event', agentId: 'lead', payload: { kind: 'error', text: 'lead broke' } })+ await vi.waitFor(() => expect(calls('turnError')).toEqual([['lead', 'lead broke']]))+ expect(calls('turnDone')).toEqual([])+ })++ it('on a machine once listed as a Harness Team account is the person\'s again once the list no longer says so', async () => {+ const { core } = start()+ await teamAccount(core)+ vi.mocked(core.account.machines).mockResolvedValue({ status: 401, body: {} })+ await seen.fleet!.deps.machines.refresh()+ seen.fleet!.events!({ machineId: 'team-mac', kind: 'error', agentId: 'reviewer', text: 'boom', recap: '' })+ await vi.waitFor(() => expect(calls('turnError')).toEqual([['reviewer', 'boom']]))+ })+})+describe('⌘K, the Wi-Fi device\'s borrowed walk, the voice router and stopping', () => {it('route a typed task and its send through the fleet, saying why a send was refused', async () => {const { port } = start()diff --git a/cli/src/services/devices.ts b/cli/src/services/devices.tsindex f2ccb51e4..d1102cf04 100644--- a/cli/src/services/devices.ts+++ b/cli/src/services/devices.ts@@ -34,6 +34,7 @@ import { WindowSelection } from '../cable/windowSelection.js'import { WindowVisit } from '../cable/windowVisit.js'import { MachineListCache } from '../device/machineList.js'import { harnessDevicesRequest } from '../lib/harnessDevices.js'+import { machineKindsOf } from '../lib/e2ee/machineKinds.js'import { truncateUtf8 } from '../lib/deviceRecentTrim.js'import { setVoiceRouterDeviceConnected, setVoiceRouterSessions, shutdownVoiceRouter } from '../lib/voiceRouter.js'import { createJevDecide } from '../lib/jev/jevClient.js'@@ -84,6 +85,8 @@ const NO_AGENT_LIST = 'no agent list yet'const CHAT_ID = /^[A-Za-z0-9_-]{1,47}$/const unrouted = (reason: string): RouteAnswer => ({ agentId: '', machineId: '', name: '', confidence: 0, reason, candidates: [], weighed: 0, machines: 0, via: '' })const sid = (id: string): string => id.slice(0, 8)+/** A card for the dial, and the machine it came from when another machine sent it (services/fleet.ts). */+type DialEvent = NonNullable<ReturnType<typeof cableEventFor>> & { machineId?: string }export function startDevices(core: CoreApi, ports: CorePorts, deps: DevicesDeps): ServiceRequests {const log = deps.log ?? ((line: string) => console.log(line))@@ -119,6 +122,12 @@ export function startDevices(core: CoreApi, ports: CorePorts, deps: DevicesDeps)// the trust group read; this copy writes no file of its own, so `machines.json` has one writer.const machines = new MachineListCache(() => core.account.machines(), () => core.machine.computerId(),(line) => log(`[cable] ${line}`), core.dataDir, () => null, false)+ // The account's Harness Team account machines, as each list read says (docs/plans/2026-10-24-swarm-team-account.md):+ // they run Swarm work only. Forgotten on a sign-out, which tells the list as null.+ let teamMachines = new Set<string>()+ machines.listen((body) => {+ teamMachines = new Set([...machineKindsOf(body) ?? []].filter(([, kind]) => kind === 'team').map(([id]) => id))+ })const fleet: Fleet | null = part.start('fleet', () => startFleet(core, { machines, desk: () => desk, refresh: deps.refresh }).fleet, FLEET_FALLBACKS)// ── the window bridges ─────────────────────────────────────────────────────────────────────────────@@ -319,7 +328,7 @@ export function startDevices(core: CoreApi, ports: CorePorts, deps: DevicesDeps)/** One card for the dial, in its four calls. A remote machine's and this computer's are the same calls,* so a new kind of card lands on both the day it lands on either. */- const dispatch = (event: NonNullable<ReturnType<typeof cableEventFor>>): void | Promise<void> => {+ const dispatch = (event: DialEvent): void | Promise<void> => {if (event.kind !== 'processing') latestUpdate.delete(event.agentId)if (event.kind === 'processing') {if (event.update) latestUpdate.set(event.agentId, event.update)@@ -372,10 +381,29 @@ export function startDevices(core: CoreApi, ports: CorePorts, deps: DevicesDeps)began.delete(event.agentId); ended.delete(event.agentId)stats.take(event.agentId) // a failed turn's sums must not leak into the next turnstarts.delete(event.agentId)+ // A Swarm Reviewer on a Mac's Harness Team account failed every turn in 1-2 s (2026-10-28), and each failure took over+ // the round dial with the engine's raw error for 8 s. A Swarm's workers answer to their Lead, who hears of it in the+ // Swarm: one the person has not put on a tab ends its tile quietly, as a finished turn does, and never stays Working.+ if (swarmWorker(event) && !onDesk(event.agentId)) {+ tally(cableHost.describe(event.agentId)?.name ?? '', 'silent', 'rule:swarm-worker', 'turn.error', 0)+ void cable.turnDone(event.agentId)+ return+ }tally(cableHost.describe(event.agentId)?.name ?? '', 'alert', 'rule:failed', 'turn.error', 0)void cable.turnError(event.agentId, event.text)}}+ /** A Builder or Reviewer the Swarm started here (its record's Swarm role, and an agent started it, as every Swarm start+ * is), or any agent on a Harness Team account. A Lead is the person's own agent leading the Swarm, and one the person+ * started by hand is theirs whatever its role: their failures reach the dial as before. */+ const swarmWorker = (event: DialEvent): boolean => {+ const session = event.machineId ? undefined : core.agents.byAgent(event.agentId)+ const role = session?.startedBy === 'agent' ? session.swarmSkill?.role : undefined+ return role === 'dev' || role === 'review' || (!!event.machineId && teamMachines.has(event.machineId))+ }+ /** On any of the window's tabs, or the desk the dial walks: the person put it there, so its failure is theirs to see. */+ const onDesk = (agentId: string): boolean =>+ desk.includes(agentId) || cableHost.listSwarms().swarms.some((tab) => tab.agentIds?.includes(agentId))/*** The reply as it streams: a `steps-v1` device shows the agent's latest paragraph, but a text delta arrives every* few tokens and the link is lossy. So at most one send per 750 ms per agent, a trailing send of the last text@@ -422,7 +450,7 @@ export function startDevices(core: CoreApi, ports: CorePorts, deps: DevicesDeps)queued.set(agentId, tail)void tail.then(() => { if (queued.get(agentId) === tail) queued.delete(agentId) })}- const toDial = (event: NonNullable<ReturnType<typeof cableEventFor>>): void => {+ const toDial = (event: DialEvent): void => {// The last streamed text goes out before the turn's end, in the same per-agent order.if (event.kind !== 'processing') endReplies(event.agentId, true)inOrder(event.agentId, () => dispatch(event))