Repository navigation
fix(cron): avoid delaying condition checks when capacity frees up - #197099
Conversation
A condition check that found all three evaluations busy was turned away and retried on the 30s-to-5min admission backoff, even when a slot freed at once, and a quiet (fire: false) success left the waiting episode and its retry count in place. - The run queue admits at most three runs that are still evaluating a condition. Further checks stay queued in due-time order with no running marker, so they hold no run slot, spend no run budget and keep their occurrence across a restart. The evaluator's own cap and its busy result are gone. - A fired condition stops counting as a check, so the next one starts while the payload runs. - A quiet check ends the waiting episode, like a payload run does. - While any job has a condition, scheduled runs without one leave one run slot free. - A queued timed occurrence survives a graceful shutdown: the host drain no longer activates timed work while the Gateway drains, service stop leaves it in the durable queue, and an activated launch the stopping host refuses is released for the next process instead of skipped. Refs openclaw#196859
|
🦞👀 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: needs real behavior proof before merge. What this changesThis PR queues excess condition checks, clears waiting state after quiet success, and parks timed conversation continuations without occupying execution capacity. Example: Fourteen conditional automations share a five-minute schedule and each check takes five seconds.
Review scores
ProductKind: Bug fix · Worth it: Needs a maintainer decision · Fix scope: Partial Merge readiness⛔ Blocked before merge - 2 items remain Keep open: this PR addresses a current scheduler defect with useful unique work; no discrete introduced bug was found, but the admission-policy change needs owner judgment. Priority: P1 Decision needed
Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherThe Gateway scheduler submits due occurrences to the durable cron worker, which controls admission and receipts; the host evaluates conditions, executes fired payloads, and finalizes results. flowchart TD
A[Due automation] --> B[Durable run queue]
C[Conversation readiness] --> B
B --> D[Condition evaluation]
D --> E[Payload execution]
D --> F[Result finalization]
E --> F
F --> B
Technical reviewBest possible solution: Use the existing durable queue to serve condition checks in due order, retaining bounded execution and truthful waiting-state cleanup. Do we have a high-confidence way to reproduce the issue? Current-main source establishes capacity refusal and retained waiting state, supported by the contributor's scheduled-Gateway comparison; this review ran no target code. Is this the best way to solve the issue? Moving admission into the existing queue fixes the refusal mechanism without a second scheduler, and the added tests cover distinct ordering, recovery, and conversation-wait boundaries. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against ba052b7ed712. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +173, Tests +138, Docs +6, Other +5. Total +322 across 28 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed November 11, 2026, 7:34 PM ET / November 12, 2026, 00:34 UTC (Revision 2). |
A job that runs inside the conversation that created it waits for that conversation to be idle before it starts. The queue activated it first, so the wait held a run slot and, for a watcher, one of the three condition checks: three watchers behind one long turn stopped every other check until the turn ended. - The host tells the queue which jobs continue a conversation that is busy. Their timed occurrences stay queued, the way runs whose agent is still preparing do, and the host drains again when the conversation goes idle. A waiting occurrence therefore shows as queued, not running, and a schedule change cancels it like any queued run. - Requested and event runs keep their activation before the wait, and a turn that starts between the drain and the launch is still waited out at launch. - Scheduled runs without a condition can use all eight run slots; the slot held back for checks is removed. Refs openclaw#196859
The evaluator no longer returns a busy result, so nothing sets triggerEval.busy. Remove the field, its three readers and the tests that set it by hand.
6c70f95 to
fb02b12
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
openclaw#197099 landed this branch's first three commits on main as one squash, so the resolution keeps main's version of them and reapplies only 'fix(cron): keep condition checks off the run slots' on top.
…enclaw#197099) * fix(cron): queue condition checks instead of backing them off A condition check that found all three evaluations busy was turned away and retried on the 30s-to-5min admission backoff, even when a slot freed at once, and a quiet (fire: false) success left the waiting episode and its retry count in place. - The run queue admits at most three runs that are still evaluating a condition. Further checks stay queued in due-time order with no running marker, so they hold no run slot, spend no run budget and keep their occurrence across a restart. The evaluator's own cap and its busy result are gone. - A fired condition stops counting as a check, so the next one starts while the payload runs. - A quiet check ends the waiting episode, like a payload run does. - While any job has a condition, scheduled runs without one leave one run slot free. - A queued timed occurrence survives a graceful shutdown: the host drain no longer activates timed work while the Gateway drains, service stop leaves it in the durable queue, and an activated launch the stopping host refuses is released for the next process instead of skipped. Refs openclaw#196859 * fix(cron): keep checks running while a job waits for its conversation A job that runs inside the conversation that created it waits for that conversation to be idle before it starts. The queue activated it first, so the wait held a run slot and, for a watcher, one of the three condition checks: three watchers behind one long turn stopped every other check until the turn ended. - The host tells the queue which jobs continue a conversation that is busy. Their timed occurrences stay queued, the way runs whose agent is still preparing do, and the host drains again when the conversation goes idle. A waiting occurrence therefore shows as queued, not running, and a schedule change cancels it like any queued run. - Requested and event runs keep their activation before the wait, and a turn that starts between the drain and the launch is still waited out at launch. - Scheduled runs without a condition can use all eight run slots; the slot held back for checks is removed. Refs openclaw#196859 * refactor(cron): drop the unused busy trigger evaluation flag The evaluator no longer returns a busy result, so nothing sets triggerEval.busy. Remove the field, its three readers and the tests that set it by hand.
Related: #196859
What Problem This Solves
Fixes: five-minute conditional automations go more than an hour without being checked when more than three of them are due at the same moment.
A check that finds all three evaluations busy is turned away and retried after 30 seconds, doubling up to five minutes. A check that finds nothing new never resets that retry count, so after a few busy moments every retry is five minutes long. Five minutes is also the schedule, so the retry arrives a fraction of a second after the next round of on-time checks has taken the three evaluations, and it is turned away again, round after round. The automation also keeps showing an old "waiting" warning after it has been checked successfully.
User Impact
session:<key>) waits until that conversation is idle, as it does today. While it waits it stays queued and uses neither a run slot nor one of the three evaluations, so it cannot hold up other automations. Two visible differences follow: the job shows as queued rather than running during that wait, and a schedule change made meanwhile cancels the waiting occurrence, as for any queued run. If the conversation starts another turn straight away, the occurrence keeps waiting until the conversation is idle.Still open in #196859 and not addressed here: when all eight run slots are busy with long work, checks wait until one ends; a watcher inside a busy conversation is not checked until that conversation is idle; the Automations page does not show when a check last ran.
Why This Change Was Made
The limit of three simultaneous condition checks moves from the evaluator, which could only refuse, into the durable run queue, which can make a check wait its turn. Checks beyond three stay queued with no running marker, so they hold no run slot, spend no time budget and keep their occurrence across a restart. A condition that fires stops counting as a check, so the next one starts while the payload runs.
A timed occurrence that has to wait for its conversation is left in the queue the same way the queue already leaves runs whose agent is still preparing, and the Gateway drains the queue again when the conversation goes idle. Without this, three watchers waiting behind one long turn would hold all three evaluations and stop every other check.
Accepted edges: runs started by hand or by an event take their slot before waiting for their conversation, as they do today, because an event's source needs its transfer acknowledged at once and only timed occurrences are recovered from the queue after a restart. A conversation turn that starts in the instant between the queue handing out a run and that run starting is waited out with the slot held.
Evidence
Live Gateway, 14 watchers on one five-minute schedule, 125 minutes. Isolated Gateways in a macOS VM, driven by the reproduction script from #196859 extended to run longer; no model, no channels. The branch build is this PR's first commit,
d89ef4e; the second commit does not change how watchers outside a conversation are queued.e9fcf00e9fcf00On the base, ten watchers (1.2 s) and eleven watchers (5 s) went more than an hour without a check, and all fourteen jobs ended the run holding a waiting record. On this branch every watcher completed 25 or 26 checks, the last of the fourteen started 21.5 seconds after each tick, and no job held a waiting record at the end.
Tests (targeted, not the full suite): 162 passed in 10 cron test files, none skipped. They include:
expected [] to deeply equal ['free']) and passes with this change; it runs in under 0.1 s;Formatting, lint, both typechecks (core and cron tests), docs formatting, the test-line budget and
git diff --checkpass.Test-line allocation:
config/test-lines-allocations/196859-condition-check-queue.txtrecords 138 lines, the exact net growth. The busy-conversation and shutdown regressions need the real scheduler and queue together, which no existing smaller test exercises.Not tested: the conversation wait on a live Gateway with a real conversation (covered by the scheduler test only). A fired payload handing its check to the next watcher on a live Gateway. A hard kill while checks are queued. An upgrade from the latest stable release with existing automations; the only new stored field is the optional
conditionCheckReceiptIdin a job's state, absent on existing rows.