Repository navigation
Description
Summary
A loop session that hits a permission prompt doesn't fail: it waits until its lease expires, writes nothing, and the sweep then re-fires it into the same wall, up to dispatch.maxAttempts (3). docs/why.md#a-blocked-run-cannot-see-that-it-is-blocked records this as a known gap, and asserts that the routines API reports such a session as worker_status: requires_action within about 90 seconds. The dispatcher never asks.
It has now cost a full lease again. The set build for sydevs/SahajCloud#1078 ran 16:39–22:39Z on 2026-11-16, its whole 360 minutes. It left no branch, no PR, no journal entry, and an unmoved lease.
- Dispatch:
SahajCloud-1078-implement-20261116T163938618Z-b103 - Children: #1168, feat(loop): link preview fixture records, and drop preview sign-in #258
- Session:
cse_01Mg9rjXNTqeCAHtsoP4AK2q
Validated 2026-11-23: this ticket is not ready for implement. Step 1 cannot be done by a loop run, and the request parts 2 and 3 poll with is not settled — no endpoint documented today returns a prompt-waiting status. Both readings are attended work, listed as step 1 and asked as question 1. The measurements behind that are in ## Notes.
Joined: a session that never started is charged an attempt too. When the account hit its usage limit on 2026-11-19/20, every fire still succeeded, but the sessions sat queued for hours. #285's review fired at 09:55Z and began at 15:11Z, past its deadline, so payload.mjs refused it. The sweep counted each such dispatch as timed out and re-fired it into the same queue. Today's journal, #286, holds 36 anomalies, and about a dozen items reached attempts-exhausted with no session having done any work. Both cases come down to one missing check: the sweep reading a session's status before it charges a timeout.
Open questions
- 1. Build the poll on an undocumented field of a research-preview API?
- A — Measure first, then build (recommended): in an attended session, record here the request that returns a session's prompt-waiting state — URL, headers, and a sample body showing the field and its value — and whether
ROUTINE_TOKEN_<REPO>may make it or a new secret is needed. The poll is then built from measured fact. Cost: one attended session. Risk: an undocumented field can change under us, which criterion 5's fallback contains. - B — Build part 3 from timing alone: not viable. The record holds
firedAtand the session id (dispatcher/apply.mjs:589-593), never a start time, so "never started" is not derivable without the same status read. - C — Harden only the first line of defence: extend
start-run's prediction and leave the dispatcher alone. Needs no API and closes nothing — a run that cannot predict its prompt still burns the lease, which is the failure this ticket exists for.
- A — Measure first, then build (recommended): in an attended session, record here the request that returns a session's prompt-waiting state — URL, headers, and a sample body showing the field and its value — and whether
Approach
- Attended: confirm the cause, and settle the request. A loop run can do neither (
## Notes), so this step is a person's, and parts 2 to 4 wait on it.- Read
cse_01Mg9rjXNTqeCAHtsoP4AK2q's log and record here the prompt and the path it named. The cause space is wider than Protected Paths, so do not assume one: a cloud run starts in auto mode, and the routines docs say repeated classifier blocks escalate to a prompt that waits for a person. This ticket had already excluded.claude/workflow.json, the one protected path it would otherwise have touched. A cause other than a prompt still leaves parts 2 and 3 worth building; name the real one here. - Answer question 1 with the request and the token scope.
- Read
- Poll for it. For every item whose
rec.currentcarries a session (dispatcher/apply.mjs:589-593writes it), the sweep (expiredLockTargetsindispatcher/sweep.mjs) reads that session's status.- On a prompt-waiting status:
- Record the dispatch as
outcome: 'blocked on a prompt', nottimed out. - Release the lease and the lock exactly as the timeout path does (
dispatcher/apply.mjs:398-411). - Do not re-fire: the next attempt would stop on the same prompt.
- Hand the item back to a person with one comment naming the session. Where the API returns the session's events, quote the tool and the path that prompted, so a maintainer who cannot open the session still sees why.
- Record the dispatch as
- Any other status, an unexpected response shape, or an API error leaves the item to today's deadline path.
- On a prompt-waiting status:
- A session that never started. In the same poll, when a lock is past its deadline and the session never began work:
- Do not count an attempt, and do not re-fire at once: a new session would queue behind the old one.
- Record
rec.pendingwith reasonthe session never startedand aretryAfterfromdispatch.fireRetry.default429Seconds, as a failed fire does (dispatcher/apply.mjs:599-608), and release the lease and lock. - Where the API allows it, stop the stale session, so it cannot wake later and spend usage refusing an expired payload.
- Post one journal anomaly,
never-started, apart from thetimed-outone atdispatcher/apply.mjs:413-419.
- Count it. The journal tally counts
blocked on a promptapart fromtimed out, and countsnever startedtoo, soimprove-loopcan tell a stall or a queue from a slow run. - Docs. Rewrite
docs/why.md#a-blocked-run-cannot-see-that-it-is-blocked: the gap is closed,start-run's protected-path check stays as the first line of defence, and auto mode's repeated-block escalation is named as the second way in.
Acceptance criteria
- This ticket records the request that returns a session's prompt-waiting state, and whether
ROUTINE_TOKEN_<REPO>may make it. - This ticket records the cause of
cse_01Mg9rjXNTqeCAHtsoP4AK2q's stall, read from the session itself, or says why it stays unread. - A dispatched session waiting on a prompt is reclaimed by the next sweep: lease and lock released, outcome
blocked on a prompt, no re-fire. - The hand-back comment names the session, and the prompting tool and path where the API returns them.
- A session in any other state is untouched, and an API failure or an unexpected response shape falls back to the deadline path.
- A lock past its deadline whose session never started is released to Pending with a retry time, with no attempt counted and no immediate re-fire.
- The journal tally reports prompt-blocked and never-started dispatches separately.
-
docs/why.mddescribes the new behaviour, and names auto mode's repeated-block escalation beside Protected Paths.
Verification checklist
-
node --test dispatcher/test/*.test.mjspasses. - A sweep test with a stubbed prompt-waiting status yields a release and a hand-back comment, and no fire.
- A sweep test with a lock past its deadline and a stubbed not-started status yields a release,
rec.pendingwithretryAfter, the sameattempt, and no fire. - Sweep tests with a stubbed
runningstatus, with a 404 or 500, and with a body missing the status field, each yield no new action. -
claude plugin validate ./workflow --strict && node --test workflow/lib/*.test.mjspasses.
Notes
Prior art: 82b1559 (#108). Six consecutive WeMeditateWeb#97 runs each stalled on a .npmrc write and burned a 150-minute lease. That commit added start-run's protected-path check, which only works when a session predicts the path before writing.
Why step 1 is attended. Measured in this revise run on 2026-11-23:
RemoteTrigger, the tooldocs/routine-setup.md:753names forlist_runs→get_run_log, is absent from a routine session.ToolSearchreturns no routines tool, and no/scheduleskill is loaded. Reading a run's log through/scheduleneeds Claude Code v2.1.227 or later (routines docs); this session reports v2.1.42.- The routines REST API needs
ROUTINE_TOKEN_<REPO>, a GitHub Actions secret. NoROUTINE_TOKEN_*exists in a session's environment, anddispatcher/fire.mjsonly POSTs/fire. - No endpoint documented today returns
worker_statusorrequires_action.GET /v1/sessionsreturnsstatus∈rescheduling | running | idle | terminated, none of which is a prompt-waiting state, and the routines page documents no runs or status endpoint and calls the surface a research preview whose API may change.worker_statusis attested only bydocs/why.mdand by the upstream issue below.
Upstream, not reproduced here: anthropics/claude-code#111791, opened 2026-11-23, reports that cloud routines ignore allowed_tools and that every gh call stops on a permission prompt at worker_status: requires_action. start-run names gh api -X GET search/issues as its search fallback, so if that holds for this account the loop's own sanctioned fallback is a stall source. Against it: gh api repos/sydevs/claude-workflow/issues/268 ran with no prompt in this routine session at 22:45Z, as did the 2026-11-08 re-measurement in docs/why.md#a-routine-cannot-reach-the-github-api. Deliberately not tested further — a gh call that does prompt burns the lease it is testing from, so that experiment is attended.
Stale file:line references in this ticket's earlier Approach, corrected above: the timeout path is dispatcher/apply.mjs:398, not :343, and the retryAfter pending write is :599-608, not :569-572. dispatcher/apply.mjs moved under #299 and #300 after this ticket was filed.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Hold Until
Projects
- StatusShow more project fieldsAwaiting
Activity
Ardnived commentedon Nov 23, 2026
@sydevs-bot revise - validate this ticket by attempting step 1
sydevs-dispatcher commentedon Nov 23, 2026
🤖 no session running
recent dispatches
Written by the sydevs dispatcher. Sessions never edit this comment.
sydevs-bot commentedon Nov 23, 2026
Validated: a loop run cannot do step 1.
RemoteTrigger(list_runs→get_run_log) is absent from a routine session, no/scheduleskill is loaded, and its log read needs Claude Code v2.1.227 — this session is v2.1.42. The routines REST API needsROUTINE_TOKEN_<REPO>, a secret no session holds. So the stall's cause is still unread.Worse for parts 2 and 3: no endpoint documented today returns
worker_statusorrequires_action.GET /v1/sessionsreturnsstatus∈rescheduling|running|idle|terminated. The poll would rest on an undocumented field of a research-preview API, so that is now question 1.Also corrected in the body: the cause space is wider than Protected Paths — auto mode escalates repeated blocks to a waiting prompt — and two
file:linerefs had drifted. The timeout path isapply.mjs:398, the pending write:599-608.Incidental finding filed as #311: ~17 unused MCP servers attach to every dispatch, which
docs/routine-setup.mdsays cannot happen.Answer question 1, then
@sydevs-bot implementstarts the build.🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code