Skip to content

fix(cron): auto-disable notice skips the failure-alert route when a recurring automation is disabled after 10 failures - #174309

Merged
roboclaw-bot merged 2 commits into
openclaw:mainfrom
saftall:fix/cron-auto-disable-notice-route
Oct 17, 2026
Merged

roboclaw-bot merged 2 commits into
openclaw:mainfrom
saftall:fix/cron-auto-disable-notice-route

Conversation

@saftall

@saftall saftall commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Closes #174308

What Problem This Solves

Fixes: the auto-disable safety notice of a recurring automation never reaches its configured failure-alert destination (webhook or announce) when the job is disabled after 10 consecutive failures; it is only queued for a model turn, so while the failing model provider is the cause nobody is told.

User Impact

User impact: operators who route automation failure alerts to a webhook or a channel now receive the "was auto-disabled after 10 consecutive run failures" notice on that route, with the recovery command, even while the model provider is down. Jobs without a failure route keep today's in-app notice to the owning agent. No config change, no new option.

Why This Change Was Made

The recurring terminal failure set autoDisableNotificationOwnsFailure, which made finalizeCronFailureNotifications skip the resolved failure route entirely; the notice only became a system event for the owning agent, i.e. a model turn. Now maybeEmitFailureAlert sends the auto-disable notice directly through the resolved route when a recurring job is disabled by this failure: the threshold, cooldown, the streak's earlier incident signature, and a pending repair request do not hold it back, and it never takes the owner-repair branch (a repair turn needs the same model that just failed ten times). The in-app system event is queued only when no route alert was queued (no route, failureAlert: false, best-effort delivery). The repair branch itself is unchanged for one-shots and non-terminal failures. The notice text is built once (buildCronAutoDisableNotice) so the route and the agent read the same words.

This is the option ClawSweeper recommended for its decision question ("Deliver the safety notice directly: use the configured route independently of model-backed repair, preserving the no-route owner fallback"). The first commit had admitted recurring terminal failures of owned jobs into the repair branch; the second commit removes that and updates the existing tenth-failure regression.

Evidence

Tested at 68df5a3e4e982f1114f9ee47805487909dd0a4b1 (base 7621a15a943). Same script, same inputs, two entry points: the published [email protected] package and this branch built with pnpm build, each as node openclaw.mjs gateway run on a fresh state in a node:24-bookworm container, with a local OpenAI-compatible stub answering HTTP 500 and a local webhook receiver as the failure-alert destination (cron.failureAlert.mode: "webhook"). The job is owned: created through the shipped cron.add RPC with owner: { agentId: "main", sessionKey: "agent:main:main" }, the shape the agent's automations tool stores when a conversation creates a job. The 10th failure is reached by persisting a 9-failure streak with an elapsed backoff (the natural path takes ~5.5 h). The stub also flags any request that carries the scheduler's repair brief.

Before (published 2026.10.4, owned job)

$ node node_modules/openclaw/openclaw.mjs --version        # published package
OpenClaw 2026.10.4 (383c124)
00:25:32Z gateway call cron.add {..., owner:{agentId:"main", sessionKey:"agent:main:main"}, every 60s, isolated}; cron.failureAlert webhook -> 127.0.0.1:18977
00:29:35Z receiver: POST /alert "Automation \"proof-outage\" failed 2 times\nCause: server_error\nLast error: ... | 500"
00:29:43Z stop; persist consecutiveErrors=9 with an elapsed backoff; start again
00:33:28Z 10th failure -> ERROR cron: auto-disabled job after consecutive run failures (file log)
00:33:30Z provider: POST /v1/chat/completions autoDisableText=true   <- the notice rides a model turn (HTTP 500)
00:33:53Z receiver: 0 alerts since the terminal failure
          job: enabled=false, autoDisabled={reason:consecutive-failures, consecutiveErrors:10}, lastFailureNotificationDeliveryStatus=not-requested
          provider over the whole run: 31 chat requests, 1 carrying the notice, 0 carrying a repair brief
00:34:20Z provider answers 200 again; `openclaw system event --mode now`: 2 requests, neither carries the notice

After (this PR at 68df5a3e4e, owned job)

$ node openclaw.mjs --version        # source build of this branch
OpenClaw 2026.10.4 (68df5a3)
00:34:40Z gateway call cron.add {..., owner:{agentId:"main", sessionKey:"agent:main:main"}, every 60s, isolated}; same config, stub, receiver
00:47:18Z receiver: POST /alert "Automation \"proof-outage\" failed 4 times\nCause: server_error\nLast error: ... | 500"
          (main holds the threshold alert through the quick re-run ladder for server errors, `pendingTransientRetry`; the published
           2026.10.4 predates that hold, which is why it alerted after the 2nd failure above. Unchanged by this PR.)
