Repository navigation
Conversation
A cron agentTurn queued behind an active turn in a CLI-backed session kept its 60s setup watchdog running and aborted with "isolated agent setup timed out before runner start". Report the local session-lane wait and admission to onLaneWait, matching the embedded runtime, and forward the cron callback on the CLI branch. Closes openclaw#160302
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed September 28, 2026, 9:05 PM ET / September 29, 2026, 01:05 UTC (Revision 3). ClawSweeper reviewWhat this changesCron jobs targeting a busy CLI-backed session now pause the setup watchdog while queued and settle promptly if the run is cancelled. Regression provenancePossible regression — suspected (failure trace). No predecessor PR is attributed. Merge readiness⛔ Blocked before merge - 3 items remain The patch addresses a current cron failure, and the contributor’s Gateway trace shows the queued CLI turn running after its session becomes free. The prior cancellation finding is addressed. A maintainer still needs to accept or change the effect of an unbounded session wait on cron run capacity. Priority: P1 Review scores
Verification
How this fits togetherThe Gateway cron scheduler admits scheduled agent turns and sends them to either the embedded runtime or a CLI backend. A session lane serializes turns for the same conversation before the runner starts and the scheduler records the result. flowchart LR
A[Scheduled agent turn] --> B[Cron run slot]
B --> C{CLI or embedded runtime}
C --> D[Session lane]
D --> E{Wait or admit}
E --> F[Runner and result]
E --> G[Cancellation settles run]
Decision needed
Why: The patch restores parity and prevents lost runs, but its capacity effect can delay unrelated jobs; choosing that scheduler tradeoff requires owner intent. Before merge
Agent review detailsSecurityNone. PR surfaceSource +16, Tests +69. Total +85 across 3 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Preserve the working CLI session-lane behavior, then have the cron owner decide whether queued turns may retain run slots indefinitely or need a shared bounded-wait policy for both runtimes. Do we have a high-confidence way to reproduce the issue? Yes, at the source boundary: current main omits the CLI lane-wait callback, and a queued turn leaves the 60-second setup timer running. The contributor also supplies a before-and-after Gateway trace; this reviewer did not execute it. Is this the best way to solve the issue? Yes, for the reported failure: the patch uses the existing queue and watchdog contracts and adds prompt cancellation. Whether the resulting unbounded slot wait is acceptable remains an explicit scheduler decision. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e1ccea91271f. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
Reporting the session-lane wait pauses the cron setup watchdog, so a queued CLI turn must also be removable: pass the owner abort signal to the session-lane enqueue (as the embedded lane controller already does) so cancelling a cron run settles it even while the active turn never releases the lane.
|
Independently reproduced with an isolated Gateway and a registered mock CLI backend (Node 24.21.0, secretless Docker), using the real 60-second watchdog and an 85-second busy turn in
No overlap with Pash/Sarah changes was found in the three touched files. Thanks to @Oldrich333 for the report and @changeroa for the fix and regression coverage. The existing exact-head ClawSweeper owner-decision hold remains unresolved; no changes were pushed. Cron scheduler owner question: may a CLI cron turn queued behind a busy session retain one of the eight cron run slots indefinitely, matching the embedded runtime, with cancellation as the escape? The relevant capacity owner is |
|
@steipete: handing this off for a cron-owner decision. The proof is in #160804 (comment). ClawSweeper's review of exact head Proof: real Gateways in secretless Docker, with a mock CLI kept busy for 85 s against the real 60 s watchdog.
|
Production data for the cron-owner decision, from the reporter side (#160302).
|
Cancelling CLI work while it waits behind an active session turn previously left the caller blocked until the predecessor finished. Forward the caller's abort signal to the existing command queue so cancellation promptly removes and rejects the queued turn without executing it. Strengthen the existing regression to await rejection before releasing the predecessor. The regression fails before the fix; all 39 focused owner, caller-scope and queue cancellation tests pass afterward. Victor Jaepyo Jo (@changeroa) previously identified the same cancellation defect in #160804, which also contains distinct cron watchdog work. This narrow fix was independently reproduced. Co-authored-by: Victor Jaepyo Jo <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
Cancelling CLI work while it waits behind an active session turn previously left the caller blocked until the predecessor finished. Forward the caller's abort signal to the existing command queue so cancellation promptly removes and rejects the queued turn without executing it. Strengthen the existing regression to await rejection before releasing the predecessor. The regression fails before the fix; all 39 focused owner, caller-scope and queue cancellation tests pass afterward. Victor Jaepyo Jo (@changeroa) previously identified the same cancellation defect in #160804, which also contains distinct cron watchdog work. This narrow fix was independently reproduced. Co-authored-by: Victor Jaepyo Jo <[email protected]> Co-authored-by: Peter Steinberger <[email protected]> (cherry picked from commit 9607478)
Cancelling CLI work while it waits behind an active session turn previously left the caller blocked until the predecessor finished. Forward the caller's abort signal to the existing command queue so cancellation promptly removes and rejects the queued turn without executing it. Strengthen the existing regression to await rejection before releasing the predecessor. The regression fails before the fix; all 39 focused owner, caller-scope and queue cancellation tests pass afterward. Victor Jaepyo Jo (@changeroa) previously identified the same cancellation defect in openclaw#160804, which also contains distinct cron watchdog work. This narrow fix was independently reproduced. Co-authored-by: Victor Jaepyo Jo <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
|
Thanks @changeroa for the fix and queued-cancellation coverage. This has since been addressed on main: #165310 ( I checked the current code path: both CLI and embedded turns now wait through Verified on main |
Closes #160302
Related (same error text, different boundary, not duplicates):
setup timed out before runner startfrom slow preparationWhat Problem This Solves
Fixes: a cron
agentTurnjob aimed at a busy CLI-backed session (for exampleclaude-cliwithsessionTarget: "session:<key>") is aborted withcron: isolated agent setup timed out before runner startwhenever that session's current turn runs longer than 60 seconds. The run is lost, and one-shotatjobs never deliver.User Impact
User impact: cron and follow-up jobs that target a live CLI-backed conversation now wait their turn in the session lane and run when the active turn finishes. The embedded runtime already behaves this way. Cancelling such a queued job (for example
openclaw automations rm) still settles it right away, even while the session stays busy.Important
Maintainer decision requested: should a queued CLI cron turn keep its cron run slot while it waits for a busy session?
With this PR, a cron turn queued behind a busy CLI session keeps its cron run slot (
DEFAULT_CRON_MAX_CONCURRENT_RUNS) for as long as the session's active turn runs. Operator cancellation (openclaw automations rm) is the only thing that bounds that wait, and after the second commit it settles immediately.Facts that bear on the decision:
onLaneWait(src/cron/isolated-agent/run-executor.ts, embeddedrunEmbeddedAgentcall), the lane controller reportswaiting: true, and the setup watchdog pauses. The session-lanetaskTimeoutMsclock only starts when the task starts (src/process/command-queue.ts,startedAtMs), so an embedded cron turn queued behind a busy session also waits without a bound while holding its slot. This PR doesn't add a new availability class; it removes a CLI-only 60 s abort.Options:
I'm happy to adjust this PR (or open the follow-up) based on the decision.
Why This Change Was Made
The cron setup watchdog (
CRON_AGENT_SETUP_WATCHDOG_MS = 60_000) pauses while a run waits for its session lane:onLaneWait({ waiting: true })stops the setup timer, and{ waiting: false }restarts it. The embedded runtime reports those transitions. The direct CLI path didn't:withLocalSessionPlacementTurnSettlementqueued the CLI turn onsession:<key>but reported onlyonQueued(capacity wait), notonLaneWait.params.onLaneWaitinto it.The PR has two commits:
fix(cron): report CLI session-lane waits to the setup watchdogwaiting: truewhen the CLI turn is actually queued andwaiting: falseright before it runs, the same contract the embedded lane controller uses. Also forwardonLaneWaiton the cron CLI branch.fix(cron): cancel a queued CLI turn when its owner abortsabortSignalis now passed to the session-lane enqueue (the embedded lane controller already does this). Cancelling the cron run removes the queued entry and settles the run immediately, instead of waiting for a predecessor that may never finish. This addresses the ClawSweeper P2 finding.run-executor.tssits exactly at its grandfathered line cap, so the one forwarding line is offset by inlining the single-usecliAbortSignalalias (deferredLifecycle.signalis a fixed property). There is no behavior change from that inline. The watchdog itself is unchanged.Evidence
1. Live Gateway run with a real CLI backend (before → after)
Setup. An isolated
OPENCLAW_STATE_DIRGateway runs a tiny local CLI backend plugin (fakecli, registered throughapi.registerCliBackend,output: "text",input: "stdin"). Its script sleeps 80 s when the prompt containsHOLD-SESSIONand otherwise replies immediately. The run reportsrunner: "cli",provider: "fakecli".Scenario A: cron into a busy CLI session. Session
agent:main:proofruns an 80 s turn. Six seconds later:main@ ad76695)status: error,completionStatus: failederror: "cron: isolated agent setup timed out before runner start"after 59 997 ms. The Gateway log showslane wait exceeded … waitedMs=72156 activeAhead=1, thenlane task error … durationMs=1. The cron turn never started.status: ok,completionStatus: succeededdurationMs: 70805, well past the 60 s setup watchdog.Scenario B: cancel a queued cron turn while the session stays busy (this PR). Session
agent:main:proof2runs an 80 s turn. A cron job is queued behind it, and after about 15 s it is removed:The run settled 15 ms after
automations rm, while the busy turn was still running (it finished at 00:21:25). The fake CLI log shows the cancelled cron turn never executed, not even after the lane freed up.Fake CLI backend used for the proof
2. Regression tests
src/agents/session-placement-admission.test.ts:waiting → admitted → taskbehind an occupied laneexpected [] to deeply equal [ 'waiting' ]expected 'pending' to be Error: cron run cancelled while queued✅ 33 passed (33) plus the watchdog suite's 13 passed (13). The existing
timer.timeout-watchdog.test.tsalready proves thatonLaneWait({ waiting: true/false })pauses and restarts the setup watchdog.3. Checks
node scripts/check-changed.mjson this head: typecheck core + core tests, format, line-cap / max-lines / assertion ratchets, dead-export scan, and boundary checks all pass. The first run flagged oneno-promise-executor-returnlint in the new test, fixed intest(cron): keep the queued-abort test promise executor lint-clean. oxlint and oxfmt on the changed files are clean.pnpm test src/agents/session-placement-admission.test.ts --maxWorkers=1takes 45 s wall with a cold transform cache (Vitest 41.8 s, 95% transform). The two new cases take about 1 ms each.scoped-clean.