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
fix: prevent restored agents from getting stuck in starting state by checking resume hook requirements
0xken15d86046037e55
diff --git a/cli/src/cli.ts b/cli/src/cli.tsindex 765b7fbfd..9ee39981f 100644--- a/cli/src/cli.ts+++ b/cli/src/cli.ts@@ -87,6 +87,7 @@ import { DEFAULT_HOST_THEME, loadHostTheme, saveHostTheme, type HostTheme } fromimport { createAndRegisterPane } from './lib/createAgentPane.js'import { forkName, planFork } from './lib/forkAgent.js'import { restoreAgents } from './lib/restoreAgents.js'+import { awaitsResumeHook } from './lib/resumeCapability.js'import { createRetainExitedSession } from './lib/retainExitedSession.js'import { repairClaudeCwd } from './lib/cwdRepair.js'import { stoppedAgents } from './lib/stoppedAgents.js'@@ -3114,7 +3115,14 @@ async function runForeground(session: AuthSession | null): Promise<void> {if (observed.dsh && !current.dsh) registry.setDsh(current.agentId, observed.dsh)const withDsh = registry.byAgent(current.agentId)if (withDsh?.dsh) attachDsh(withDsh)- if (wasLaunching && !current.resumeOnly) registry.setLaunch(current.agentId, { state: 'ready' })+ // A strict-resume row waits for the hook that proves the engine reopened THAT conversation —+ // but only where such a hook is coming. For every other engine this live process, in this+ // row's own pane, IS the proof (`resumeCapability.ts`), and refusing to say so left an+ // opencode harness restored after a reboot reading "Starting" while it was working. The Open+ // path already marks those ready itself (`resumeAgentService.ts`); this is the same rule on+ // the door restore comes through.+ const waitingForResumeHook = !!current.resumeOnly && awaitsResumeHook(current.engine, current.sessionId)+ if (wasLaunching && !waitingForResumeHook) registry.setLaunch(current.agentId, { state: 'ready' })await bindObservedAgent(observed)if (wasDormant || wasLaunching || adopted) {const active = registry.byAgent(current.agentId)diff --git a/cli/src/lib/resumeAgentService.ts b/cli/src/lib/resumeAgentService.tsindex b5a07ecca..954b1e2a8 100644--- a/cli/src/lib/resumeAgentService.ts+++ b/cli/src/lib/resumeAgentService.ts@@ -4,7 +4,7 @@ import { installedDsh } from '../dsh/installed.js'import { engineKeepsTranscriptFile, registry as liveRegistry, validTranscriptPath, type RegisteredSession } from './registry.js'import type { StoppedAgentStore } from './stoppedAgents.js'import { resumeStoppedAgent, waitForResumedAgent, resumeChanged, resumeUnconfirmed } from './resumeStoppedAgent.js'-import { confirmsResumeByHook, resumesConversation } from './resumeCapability.js'+import { awaitsResumeHook } from './resumeCapability.js'import { checkPidRuntime } from './deleteAgentFallback.js'import { checkSessionRuntime, clearPaneRemainOnExit, resolvePaneEngineProcess, tmuxPaneState } from './tmux.js'import { listTmuxPanes } from './tmuxAgentDiscovery.js'@@ -66,8 +66,7 @@ export function createResumeAgentService(deps: ResumeAgentServiceDeps) {// discovery out of it (see cli.ts's resumeOnly guard). Same condition as the proof itself in// `waitForResumedAgent`: only a resume that ASKED for a conversation, on an engine that hooks// at launch, is marked ready by `register` instead.- const byHook = resumesConversation(saved.engine, saved.sessionId) && confirmsResumeByHook(saved.engine)- const ready = byHook+ const ready = awaitsResumeHook(saved.engine, saved.sessionId)? result.session: registry.setLaunch(saved.agentId, { state: 'ready' }) ?? result.sessionannounceSession(ready)diff --git a/cli/src/lib/resumeCapability.spec.ts b/cli/src/lib/resumeCapability.spec.tsindex 976c527f0..a73eca238 100644--- a/cli/src/lib/resumeCapability.spec.ts+++ b/cli/src/lib/resumeCapability.spec.ts@@ -1,7 +1,7 @@import { describe, expect, it } from 'vitest'import { ENGINES, type AgentEngine } from '../engines/types.js'import { LAUNCH_RESUME_FLAG } from './engineLaunch.js'-import { confirmsResumeByHook, resumeMode, resumesConversation } from './resumeCapability.js'+import { awaitsResumeHook, confirmsResumeByHook, resumeMode, resumesConversation } from './resumeCapability.js'describe('what a paused harness can promise, per engine', () => {it('gives every engine exactly one mode, from the launch table itself', () => {@@ -40,6 +40,21 @@ describe('what a paused harness can promise, per engine', () => {}})+ it('waits for a resume hook only where one is both asked for and sent', () => {+ // The pair that hooks, with a conversation to confirm: wait for it.+ expect(awaitsResumeHook('claude', 'sess-1')).toBe(true)+ expect(awaitsResumeHook('codex', 'sess-1')).toBe(true)+ // Nothing was asked for, so the id the engine reports is a new one by design.+ expect(awaitsResumeHook('claude', null)).toBe(false)+ expect(awaitsResumeHook('codex', '')).toBe(false)+ // The engine that made this rule worth naming: a restored opencode row waiting for a hook that+ // `--session <id>` never sends read "Starting" while it was working.+ expect(awaitsResumeHook('opencode', 'ses_f333bf6d8ffe')).toBe(false)+ for (const engine of ['kilo', 'copilot', 'pi', 'amp', 'muse', 'hermes', 'grok', 'agy', 'devin', 'terminal'] as AgentEngine[]) {+ expect(awaitsResumeHook(engine, 'sess-1')).toBe(false)+ }+ })+it('covers the whole roster, so a new engine cannot be forgotten', () => {// A new engine gets the weaker proof by default, never a ten-minute wait.const strict = ENGINES.filter(engine => confirmsResumeByHook(engine))diff --git a/cli/src/lib/resumeCapability.ts b/cli/src/lib/resumeCapability.tsindex 5a762a4ed..0425b6910 100644--- a/cli/src/lib/resumeCapability.ts+++ b/cli/src/lib/resumeCapability.ts@@ -57,3 +57,23 @@ export function resumesConversation(engine: AgentEngine, sessionId: string | nulexport function confirmsResumeByHook(engine: AgentEngine): boolean {return engine === 'claude' || engine === 'codex'}++/**+ * Whether a resumed row must WAIT for that hook before anything may call it started.+ *+ * Both halves have to hold: a conversation was actually requested (so there is something for a hook+ * to confirm), and this engine hooks at launch. Where either fails, the engine process alive in the+ * row's own pane is the proof, and whoever observes it says so.+ *+ * The one place this is read from is worth naming, because getting it wrong is invisible until a+ * person is looking at it: a strict-resume row that nobody marks ready stays `launch: starting`,+ * which every surface renders as "Starting" for ever. Measured 2026-09-23 — an opencode harness+ * opened from the catalog, then brought back by the post-reboot restore, sat at "Starting" while its+ * engine was up and typeable, because restore marks every row `starting` and hands the flip to+ * discovery, and discovery refused it for being resume-only. opencode's plugin posts on+ * `session.created`, which relaunching with `--session <id>` never emits, so the hook it was waiting+ * for was never coming.+ */+export function awaitsResumeHook(engine: AgentEngine, sessionId: string | null | undefined): boolean {+ return resumesConversation(engine, sessionId) && confirmsResumeByHook(engine)+}