00:47:22Z stop; persist consecutiveErrors=9 with an elapsed backoff; start again
00:50:46Z 10th failure -> auto-disabled -> receiver: POST /alert {"jobName":"proof-outage","message":"⚠️ Automation \"proof-outage\" was auto-disabled after 10 consecutive run failures.\nCause: server_error\nFix the underlying cause, then run `openclaw automations enable <id>` to re-enable it.\nLast error: ⚠️ The AI service is having trouble. Please try again in a moment. | 500"}
00:51:12Z job: enabled=false, autoDisabled={reason:consecutive-failures, consecutiveErrors:10}, lastFailureNotificationDeliveryStatus=delivered
          provider over the whole run: 39 chat requests, 0 carrying the notice, 0 carrying a repair brief
00:51:40Z provider answers 200 again; `openclaw system event --mode now`: 1 request (the unrelated event), no notice pending

Earlier run, unowned job created with openclaw automations add (after-run at the first commit b01e4182; the second commit does not change the unowned path):

before 2026.10.4  14:08:03Z 10th failure -> receiver 0 alerts; notice only inside a failing chat-completion request; lastFailureNotificationDeliveryStatus=not-requested
after  b01e4182   14:25:28Z 10th failure -> receiver POST /alert "⚠️ Automation \"proof-outage\" was auto-disabled after 10 consecutive run failures. ... openclaw automations enable <id> ..."; 0 model requests carried it; delivered

Tests (Node runtime, as CI; node:24-bookworm, pnpm 12.10.1, fresh pnpm install --frozen-lockfile at 68df5a3e4e):

$ OPENCLAW_VITEST_RUNTIME=node pnpm test src/cron --maxWorkers=4
 Test Files  251 passed (251)

# the same new/updated tests against base production code (src/cron/service/{auto-disable,failure-alerts,timer-outcomes}.ts from 7621a15a943):
 FAIL  timer-outcomes.regression.test.ts > records failure diagnostics and auto-disables on the tenth consecutive failure
 FAIL  timer-outcomes.regression.test.ts > sends an owned job's auto-disable notice through its route, not a repair turn (webhook route, no earlier alert)
 FAIL  timer-outcomes.regression.test.ts > sends an owned job's auto-disable notice through its route, not a repair turn (announce route, no earlier alert)
 FAIL  timer-outcomes.regression.test.ts > sends an owned job's auto-disable notice through its route, not a repair turn (announce route, repair still pending)
 FAIL  timer.batch-finalization.test.ts > sends the recurring auto-disable notice through the job's failure route instead of a model turn
 (the two "keeps the owning-agent auto-disable notice" cases pass on base: they pin the unchanged no-route fallback)

PR CI on 68df5a3e4e: all checks green, including checks-node-changed-*, check-lint*, check-test-types*, check-docs.

Not covered: no live chat channel was exercised for an announce route (the routed notice uses the existing failure-alert transport; announce-route behavior is covered by the unit cases above).

Checks

  • pnpm test src/cron --maxWorkers=4 (251 files) at 68df5a3e4e; new/updated cases proven red on base production code.
  • Production delta: src/cron/service/{auto-disable,failure-alerts,timer-outcomes}.ts +87/-17; tests +161/-4; docs: one sentence in docs/automation/cron-jobs/delivery.md.

Merge danger

Two-way door. Behavior changes only on the terminal (10th) failure of a time-based recurring job that has a resolved failure route: that route now carries the notice directly and the in-app system event is not queued for it. Jobs without a route, failureAlert: false, best-effort delivery, one-shots, schedule-error auto-disable, startup replay, and all non-terminal alerts and repair requests are unchanged. No stored data, protocol, or config shape changes.

…r is the cause

A time-based recurring automation is auto-disabled after 10 consecutive
execution failures. The safety notice for that terminal failure was only
queued as a system event for the owning agent and delivered through an
immediate heartbeat turn, while the job's resolved failure route was told to
stay quiet (`autoDisableNotificationOwnsFailure`). When the consecutive
failures are the model provider itself (outage, revoked key, unsupported
model), the heartbeat turn fails the same way, the admitted system event is
consumed with it, and nobody is told that the automation stopped. A webhook or
announce failure route that had been delivering the threshold alerts without a
model goes silent exactly on the failure that matters.

