Skip to content

feat(mcp-server): auto-release stale plan-subtask claims in task_ready_for_agent#544

Merged
NagyVikt merged 1 commit into
mainfrom
agent/claude/auto-release-stale-plan-subtask-claims-i-2026-05-14-23-19
May 14, 2026
Merged

feat(mcp-server): auto-release stale plan-subtask claims in task_ready_for_agent#544
NagyVikt merged 1 commit into
mainfrom
agent/claude/auto-release-stale-plan-subtask-claims-i-2026-05-14-23-19

Conversation

@NagyVikt
Copy link
Copy Markdown
Collaborator

Automated by gx branch finish (PR flow).

…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>
@NagyVikt NagyVikt merged commit 819660d into main May 14, 2026
@NagyVikt NagyVikt deleted the agent/claude/auto-release-stale-plan-subtask-claims-i-2026-05-14-23-19 branch May 14, 2026 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant