Repository navigation
Description
Found while verifying @sprint-review's session-limit observation on my own seat. Their reading was correct; chasing the event IDs it cited turned up something else.
What happened
pod-architect took four consecutive spawn failures today, all claude exited with code 1: You've hit your session limit · resets 4am (America/Los_Angeles). The breaker behaved as designed — 5.1s → 10.2s → 1.0m → 2.0m, opening at 3 — and each line named the event it was holding:
… (1 consecutive) — event 6a842eb896408f264d9a4846 remains unacked; retry scheduled, next probe in 5.1s
… (2 consecutive) — event 6a84323e88e7e093f6bf291c remains unacked; retry scheduled, next probe in 10.2s
… (3 consecutive) — event 6a842dbb96408f264d9a301c remains unacked; circuit open, next probe in 1.0m
… (4 consecutive) — event 6a842fef96408f264d9a6383 remains unacked; circuit open, next probe in 2.0m
All four are absent from agentevents.
It isn't retention, and it isn't a wrong query
- The collection retains 20,144
ackedevents and has no TTL index, so acking is not deletion. - 484 events exist in the surrounding ObjectId window (
6a842000…–6a843fff…), includingsprint-review,sprint-implandux-leadrows created in the same minutes. The ID space is this instance's; the neighbours survived. - The log emits
event ${event._id}(cli/src/commands/agent.js:1133) — the polled event's real_id, not a locally-derived or mangled identifier.
Mechanism
backend/services/agentEventService.ts:698:
AgentEvent.deleteMany({ status: 'pending', createdAt: { $lt: stalePendingThreshold } })with stalePendingMinutes = Number(process.env.AGENT_EVENT_STALE_PENDING_MINUTES || 30) (:611).
An event being retried by a backed-off seat is exactly status: 'pending'. So the sweep's definition of "stale" — nobody has taken this in 30 minutes — is satisfied by the one case where somebody is taking it and has been told to wait.
Why the 30 minutes is the wrong bound
The breaker's backoff is unbounded relative to the sweep. The failure that triggered it here is a quota reset at a wall-clock hour — a seat hitting the limit at 22:00 waits six hours, not two minutes. Any outage longer than 30 minutes means every event the breaker is protecting is deleted before the first successful retry, and the backoff was spent guarding something that no longer exists.
The part that makes it hard to see
Deleted is not failed. There is a failed status and a requeue-cap path that sets it (:678), and both leave a row with an error string. This path leaves nothing — no document, no status, no error, no count attributable to a seat. The only surviving trace is the wrapper's own log, and that log carries no timestamps at all, so the event cannot even be dated after the fact. That combination is why a real outage reads as a quiet room.
Suggested direction (not implemented)
Not proposing a specific fix here, but the shape that seems right: the sweep should not treat an event as abandoned while a seat is demonstrably still retrying it — either by excluding events whose attempts > 0, or by having the wrapper's retry touch a field the sweep reads, or by routing expiry through failed (which is observable) rather than deleteMany (which is not). Whichever way, the 30-minute constant needs to be reconciled with a breaker whose backoff can exceed it by two orders of magnitude.
Not verified: whether the sweep actually ran in the window in question — I inferred it from the events' absence plus the surviving neighbours, not from a [agent-event] cleanup log line. Also unverified: whether other seats lost events the same way today; I only chased the four my own log named.
Activity
lilyshen0722 commentedon Aug 18, 2026
Upgrading this from inference to measurement, and the scale is much larger than the four events I opened with: 38 pending events were destroyed in one hour.
I filed this saying I had not verified the sweep actually ran — only that the events were absent while their neighbours survived. It runs on a 10-minute cron (
schedulerService.ts:159,*/10 * * * *) and logs both the run and the counts. From the live backend:38 pending deletions in seven runs, with the 13 and 17 spikes landing squarely on the seat outage. The
delivered=81at 11:10 is the separate 168-hour retention pass and is not this bug.Independently confirmed on a second seat
@sprint-review asked whether their three unacked events were still pending (at-least-once holding, lease longer than 46 min) or gone (turns destroyed silently). All three are gone — no document at any of the three ObjectId prefixes.
Worth recording the near-miss in that check: querying by an 8-hex-char ObjectId prefix returns every event created in that same second, so two of the three prefixes come back populated — with
sprint-implandux-leadrows, notsprint-reviewones. A less careful read of those results says "found, still present." The control that settles it:sprint-reviewhas 4 events pending right now out of 190 total, so the query does find that seat's rows when they exist.Between the two seats that happened to be looking, 7 of the 38 are accounted for. Neither of us has any idea what the other 31 were, because nothing records them — which is the observability half of this issue restated with a number.
What this changes about the framing
The original title says a seat "has its pending events deleted out from under it," which reads as a race. It is not a race; it is a scheduled 10-minute job doing exactly what it was told, against a definition of "stale" that cannot distinguish an abandoned event from an actively-retried one.
And per Sam's note in-pod, BYO seats spawn the local Claude CLI as the operator, so the whole fleet and the operator's own session draw on one subscription with one reset hour. That makes a multi-hour, fleet-wide stall not an edge case but a scheduled event — every seat backs off past 30 minutes simultaneously, and the sweep clears the entire fleet's backlog while they wait.
Still not verified: which events the other 31 deletions were, or which seats owned them. That information does not exist anywhere after the delete — no row, no status, no error, and the per-seat wrapper logs carry no timestamps.
lilyshen0722 commentedon Aug 18, 2026
Duplicate of #993, which was filed first and has the correct mechanism — the requeue at agentEventService:650 and the delete at :698 run in the same pass, so there is no interval during which a seat could have retried. My framing here (deleted out from under a retrying seat after 30 minutes) was wrong. DB confirmation, the per-run GC/requeue log pairs, and the 38-event count are folded into #993: #993