Treat the terminal recurring failure like a terminal one-shot failure: the
route-backed alert carries the auto-disable notice (threshold and cooldown do
not apply, the earlier alert's incident signature does not suppress it), and
only a job without a failure route hands the notice to its owning agent as a
system event. The notice text is shared, so the route and the agent read the
same words and recovery command.
@clawsweeper

clawsweeper Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: S labels Oct 16, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 16, 2026
@clawsweeper

clawsweeper Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Send recurring automation auto-disable notices directly through the configured failure-alert route after ten consecutive failures.

Example: The owned automation proof-outage reaches its tenth failure while its provider returns HTTP 500.

  • Before: The webhook receives no terminal notice, while the notice enters another failing model turn.
  • After: The webhook receives the auto-disable notice and re-enable command without a model turn.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused fix with shipped-entry-point proof, relevant regression coverage, resolved prior findings, and a successful exact-head CI gate.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): At the reviewed head, the contributor's built Gateway processes an owned cron.add job against an HTTP-500 provider and sends its tenth-failure notice to a real local webhook receiver, records delivered, and issues no model-backed notice or repair request.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Operators receive no auto-disable notice at their configured failure destination when the failing provider also prevents the owning-agent notification.
Reason: A terminal safety notice must remain useful during the outage that disabled the automation; the existing route provides that capability without new configuration.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current-main notification bug and resolves both prior findings; no remaining merge blocker was found.

Priority: P1
Reviewed head: 68df5a3e4e982f1114f9ee47805487909dd0a4b1

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Live announce-channel delivery was not exercised; source and regression cases cover its unchanged transport selection, while the real gateway webhook run proves the changed terminal-routing boundary.
Agent review details

How this fits together

Cron finalization records execution outcomes and disablement, then dispatches committed notification intents through the Gateway's existing webhook, channel, or owning-agent transport.

flowchart TD
  A[Execution failure] --> B[Cron outcome finalization]
  B --> C[Persist disabled job and notification]
  C --> D[Failure alert dispatcher]
  D --> E[Configured webhook or channel]
  C --> F[Owning agent fallback]
Loading

Technical review

Best possible solution:

Land the focused routing fix through the existing failure-alert owner while retaining the owning-agent fallback.

Do we have a high-confidence way to reproduce the issue?

Current-main source establishes the route bypass, and the contributor supplies matching published-release gateway and webhook traces; this read-only review executed no target code.

Is this the best way to solve the issue?

The patch repairs notification selection at its existing owner, reuses the established transport, and preserves unrelated scheduling, one-shot repair, and opt-out behavior.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against b0ab44081ef4.

Provenance checked

  • Recurring auto-disable notification changes intended behavior with a stated reason (08d0952: Stop persistently failing recurring jobs and provide a durable, visible terminal outcome with a recovery command.)
  • Failure-alert ownership and suppression keeps the original intent (177828a: Centralize alert routing and threshold decisions in cron finalization while honoring operator opt-outs and best-effort semantics.)
  • Owner-repair verification hold changes intended behavior with a stated reason (cb63a46: Wait for a fresh post-repair execution before escalating ordinary failures; this PR explains why permanent recurring disablement needs immediate direct notification.)
  • Notification privacy keeps the original intent (4c95139: Keep raw runtime details out of chat notifications while retaining diagnostic details in structured webhooks and history.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Current main retains the route bypass: The current-main production modules match the introduction base: recurring auto-disable sets autoDisableNotificationOwnsFailure, which excludes the terminal failure from routed notification finalization. (src/cron/service/timer-outcomes.ts:386, b0ab44081ef4)
  • Prior repair-routing finding resolved: Terminal recurring failures bypass repair deadlines, incident deduplication, cooldown, and owner repair, then queue the existing failure-alert intent directly. (src/cron/service/failure-alerts.ts:440, 68df5a3e4e98)
  • Fallback and regression coverage: The existing tenth-failure regression now expects routed delivery; added cases cover owned webhook and announce jobs, a pending repair, alert opt-out, and no-route fallback, while batch finalization checks persisted disablement. (src/cron/service/timer-outcomes.regression.test.ts:285, 68df5a3e4e98)
  • Owned-job gateway proof: saftall supplies published-release and reviewed-head gateway traces using cron.add, an owned job, an HTTP-500 provider, and a real local webhook receiver; the reviewed head delivers the terminal notice and records delivered without a notice-bearing or repair model request. (68df5a3e4e98)
  • Exact-head CI and mergeability: Paginated check reads show no failed or unfinished checks, the openclaw/ci-gate succeeds, combined statuses succeed, and GitHub reports the reviewed head cleanly mergeable. (68df5a3e4e98)
  • Existing transport and security boundary: The notice uses the existing Gateway failure-alert transport, including configured account and recipient routing, strict webhook SSRF protection, delivery settlement, and proven-not-delivered fallback. (src/gateway/server-cron-notifications.ts, 68df5a3e4e98)

Likely related people:

  • Peter Steinberger: Raw commit 08d0952 adds src/cron/service/auto-disable.ts:16 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 08d0952df24a; files: src/cron/service/auto-disable.ts)

