Repository navigation
Description
Summary
Phase 2 of #1081 specifies a lease-renewal heartbeat:
Lease renewal: a worker heartbeat renews
lease_expires_atfor legitimately long turns (reuse the #307 heartbeat path) so they're never reaped out from under themselves.
It was never built. lease_expires_at is written exactly once, at claim (db/schedules/queue.py:136), and thereafter only ever set to NULL on re-queue or park. There is no renew endpoint, no renewal call in the agent's pull worker, and no code path anywhere that extends a live lease.
The reaper, correspondingly, does no liveness check. Its own docstring says it recovers a row when the worker "dies or hangs" (lease_reaper_service.py) — it cannot distinguish a dead worker from a turn that is still running.
Consequence
A turn that outlives timeout_seconds + SLOT_TTL_BUFFER is re-queued and re-claimed while the original is still executing. That is not recovery — it is two workers running the same execution_id concurrently, which is the one thing the design is explicit that re-delivery must never cause.
Three things fall out:
- It is precisely the condition feat(pull): platform-injected execution id for the side-effect guard — Tier-6 T6.3, blocks default-ON for side-effect agents #2392 exists for. Re-delivery deliberately preserves the
execution_idsoeffect_guardcan de-duplicate; that guarantee assumes the two attempts are sequential. Two concurrent attempts can interleave either side of the guard's claim. - The overbooking meter cannot see it. M3 measures peak concurrent distinct
claimed_by_worker, and both attempts are legitimately claimed — so a reaper-induced double-run reads as normal occupancy, not as a breach. - The agent-side cap is not a backstop. The worker pool bounds how many claims an agent holds; it does not prevent the same execution being claimed twice, once by each of two workers.
How reachable is it
Narrow today, but not theoretical. The worker enforces its own turn timeout at timeout_seconds, 300s inside the lease, so the gap only opens when that enforcement itself fails — a turn that hangs past its own kill. That is exactly the stuck-reader / leaked-thread family this codebase keeps producing (#728, #1502, #1661, #2398, #2455), and #2398 wedged an agent on eu2 for ~22 hours as recently as 2026-09-10.
It is also about to get much wider. Per the decision on #1989 (2026-09-16) the durable queue carries all traffic and the push path is deleted, so this stops being a property of a three-agent pilot and becomes a property of every execution on every agent.
Scope
- Clamp the turn limit at claim.
claim_next_tasksizes the lease from the agent'sexecution_timeout_secondsand caps the turn limit (task_overrides.timeout_seconds) at the same value (absent → that value), so a healthy turn always ends inside its lease. - No lease-renewal heartbeat. With the clamp it has nothing to do for a healthy turn, and for a hung turn it would keep the lease alive forever.
TARGET_ARCHITECTURE.md§Recovery andMESSAGE_ENVELOPE_SCHEMA.md§3.5 / OPEN-4 say so. - Name the shortened limit. When the clamp shortens a limit, log it; if the turn then times out, the failure text says the limit was shortened, so the operator knows which setting to change.
- Reaper docstring states the assumption: an expired lease means the worker died or its own kill failed. Only workers in the same agent container can re-claim, so a frozen agent-server claims nothing.
Acceptance criteria
- A queued job whose timeout exceeds the agent's (agent timeout lowered while it waited) is handed a turn limit no greater than the agent timeout — tested
- A job with no recorded timeout is handed the agent timeout, not the worker's 900s default — tested
- The turn limit plus
SLOT_TTL_BUFFERfits inside the lease — tested - A timeout failure on a clamped job names the shortened limit, and a failure computing that note never blocks the terminal write — tested
- The reaper docstring,
TARGET_ARCHITECTURE.mdandMESSAGE_ENVELOPE_SCHEMA.mdagree with the code (no heartbeat)
Notes
- Parent: feat: pull / work-stealing coordination (push→pull dispatch) #1081 (Phase 2 scope item, never implemented). Found during the Production soak-test of pull/work-stealing coordination (#1081) before default-on #1766 soak.
- Related: feat(pull): platform-injected execution id for the side-effect guard — Tier-6 T6.3, blocks default-ON for side-effect agents #2392 (the guard whose sequential-attempt assumption this breaks), docs(testing): close the measurement traps in the #1766 soak set before the flip #2124 / instance-monitor#13 (M3, which cannot detect it).
- Operational note for whoever tests this: on
eu2the pilot leases aretimeout + 300s, so 3000s or 3900s depending on the agent — a repro needs a turn that hangs past its own timeout, not merely a long one.
Activity
obasilakis commentedon Sep 21, 2026
/claim
github-actions commentedon Sep 21, 2026
Claimed by @obasilakis. Label
status-in-progressadded.Next steps:
feature/2846-<short-slug>Fixes #2846fix(pull): state facts in the timeout note; scope the reaper assumpti…
fix(pull): clamp the turn limit at claim so a healthy turn never outl…
fix(pull): clamp the turn limit before composing the pulled prompt (#…
fix(pull): a pulled turn's prompt states the timeout it actually runs…