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
Swarm host: a start the backend failed stops the agent its machine launched for it
bitcoinbuilder10a6f7d0aeb7
diff --git a/cli/src/superTabs/machines.spec.ts b/cli/src/superTabs/machines.spec.tsindex 4aff15125..cf01dea41 100644--- a/cli/src/superTabs/machines.spec.ts+++ b/cli/src/superTabs/machines.spec.ts@@ -761,6 +761,83 @@ describe('contributed machine executor', () => {expect(machinePosts(f).at(-1)).not.toHaveProperty('preparingStartIds')})+ // Mac Auto's Harness Team account, 2026-10-29: the backend failed each start at 3 minutes while its Codex never recorded+ // its session, and the agent the machine launched for it stayed, idle, with no Swarm agent behind it.+ describe('that the backend then fails', () => {+ const waiting = { error: 'START_PENDING', startId: 'start', creationId: 'creation', harnessId: 'launched',+ detail: 'Waiting for the launched engine to record its session identity. Resume this same start request.' }+ const startPath = '/api/super-tabs/hosts/host/starts/tab/start'+ function failedLater(status: () => unknown) {+ const f = fixture()+ const closeMember = vi.fn(async (_agentId: string, _creationId?: string): Promise<Record<string, unknown>> => ({ closed: true }))+ f.core.agents.closeMember = closeMember as never+ f.start.mockResolvedValue(waiting as never)+ const original = f.backend.getMockImplementation()!+ f.backend.mockImplementation(async (core, method, path, body) => method === 'GET' && path === startPath ? status() : original(core, method, path, body))+ return { f, closeMember, fail: () => { f.pool.starts = [] } }+ }+ const settle = () => new Promise(resolve => setTimeout(resolve, 0))++ it('stops the agent it launched for it, by the start\'s own creation receipt', async () => {+ const { f, closeMember, fail } = failedLater(() => ({ error: 'Mac Auto did not start it within 3 minutes' }))+ await f.machine.tick()+ expect(closeMember).not.toHaveBeenCalled()+ fail(); f.advance(); await f.machine.tick(); await settle()+ expect(closeMember).toHaveBeenCalledWith('launched', 'creation')+ expect(f.log.mock.calls.flat().join('\n')).toContain('Stopped the agent a failed start launched (start start, session launched)')+ // Once: it is no longer the host's to stop.+ f.advance(); await f.machine.tick(); await settle()+ expect(closeMember).toHaveBeenCalledTimes(1)+ })++ it('never stops one that joined, one its receipt does not name, or one whose start is still pending', async () => {+ const joined = failedLater(() => ({ harnessId: 'launched' }))+ await joined.f.machine.tick(); joined.fail(); joined.f.advance(); await joined.f.machine.tick(); await settle()+ expect(joined.closeMember).not.toHaveBeenCalled()+ const settled = failedLater(() => ({ error: null }))+ await settled.f.machine.tick(); settled.fail(); settled.f.advance(); await settled.f.machine.tick(); await settled.f.machine.tick(); await settle()+ expect(settled.closeMember).not.toHaveBeenCalled()+ const other = failedLater(() => ({ error: 'Abandoned before it started.' }))+ other.closeMember.mockResolvedValue({ error: 'NOT_A_MEMBER' })+ await other.f.machine.tick(); other.fail(); other.f.advance(); await other.f.machine.tick(); await settle()+ other.f.advance(); await other.f.machine.tick(); await settle()+ expect(other.closeMember).toHaveBeenCalledTimes(1)+ // Still pending on the backend: nothing is asked, nothing stopped.+ const pending = failedLater(() => ({ error: 'unused' }))+ await pending.f.machine.tick(); pending.f.advance(); await pending.f.machine.tick(); await settle()+ expect(pending.f.backend.mock.calls.some(c => c[2] === startPath)).toBe(false)+ expect(pending.closeMember).not.toHaveBeenCalled()+ })++ it('asks again on later passes when it cannot tell or cannot stop it, a few times, then lets it go', async () => {+ const { f, closeMember, fail } = failedLater(() => { throw new Error('backend down') })+ await f.machine.tick(); fail()+ for (let pass = 0; pass < 7; pass++) { f.advance(); await f.machine.tick(); await settle() }+ expect(f.backend.mock.calls.filter(c => c[2] === startPath)).toHaveLength(5)+ expect(closeMember).not.toHaveBeenCalled()+ expect(f.log.mock.calls.flat().join('\n')).toContain('Could not stop the agent a failed start launched (start start): backend down')+ const refused = failedLater(() => ({ error: 'failed' }))+ refused.closeMember.mockResolvedValueOnce({ error: 'SERVICE_UNAVAILABLE', detail: 'busy' })+ await refused.f.machine.tick(); refused.fail()+ refused.f.advance(); await refused.f.machine.tick(); await settle()+ refused.f.advance(); await refused.f.machine.tick(); await settle()+ expect(refused.closeMember).toHaveBeenCalledTimes(2)+ expect(refused.f.log.mock.calls.flat().join('\n')).toContain('SERVICE_UNAVAILABLE: busy')+ })++ it('leaves alone a start whose agent is not named, and a host whose core cannot close', async () => {+ const unnamed = failedLater(() => ({ error: 'failed' }))+ unnamed.f.start.mockResolvedValue({ ...waiting, harnessId: undefined } as never)+ await unnamed.f.machine.tick(); unnamed.fail(); unnamed.f.advance(); await unnamed.f.machine.tick(); await settle()+ expect(unnamed.closeMember).not.toHaveBeenCalled()+ const noClose = failedLater(() => ({ error: 'failed' }))+ noClose.f.core.agents.closeMember = undefined+ await noClose.f.machine.tick(); noClose.fail(); noClose.f.advance(); await noClose.f.machine.tick(); await settle()+ noClose.f.advance(); await noClose.f.machine.tick(); await settle()+ expect(noClose.f.backend.mock.calls.filter(c => c[2] === startPath)).toHaveLength(1)+ })+ })+it('is not a start whose launch is uncertain, refused or failed', async () => {for (const result of [{ ...pendingCreation, state: 'unconfirmed' }, { error: 'START_UNCERTAIN', startId: 'start', detail: 'Inspect the machine.' },{ error: 'CAPACITY_UNAVAILABLE', startId: 'start', reasons: ['Busy.'] }, { error: 'START_FAILED', startId: 'start', detail: 'Failed.' }]) {diff --git a/cli/src/superTabs/machines.ts b/cli/src/superTabs/machines.tsindex 0b8be8f3c..e6de1d68a 100644--- a/cli/src/superTabs/machines.ts+++ b/cli/src/superTabs/machines.ts@@ -177,6 +177,8 @@ export class ContributedMachines {* last pass found them. Reported so the backend waits past its 3 minutes (backend liveness.ts): Diego's Mac fetched and* checked out a 470 MB project, and the start failed while it did (2026-10-27). */private readonly preparing = new Set<string>()+ /** Starts this host launched whose engine has not yet recorded its session: the agent each created, by start id. */+ private readonly unconfirmed = new Map<string, Unconfirmed>()/** Removals cleaned and acknowledged by this host, and the one in progress per removal. */private readonly cleaned = new Set<string>()private readonly cleaning = new Map<string, Promise<void>>()@@ -333,6 +335,7 @@ export class ContributedMachines {for (const id of this.waiting.keys()) if (!pendingIds.has(id)) this.waiting.delete(id)for (const id of this.refusedSince.keys()) if (!pendingIds.has(id)) this.refusedSince.delete(id)for (const id of this.preparing) if (!pendingIds.has(id)) this.preparing.delete(id)+ for (const [id, launch] of this.unconfirmed) if (!pendingIds.has(id) && !launch.checking) void this.abandoned(id, launch)for (const tab of this.published.keys()) if (!pools.some(row => row.tabId === tab)) this.published.delete(tab)for (const tab of this.lastSent.keys()) if (!pools.some(row => row.tabId === tab)) this.lastSent.delete(tab)for (const tab of this.readingFailures.keys()) if (!pools.some(row => row.tabId === tab)) this.readingFailures.delete(tab)@@ -553,6 +556,10 @@ export class ContributedMachines {// Launched, and its creation still under way on the daemon: anything else is not preparing.if (result.error === 'START_PENDING' && result.state === 'pending') this.preparing.add(String(start.id))else this.preparing.delete(String(start.id))+ // Launched, its engine yet to record its session: if the Swarm fails this start meanwhile, [abandoned] stops it.+ if (result.error === 'START_PENDING' && identifier(result.harnessId) && identifier(result.creationId)) {+ this.unconfirmed.set(String(start.id), { path, harnessId: result.harnessId, creationId: result.creationId, tries: 0, checking: false })+ } else this.unconfirmed.delete(String(start.id))if (!refused) this.refusedSince.delete(start.id)if (result.ok === true && identifier(result.harnessId)) {this.waiting.delete(start.id)@@ -578,6 +585,36 @@ export class ContributedMachines {}} finally { local?.close() }}+ /**+ * A start this host launched, its engine never recording its session, that the backend no longer lists as pending: when+ * the backend says it failed (its machine did not start it within 3 minutes, say) and joined no agent, the agent this+ * host created for it is stopped. Nothing else would: the host no longer sees the start, and the agent is no member of+ * the Swarm. Mac Auto's Harness Team account kept ten such Codex panes idle on 2026-10-29. Only the agent this start's+ * own creation receipt names is closed (core closeMember), never one that joined; a status the backend cannot give now+ * is asked again on later passes, a few times.+ */+ private async abandoned(startId: string, launch: Unconfirmed): Promise<void> {+ launch.checking = true+ try {+ const status = object(await this.deps.backend(this.core, 'GET', launch.path))+ if (identifier(status.harnessId) || !status.error) { this.unconfirmed.delete(startId); return }+ const close = this.core.agents.closeMember+ if (!close) { this.unconfirmed.delete(startId); return }+ const closed = await close(launch.harnessId, launch.creationId)+ if ('closed' in closed && closed.closed) {+ this.unconfirmed.delete(startId)+ this.log(`Stopped the agent a failed start launched (start ${startId}, session ${launch.harnessId.slice(0, 8)}): ${String(status.error)}`)+ return+ }+ // Not this start's own agent, as its receipt says: nothing here to stop.+ if ('error' in closed && closed.error === 'NOT_A_MEMBER') { this.unconfirmed.delete(startId); return }+ throw new Error(`${'error' in closed ? closed.error : 'unknown'}${'detail' in closed && closed.detail ? `: ${closed.detail}` : ''}`)+ } catch (error) {+ if (++launch.tries >= ABANDONED_TRIES) this.unconfirmed.delete(startId)+ this.log(`Could not stop the agent a failed start launched (start ${startId}): ${error instanceof Error ? error.message : String(error)}`)+ } finally { launch.checking = false }+ }+/** Each running session's token counts by model, from the daemon's last usage reading (never a transcript read): the* Swarm prices each attempt by them (backend superTabs/costs). Counts only; the reading's folders and pull requests stay* here. A session with none read yet is left out. */@@ -875,6 +912,11 @@ const GRID_MODELS_MS = 60_000/** Every Swarm's grid, as the backend mints its name: their models belong to their own Swarm. */const SWARM_GRID = /^swarm-[0-9a-f]{12}$/+/** A start this host launched whose engine has not recorded its session yet (ContributedMachines `abandoned`). */+interface Unconfirmed { path: string; harnessId: string; creationId: string; tries: number; checking: boolean }+/** How many passes ask about an abandoned start before it is let go. */+const ABANDONED_TRIES = 5+type LocalModelReading = { grid: string; model: string; name?: string; contextWindow?: number; kind: 'local' | 'api' | 'shared'; starting?: true }/** When this machine's Swarm models last changed, from the files that change with them: the APIs it sharesdiff --git a/cli/src/superTabs/start.spec.ts b/cli/src/superTabs/start.spec.tsindex 6c7d4b4e1..3301bc9ce 100644--- a/cli/src/superTabs/start.spec.ts+++ b/cli/src/superTabs/start.spec.ts@@ -966,7 +966,9 @@ it('records the original launch identity and retries without it only for an oldeit('waits for the initial engine binding before recording a timed launch identity', async () => {const f = fixture({ identity: { sessionId: '', createdAt: '2026-10-22T00:00:00.000Z' } })- expect(await startAgent({ action: 'start', tabId: 'tab', operationId: 'binding-start', request: f.start.request }, f.scoped, where, f.open)).toMatchObject({ error: 'START_PENDING' })+ // It names the agent it launched, which its host stops should the Swarm fail this start meanwhile (machines.ts `abandoned`).+ expect(await startAgent({ action: 'start', tabId: 'tab', operationId: 'binding-start', request: f.start.request }, f.scoped, where, f.open))+ .toMatchObject({ error: 'START_PENDING', creationId: expect.any(String), harnessId: expect.any(String) })expect(f.scoped.mock.calls.map(c => c[0].command as Record<string, unknown>).some(c => c?.type === 'agent.started')).toBe(false)})diff --git a/cli/src/superTabs/start.ts b/cli/src/superTabs/start.tsindex f428d3b3b..37c0a371d 100644--- a/cli/src/superTabs/start.ts+++ b/cli/src/superTabs/start.ts@@ -454,7 +454,9 @@ async function startOnce(input: Json, scoped: ScopedRequest, where: Where, open:const startedSession = typeof frame.sessionId === 'string' && frame.sessionId && typeof frame.createdAt === 'string' && Number.isFinite(Date.parse(frame.createdAt))? { sessionId: frame.sessionId, createdAt: frame.createdAt } : undefined// New native frames have their creation time before the engine binds. Wait for its original session identity.- if (typeof frame.createdAt === 'string' && !startedSession) return { error: 'START_PENDING', startId, creationId,+ // The agent it launched goes with it: should the Swarm fail this start meanwhile, its host stops that agent+ // (superTabs/machines.ts `abandoned`).+ if (typeof frame.createdAt === 'string' && !startedSession) return { error: 'START_PENDING', startId, creationId, harnessId: nativeId,detail: 'Waiting for the launched engine to record its session identity. Resume this same start request.' }const join = { type: 'agent.started', startId, harnessId: nativeId, configuration }let joined: Json = { result: {} }