Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions cloudflare-gastown/src/dos/town/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: This only rolls back rejected dispatches

ctx.dispatchAgent() resolves false for normal startup failure paths in scheduling.dispatchAgent() (for example when startAgentInContainer() returns false or the rig lookup fails). In those cases this .catch() never runs, so the agent still stays working and the 90-second dead zone remains. Handle a falsy return here as well if the goal is to roll the agent back to idle on failed container starts.

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');
});
};
}
Expand Down