Repository navigation
fix(cron): delegated blocked runs report ok and silent blocked jobs get auto-disabled - #162686
Conversation
|
🦞👀 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. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Codex review: needs maintainer review before merge. Reviewed October 1, 2026, 12:49 PM ET / 16:49 UTC (Revision 7). ClawSweeper reviewWhat this changesThe PR records delegated automation failure reports as errors, retains failed silent-run transcripts, and prevents silent agent-reported failures from automatically disabling recurring jobs while preserving error backoff. Merge readiness✅ Ready for maintainer review This PR remains necessary: current main lacks these follow-up fixes. The previous findings are resolved, real behavior proof covers the changed paths, and the draft blocker is cleared. No actionable correctness findings remain. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw’s automation scheduler runs scheduled agent tasks and settles delegated work before recording the outcome. That outcome controls run history, delivery, error backoff, and automatic job disablement. flowchart TD
A[Scheduled agent task] --> B[Parent or settled child answer]
B --> C[Classify failure report]
C --> D[Run history and transcript retention]
C --> E[Configured delivery]
C --> F[Scheduler failure policy]
F --> G[Backoff or automatic disablement]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +29, Tests +99, Docs 0. Total +128 across 11 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Automation history should reflect the work’s final outcome, while notification-free recurring jobs remain quiet and bounded by scheduler backoff. Do we have a high-confidence way to reproduce the issue? Yes. Current-main source supports delegated AUTOMATION_FAILED answers being adopted without classification and silent recurring errors reaching the ordinary disable cutoff; the supplied before/after runtime observations exercise both mechanisms. This review did not execute target code. Is this the best way to solve the issue? Yes. Reusing the existing report parser and retaining the error counter fixes the outcome boundary without duplicating policy or freezing backoff; the earlier retention and documentation gaps are resolved. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against c66d7fbc08ac. 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
HistoryReview history (6 earlier review cycles)
|
|
Owner decision on the startup-replay item: leaving it as is, with no run-history schema change. It needs a crash between the run-history write and the job-state save, which is rare, and the worst case is that an already-failing silent job gets auto-disabled. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
0530dc9 to
ee6d9e0
Compare
…cked runs out of the auto-disable streak
8e15da1 to
bfe1f0f
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…lent auto-disable exception
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Landed as 2f4d475 after the full landing checklist on the exact head 8b77715: adversarial review LAND, ClawSweeper ready, live Telegram before/after proof (a delegated child's AUTOMATION_FAILED is classified and never shown as a raw token; a silent job reporting failures keeps escalating backoff and is not auto-disabled, with zero chat messages), full CI green, bounded cost, one fewer message. |
…et auto-disabled (openclaw#162686) Related: openclaw#162391 ## What Problem This Solves Fixes two follow-ups to openclaw#162391: - A scheduled run that hands its work to a subagent can deliver the child's `AUTOMATION_FAILED` reply verbatim and still record the run as `ok`. This happens on announce jobs, and on `delivery: none` jobs since openclaw#162474 started recording the child's answer. - A silent (`delivery: none`) job whose agent keeps reporting a blocked task gets auto-disabled after 10 runs, and that posts an auto-disable notice even though the job has nowhere to notify. ## User Impact - When a delegated run's settled child answer starts with `AUTOMATION_FAILED`, the run is recorded as an error with the child's explanation. Announce and current-session delivery send only the explanation, never the token. `delivery: none` runs record it without sending anything, and keep the run transcript as other failed executions do. - A `delivery: none` job with no failure-alert route still records agent-reported failures in run history, job status, and error backoff (escalating to hourly, like any failing job). Those failures never auto-disable the job or post the auto-disable notice, so the job stays silent. - Unchanged: - Runtime errors on silent jobs still auto-disable at 10 as before. - Announce and webhook jobs, and jobs with a configured failure route, still auto-disable on agent-reported failures. - `NO_REPLY` behavior. ## Why This Change Was Made - **Settled child answers.** openclaw#162391 classified the token in `resolveCronPayloadOutcome`, which runs on the parent's reply before openclaw#117308's descendant settlement. Two places in `dispatchCronDelivery` then adopt the settled child's reply as the run's answer: the announce settlement (openclaw#117308) and the no-delivery settlement (openclaw#162474). Neither classified it. Both now go through one adoption helper that calls the shared parser `readAutomationFailedReport`, so the run's effective terminal answer is classified after settlement. `buildDeliveryState` derives one execution-failed flag from that result and uses it for both the completion status and the transcript-cleanup decision, so a failed no-delivery run is no longer cleaned up as a quiet success. `run-finalize` consumes the result the same way it already handles `pendingPresentationWarningError`: error status, permanent classification, explanation as the summary. - **Auto-disable.** Maintainer decision: an agent-reported blocked outcome on a job with no notification owner must not lead to auto-disable. The permanent error classification now carries `reportedByAgent`. `applyJobResult` in `timer-outcomes.ts` still counts every error in `consecutiveErrors`, so status and error backoff are unchanged. It skips only the auto-disable decision, and only when all of these hold: the failure was agent-reported, `resolveFailureAlert` finds no route, and the delivery mode is `none` (webhook jobs still auto-disable). - Hermes handles the same protocol the same way (`[CRON_FAILURE]`): its cron hint asks the agent to report a delegated child's failure on the first line. No new tool is needed. ## Bounded cost - No new turns, runs, waits, or notifications. Parsing happens once per settled answer inside the existing finalization. - Agent-reported failures stay permanent, so the scheduler never retries them early. - A silent blocked job keeps the normal error backoff (30 s, 1 min, 5 min, 15 min, then hourly), so it can never run more often than an identical job on origin/main. The only difference is that it keeps running at that backed-off cadence after the 10th failure instead of being disabled. ## Evidence ### Live model, Telegram Test Server (`telegram-e2e-userbot`, DM) Setup: the repo runner unchanged (`run-mock-sut-user-e2e.mjs --backend mock --source-gateway --dm`, Convex lease). `E2E_MOCK_SERVER_PATH` points to a throwaway proxy that stands in for the mock provider and forwards every request unchanged to the real OpenAI API. The proxy reads the key from a private file, so the Gateway only ever holds the runner's dummy key. `E2E_ROOT_CONFIG_PATCH` selects `openai/gpt-6-astra` (`tools.toolSearch: false`). A scenario `command` step creates the jobs with `openclaw automations add` and runs them. No model output was steered: the live parent chose `sessions_spawn`, and the live child and the live silent job wrote their own `AUTOMATION_FAILED` reports because they had no shell tool. The only steer is timing in case (b): before each run, `cron.update` sets `nextRunAtMs` to now and moves `lastRunAtMs` back 2 h, so the error backoff (up to 1 h) counts as served. The Gateway's own scheduler then runs the job as a normal scheduled (not forced) run. Before = origin/main `88f22a318b4`, plus this PR's exact base `2ae97b30828` for case (a). After = this head `8b77715ba4f`, with all three cases in one Gateway run. **(a) Announce job, live parent delegates to one child, the child reports `AUTOMATION_FAILED`** - before (`88f22a318b4`): `cron run --wait` took 99.4 s. Run `ok`, `completionStatus: succeeded`, `deliveryStatus: delivered`. The DM received bot message 43601: `AUTOMATION_FAILED` / `The command could not run because no shell execution tool is available in this session.` The token is visible. - before (`2ae97b30828`, the PR base): 80.7 s. Same result: run `ok`, `delivered`, and bot message 43705 reads `AUTOMATION_FAILED` / `The command could not run because no shell execution tool is available in this session.` - after: 63.5 s. Run `error`, `completionStatus: failed`, `deliveryStatus: delivered`. Error and summary are both the explanation. The DM received bot message 43712 with only `The command could not run because no shell execution tool is available in this session.` No token. - Pre-existing flake, not in this diff: on both sides, the announce settlement sometimes ends with `cron child-session handoff completed without a final assistant payload` even though the live child answered. That happened on 1 of 3 origin/main-side attempts (a second `88f22a318b4` run) and on 2 of 4 attempts on this branch (both on `bfe1f0f2169`). In those cases nothing reaches the chat. The PR's change only runs after a reply has been read, so it is not involved. The no-delivery path (case c) settled on every attempt. **(c) Same delegated job with `delivery: none` (the openclaw#162474 path)** - before: 55.2 s. Run `ok`, `succeeded`, `deliveryStatus: not-requested`, summary `AUTOMATION_FAILED ⏎ The command could not run because no shell execution tool is available in this session.` The token is recorded as an ok answer. - after: 36.3 s. Run `error`, `failed`, `not-requested`. Error and summary are both `The command could not run because no shell execution tool is available in this session.` The job stays enabled. No chat message. **(b) `delivery: none` job, no failure-alert route, the live model reports `AUTOMATION_FAILED` on every run (11 scheduled runs)** - before: runs 1–10 were all `error` (`Could not run \`node scripts/ledger-sync.mjs\`: this session only provides a file-reading tool…`), with `consecutiveErrors` 1…10. After run 10 the job was `enabled: false` with `autoDisabled: {reason: "consecutive-failures", consecutiveErrors: 10}`, so run 11 never happened. The DM received bot message 43644 (heartbeat relay): `⚠️ Your "Nightly ledger sync" automation was automatically disabled after 10 consecutive failures. … openclaw automations enable <id>`. 10 runs took 504 s. - after: all 11 runs were `error` with the same explanation, and `consecutiveErrors` went 1…11, which keeps feeding backoff. After run 11 the job was still `enabled: true` with no `autoDisabled`. History shows 11 `error` entries. Across the whole run, the DM received exactly one bot message: 43712 from case (a). Cases (c) and (b) sent none, including during a 120 s wait after the loop. 11 runs took 526 s. Provider evidence (proxy log): before had 1 parent `sessions_spawn` turn, 1 child turn, 10 silent-job turns, and 1 relay turn carrying the auto-disable notice. After had 2 parent `sessions_spawn` turns, 2 child turns, 11 silent-job turns, no auto-disable relay turn, and only one routine heartbeat poll, which answered `NO_REPLY`. Environment note: in `--source-gateway` mode on both refs, Telegram inbound polling could not start (the ingress worker's plugin capture has no `dist/plugin-sdk`). So the opening DM turn was not processed, and the jobs are owned by `agent:main:main`, the DM's owner session under the default `dmScope`. Outbound delivery and relays reached the DM normally. This is the same for before and after. ### Tests Each new test fails on the code it fixes and passes on this head: - `delivery-dispatch.double-announce.test.ts`, real `dispatchCronDelivery`: - Announce settlement: a settled child reply `AUTOMATION_FAILED ⏎ …` is delivered as the explanation only and recorded as `agentReportedFailure`. - No-delivery settlement: uses the real `waitForDescendantSubagentResult`, with the registry mocked only at its edge. The child's report is recorded as `agentReportedFailure` with the explanation as output and summary. Nothing is sent, and the `deleteAfterRun` transcript is not deleted. Classification fails without the shared adoption helper (checked on the rebased predecessor commit), and retention fails on `bfe1f0f2169`. - `timer-outcomes.regression.test.ts`, real `applyJobResult`, 11 agent-reported failures from a clean streak: - `delivery: none`: still enabled, streak 11, no auto-disable notice, backoff delays 5 min, 15 min, 1 h, 1 h. This fails on `ee6d9e07fdf` (no streak, no backoff). - Webhook and announce jobs: auto-disabled at 10 with one notice, same backoff. Measured on this head, run separately (vitest `Duration`): - `delivery-dispatch.double-announce`: 84 tests, 22.1 s. - `timer-outcomes.regression`: 20 tests, 15.5 s. - `run.meta-error-status`: 14 tests, 20.0 s. All pass. `pnpm tsgo:core` passes, and oxlint and oxfmt on the changed files are clean. Docs: `delivery.md` documents the silent agent-failure exception to the 10-failure auto-disable. `payloads.md` notes that a delegated run's settled answer is classified the same way. LOC vs origin/main: production +54/−25, tests +100/−1, docs +2/−2. ### Review - Adversarial re-review round 1 (on `0530dc9f`): fixed the one real finding. Webhook jobs had been exempted too; the exemption now requires delivery mode `none`, with a webhook test case. - Round 2 (on `ee6d9e07fdf`): NOT LAND, one finding. Skipping the increment also froze error backoff, so a silent blocked job could keep running every minute. Fixed per maintainer decision with no second counter: the streak always increments, and the exemption moved to the auto-disable decision. - Round 3 (on `bfe1f0f2169`, rebased): LAND, no findings. The rebase onto origin/main also routes the openclaw#162474 no-delivery settlement through the same adoption helper. - ClawSweeper on `bfe1f0f2169`: fixed both findings. (P2) A failed no-delivery child run deleted its transcript; it is now kept. (P3) The auto-disable exception is now documented. Also added per-file test timings. - Round 4 (on `8b77715ba4f`): LAND, no findings. - Accepted tradeoffs: the exemption is not re-derived during finalized-run startup recovery. A silent job whose streak is already 10 or more from reported failures auto-disables on its next runtime error. Co-authored-by: Ayaan Zaidi <[email protected]>
Related: #162391
What Problem This Solves
Fixes two follow-ups to #162391:
AUTOMATION_FAILEDreply verbatim and still record the run asok. This happens on announce jobs, and ondelivery: nonejobs since fix(cron): no-delivery spawn-only runs drop the child's result #162474 started recording the child's answer.delivery: none) job whose agent keeps reporting a blocked task gets auto-disabled after 10 runs, and that posts an auto-disable notice even though the job has nowhere to notify.User Impact
AUTOMATION_FAILED, the run is recorded as an error with the child's explanation. Announce and current-session delivery send only the explanation, never the token.delivery: noneruns record it without sending anything, and keep the run transcript as other failed executions do.delivery: nonejob with no failure-alert route still records agent-reported failures in run history, job status, and error backoff (escalating to hourly, like any failing job). Those failures never auto-disable the job or post the auto-disable notice, so the job stays silent.NO_REPLYbehavior.Why This Change Was Made
resolveCronPayloadOutcome, which runs on the parent's reply before fix(cron): deliver spawned child results when scheduled agents emit no text #117308's descendant settlement. Two places indispatchCronDeliverythen adopt the settled child's reply as the run's answer: the announce settlement (fix(cron): deliver spawned child results when scheduled agents emit no text #117308) and the no-delivery settlement (fix(cron): no-delivery spawn-only runs drop the child's result #162474). Neither classified it. Both now go through one adoption helper that calls the shared parserreadAutomationFailedReport, so the run's effective terminal answer is classified after settlement.buildDeliveryStatederives one execution-failed flag from that result and uses it for both the completion status and the transcript-cleanup decision, so a failed no-delivery run is no longer cleaned up as a quiet success.run-finalizeconsumes the result the same way it already handlespendingPresentationWarningError: error status, permanent classification, explanation as the summary.reportedByAgent.applyJobResultintimer-outcomes.tsstill counts every error inconsecutiveErrors, so status and error backoff are unchanged. It skips only the auto-disable decision, and only when all of these hold: the failure was agent-reported,resolveFailureAlertfinds no route, and the delivery mode isnone(webhook jobs still auto-disable).Bounded cost
Evidence
Live model, Telegram Test Server (
telegram-e2e-userbot, DM)Setup: the repo runner unchanged (
run-mock-sut-user-e2e.mjs --backend mock --source-gateway --dm, Convex lease).E2E_MOCK_SERVER_PATHpoints to a throwaway proxy that stands in for the mock provider and forwards every request unchanged to the real OpenAI API. The proxy reads the key from a private file, so the Gateway only ever holds the runner's dummy key.E2E_ROOT_CONFIG_PATCHselectsopenai/gpt-6-astra(tools.toolSearch: false). A scenariocommandstep creates the jobs withopenclaw automations addand runs them. No model output was steered: the live parent chosesessions_spawn, and the live child and the live silent job wrote their ownAUTOMATION_FAILEDreports because they had no shell tool. The only steer is timing in case (b): before each run,cron.updatesetsnextRunAtMsto now and moveslastRunAtMsback 2 h, so the error backoff (up to 1 h) counts as served. The Gateway's own scheduler then runs the job as a normal scheduled (not forced) run.Before = origin/main
d8a110b1a15, plus this PR's exact base5c4e9aba929for case (a). After = this head8b77715ba4f, with all three cases in one Gateway run.(a) Announce job, live parent delegates to one child, the child reports
AUTOMATION_FAILEDd8a110b1a15):cron run --waittook 99.4 s. Runok,completionStatus: succeeded,deliveryStatus: delivered. The DM received bot message 43601:AUTOMATION_FAILED/The command could not run because no shell execution tool is available in this session.The token is visible.5c4e9aba929, the PR base): 80.7 s. Same result: runok,delivered, and bot message 43705 readsAUTOMATION_FAILED/The command could not run because no shell execution tool is available in this session.error,completionStatus: failed,deliveryStatus: delivered. Error and summary are both the explanation. The DM received bot message 43712 with onlyThe command could not run because no shell execution tool is available in this session.No token.cron child-session handoff completed without a final assistant payloadeven though the live child answered. That happened on 1 of 3 origin/main-side attempts (a secondd8a110b1a15run) and on 2 of 4 attempts on this branch (both onbfe1f0f2169). In those cases nothing reaches the chat. The PR's change only runs after a reply has been read, so it is not involved. The no-delivery path (case c) settled on every attempt.(c) Same delegated job with
delivery: none(the #162474 path)ok,succeeded,deliveryStatus: not-requested, summaryAUTOMATION_FAILED ⏎ The command could not run because no shell execution tool is available in this session.The token is recorded as an ok answer.error,failed,not-requested. Error and summary are bothThe command could not run because no shell execution tool is available in this session.The job stays enabled. No chat message.(b)
delivery: nonejob, no failure-alert route, the live model reportsAUTOMATION_FAILEDon every run (11 scheduled runs)error(Could not run \node scripts/ledger-sync.mjs`: this session only provides a file-reading tool…), withconsecutiveErrors1…10. After run 10 the job wasenabled: falsewithautoDisabled: {reason: "consecutive-failures", consecutiveErrors: 10}, so run 11 never happened. The DM received bot message 43644 (heartbeat relay):errorwith the same explanation, andconsecutiveErrorswent 1…11, which keeps feeding backoff. After run 11 the job was stillenabled: truewith noautoDisabled. History shows 11errorentries. Across the whole run, the DM received exactly one bot message: 43712 from case (a). Cases (c) and (b) sent none, including during a 120 s wait after the loop. 11 runs took 526 s.Provider evidence (proxy log): before had 1 parent
sessions_spawnturn, 1 child turn, 10 silent-job turns, and 1 relay turn carrying the auto-disable notice. After had 2 parentsessions_spawnturns, 2 child turns, 11 silent-job turns, no auto-disable relay turn, and only one routine heartbeat poll, which answeredNO_REPLY.Environment note: in
--source-gatewaymode on both refs, Telegram inbound polling could not start (the ingress worker's plugin capture has nodist/plugin-sdk). So the opening DM turn was not processed, and the jobs are owned byagent:main:main, the DM's owner session under the defaultdmScope. Outbound delivery and relays reached the DM normally. This is the same for before and after.Tests
Each new test fails on the code it fixes and passes on this head:
delivery-dispatch.double-announce.test.ts, realdispatchCronDelivery:AUTOMATION_FAILED ⏎ …is delivered as the explanation only and recorded asagentReportedFailure.waitForDescendantSubagentResult, with the registry mocked only at its edge. The child's report is recorded asagentReportedFailurewith the explanation as output and summary. Nothing is sent, and thedeleteAfterRuntranscript is not deleted. Classification fails without the shared adoption helper (checked on the rebased predecessor commit), and retention fails onbfe1f0f2169.timer-outcomes.regression.test.ts, realapplyJobResult, 11 agent-reported failures from a clean streak:delivery: none: still enabled, streak 11, no auto-disable notice, backoff delays 5 min, 15 min, 1 h, 1 h. This fails onee6d9e07fdf(no streak, no backoff).Measured on this head, run separately (vitest
Duration):delivery-dispatch.double-announce: 84 tests, 22.1 s.timer-outcomes.regression: 20 tests, 15.5 s.run.meta-error-status: 14 tests, 20.0 s.All pass.
pnpm tsgo:corepasses, and oxlint and oxfmt on the changed files are clean.Docs:
delivery.mddocuments the silent agent-failure exception to the 10-failure auto-disable.payloads.mdnotes that a delegated run's settled answer is classified the same way.LOC vs origin/main: production +54/−25, tests +100/−1, docs +2/−2.
Review
0530dc9f): fixed the one real finding. Webhook jobs had been exempted too; the exemption now requires delivery modenone, with a webhook test case.ee6d9e07fdf): NOT LAND, one finding. Skipping the increment also froze error backoff, so a silent blocked job could keep running every minute. Fixed per maintainer decision with no second counter: the streak always increments, and the exemption moved to the auto-disable decision.bfe1f0f2169, rebased): LAND, no findings. The rebase onto origin/main also routes the fix(cron): no-delivery spawn-only runs drop the child's result #162474 no-delivery settlement through the same adoption helper.bfe1f0f2169: fixed both findings. (P2) A failed no-delivery child run deleted its transcript; it is now kept. (P3) The auto-disable exception is now documented. Also added per-file test timings.8b77715ba4f): LAND, no findings.