fix: orchestrator deadlock recovery — timeout, rollback, circuit breaker#280
Open
tyxben wants to merge 1 commit intoConway-Research:mainfrom
Open
fix: orchestrator deadlock recovery — timeout, rollback, circuit breaker#280tyxben wants to merge 1 commit intoConway-Research:mainfrom
tyxben wants to merge 1 commit intoConway-Research:mainfrom
Conversation
Fixes Conway-Research#266, Conway-Research#259, Conway-Research#262 — tasks stuck in 'assigned' status blocking all goal creation. Root cause: when a worker dies (sandbox crash, process restart) after task assignment, the task remains in 'assigned' forever because: 1. Recovery only ran when isWorkerAlive callback was available 2. Self-assigned tasks had zero recovery path 3. Funding/messaging failures after assignment left tasks orphaned 4. No escape hatch when all tasks in a goal were stuck Changes: 1. Timeout-based recovery (unconditional): - Track started_at timestamp when assigning tasks - If a task stays in 'assigned' longer than max(task.timeoutMs, 10min), reset to 'pending' regardless of worker liveness - Works even without isWorkerAlive callback 2. Assignment rollback on post-assign failure: - If funding or messaging fails AFTER task is committed as 'assigned', immediately roll back to 'pending' - Previously: task stuck in 'assigned' with worker never notified 3. Self-assignment circuit breaker: - Max 3 self-assigned tasks per goal - Prevents parent agent from being overwhelmed, which starved the orchestrator tick and caused cascading deadlocks 4. Phase escape hatch: - If goal is in 'executing' for >30min with zero completed/failed tasks, force-fail to unblock new goals - Tracks phase entry time in KV store, cleans up on complete/fail All 267 orchestration tests pass, no regressions.
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
Fixes #266, #259, #262 — tasks stuck in
assignedstatus blocking all goal creation.Root cause
When a worker dies (sandbox crash, process restart) after task assignment, the task remains in
assignedforever because:isWorkerAlivecallback was provided (optional)Fix: 4 interlocking mechanisms
1. Timeout-based recovery (unconditional)
started_attimestamp when assigning tasks (was missing)assignedlonger thanmax(task.timeoutMs, 10min), reset topending— regardless of worker livenessisWorkerAlivecallback, catches self-assigned tasks too2. Assignment rollback on post-assign failure
assigned, immediately roll back topendingassignedwith the worker never notified3. Self-assignment circuit breaker
MAX_SELF_ASSIGNED_PER_GOAL)4. Phase escape hatch
executingfor >30min with zero completed/failed tasks, force-fail to unblock new goalsFiles changed
src/orchestration/orchestrator.tssrc/orchestration/task-graph.tsstarted_aton assignmentTest plan
tsc --noEmitpasses