PR surface

Source +70, Tests +157, Docs 0. Total +227 across 6 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 3 87 17 +70
Tests 2 161 4 +157
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 249 22 +227

Review metrics

Metric Value Why it matters
Production versus test LOC Production +87/-17; tests +161/-4 Growth extracts shared notice construction and covers terminal routing, repair suppression bypass, fallback preservation, and durable finalization.

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: An affected released workflow silently loses its terminal notification when a recurring automation stops during a provider outage.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-16T14:45:55.649Z sha b01e418 :: blocked before merge. :: [P1] Send recurring terminal notices independently of owner repair | [P2] Update the existing tenth-failure regression for the new route

Reviewed October 16, 2026, 8:59 PM ET / October 17, 2026, 00:59 UTC (Revision 2).

@roboclaw-bot roboclaw-bot self-assigned this Oct 16, 2026
…te, not via repair

The first commit let a recurring job's terminal failure into the owner
repair branch whenever the job had an owner conversation, as a terminal
one-shot does. A repair turn needs the same model that just failed ten
times; if it settles with an error, the route stays silent, and the
repair brief described the job as one-time.

A recurring job disabled by this failure now always sends its notice
through the resolved route, even while an earlier repair request is
pending; the repair branch is unchanged for one-shots and non-terminal
failures. The tenth-failure regression now expects the routed notice,
and new cases cover the owner fallback (no route, alerts disabled) and
owned jobs with webhook and announce routes.
@saftall
saftall force-pushed the fix/cron-auto-disable-notice-route branch from bc8f244 to 68df5a3 Compare October 16, 2026 23:14
@saftall

saftall commented Oct 17, 2026

Copy link
Copy Markdown
Contributor Author

Addressed both findings in 68df5a3: a recurring job disabled by its 10th failure now sends the notice directly through the resolved route and never through owner repair (also when a repair is pending), and the existing tenth-failure regression now expects the routed notice, with new cases for the no-route owner fallback and owned webhook/announce jobs. The PR body has an owned-job before/after run at that head (job created through cron.add with an owner), all 251 src/cron test files passing, and the new cases failing on base production code.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 17, 2026
@roboclaw-bot
roboclaw-bot merged commit 053cf12 into openclaw:main Oct 17, 2026
136 checks passed
@roboclaw-bot

Copy link
Copy Markdown
Collaborator

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 18, 2026
…ecurring automation is disabled after 10 failures (openclaw#174309)

* fix(cron): auto-disable notice is lost when the failing model provider is the cause

A time-based recurring automation is auto-disabled after 10 consecutive
execution failures. The safety notice for that terminal failure was only
queued as a system event for the owning agent and delivered through an
immediate heartbeat turn, while the job's resolved failure route was told to
stay quiet (`autoDisableNotificationOwnsFailure`). When the consecutive
failures are the model provider itself (outage, revoked key, unsupported
model), the heartbeat turn fails the same way, the admitted system event is
consumed with it, and nobody is told that the automation stopped. A webhook or
announce failure route that had been delivering the threshold alerts without a
model goes silent exactly on the failure that matters.

Treat the terminal recurring failure like a terminal one-shot failure: the
route-backed alert carries the auto-disable notice (threshold and cooldown do
not apply, the earlier alert's incident signature does not suppress it), and
only a job without a failure route hands the notice to its owning agent as a
system event. The notice text is shared, so the route and the agent read the
same words and recovery command.

* fix(cron): send the recurring auto-disable notice straight to the route, not via repair

The first commit let a recurring job's terminal failure into the owner
repair branch whenever the job had an owner conversation, as a terminal
one-shot does. A repair turn needs the same model that just failed ten
times; if it settles with an error, the route stays silent, and the
repair brief described the job as one-time.

A recurring job disabled by this failure now always sends its notice
through the resolved route, even while an earlier repair request is
pending; the repair branch is unchanged for one-shots and non-terminal
failures. The tenth-failure regression now expects the routed notice,
and new cases cover the owner fallback (no route, alerts disabled) and
owned jobs with webhook and announce routes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

2 participants