From 318240729eb3f50e09c341dda55581dd9d8fcf2c Mon Sep 17 00:00:00 2001 From: John Fawcett Date: Sat, 4 Apr 2026 15:01:29 +0000 Subject: [PATCH 1/2] fix(gastown): rollback agent to idle on dispatch container start failure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When dispatch_agent's async side effect fails (container start fails), the agent was left in 'working' status with no container running, creating a 90-second dead zone until heartbeat timeout detection. Now the .catch() handler rolls the agent back to 'idle' so the reconciler can retry dispatch on the next tick, per spec §5.4. --- cloudflare-gastown/src/dos/town/actions.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cloudflare-gastown/src/dos/town/actions.ts b/cloudflare-gastown/src/dos/town/actions.ts index 5b0a45779..940991be6 100644 --- a/cloudflare-gastown/src/dos/town/actions.ts +++ b/cloudflare-gastown/src/dos/town/actions.ts @@ -558,15 +558,15 @@ export function applyAction(ctx: ApplyActionContext, action: Action): (() => Pro const capturedAgentId = agentId; return async () => { - // Best-effort dispatch. If it fails, the agent stays 'working' - // and the bead stays 'in_progress'. The reconciler detects the - // mismatch on the next tick (idle agent hooked to in_progress - // bead) and retries dispatch. + // Best-effort dispatch. If the container start fails, roll the + // agent back to 'idle' so the reconciler can retry on the next + // tick. The bead stays 'in_progress' — no transition needed. await ctx.dispatchAgent(capturedAgentId, beadId, rigId).catch(err => { console.warn( - `${LOG} dispatch_agent: container start failed for agent=${capturedAgentId} bead=${beadId}`, + `${LOG} dispatch_agent: container start failed for agent=${capturedAgentId} bead=${beadId}, rolling back to idle`, err ); + agentOps.updateAgentStatus(sql, capturedAgentId, 'idle'); }); }; } From dd0ee041513699f4cc31a37b2f29d80034d10503 Mon Sep 17 00:00:00 2001 From: John Fawcett Date: Sat, 4 Apr 2026 15:08:08 +0000 Subject: [PATCH 2/2] WIP: container eviction save