fix(gastown): rollback agent to idle on dispatch container start failure#2000
Closed
Conversation
added 2 commits
April 4, 2026 15:01
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.
| // 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 => { |
Contributor
There was a problem hiding this comment.
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.
Contributor
Code Review SummaryStatus: 1 Issues Found | Recommendation: Address before merge Overview
Fix these issues in Kilo Cloud Issue Details (click to expand)WARNING
Other Observations (not in diff)N/A Files Reviewed (1 files)
Reviewed by gpt-5.4-20260305 · 284,225 tokens |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When
dispatch_agent's async side effect fails (container start fails), the agent was left inworkingstatus with no container running, creating a 90-second dead zone until heartbeat timeout detection kicked in.Now the
.catch()handler in thedispatch_agentaction rolls the agent back toidleviaagentOps.updateAgentStatus()so the reconciler can retry dispatch on the next tick, per spec §5.4. The bead staysin_progress— no transition needed.rolling back to idleto the warning log message for observabilityVerification
.catch()is safe — it's part of the promise chain awaited byPromise.allSettledin Phase 2 of the alarm loopVisual Changes
N/A
Reviewer Notes
in_progressbead. The reconciler handles this state:reconcileBeadswill see an unassignedin_progressbead with an idle agent and re-dispatch.