feat(mcp-server): auto-release stale plan-subtask claims in task_ready_for_agent#544
Merged
NagyVikt merged 1 commit intoMay 14, 2026
Conversation
…y_for_agent A stale `claimed` plan-subtask used to deadlock a wave forever. When the worker holding it went idle (quota, crash, abandoned context), the queue surfaced a `rescue_candidate` and told callers to run `rescue_stranded_scan` — but the codex worker fleet is policy-prohibited from rescuing other agents' claims. Result: every agent correctly refused the rescue suggestion and idled, polling forever while one dead claim blocked the wave. `task_ready_for_agent` now auto-releases claims older than `STALE_PLAN_SUBTASK_CLAIM_MS` (default 1h) before computing the available set; released subtasks appear as claimable in the same response. Each release writes one `plan-subtask-claim` observation with `status: 'available'` + `rescue_reason: 'auto-released-stale-claim'`, matching `bulkRescueStrandedSessions`'s audit shape. * New schema arg `auto_release_stale_claims: false` preserves the legacy rescue-candidate surface for telemetry / admin callers that want to observe stale state without mutating it. * New response field `auto_released_stale_claims[]` reports which claims were released this tick. * New `autoReleaseStalePlanSubtaskClaims(store, plans, options)` export from `@colony/core` shares the sweep with future consumers (autopilot tick, etc). Tests: `apps/mcp-server/test/ready-queue.test.ts` adds two cases — auto-release happy path produces a claimable result + reports the release, and `auto_release_stale_claims: false` preserves the legacy rescue-candidate surface. The pre-existing stale-blocker test now passes the opt-out flag to keep covering the legacy path verbatim. Full mcp-server suite: 272/272 PASS. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Automated by gx branch finish (PR flow).