Skip to content

fix(cron): blocked scheduled runs are recorded as ok - #162391

Merged
obviyus merged 3 commits into
mainfrom
fix/cron-blocked-outcome
Oct 1, 2026
Merged

obviyus merged 3 commits into
mainfrom
fix/cron-blocked-outcome

Conversation

@obviyus

@obviyus obviyus commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes: a scheduled agent run that could not do its task is recorded as ok, so run history, --wait, and the configured failure alerts treat it as a success.

In our setup, a monthly isolated job delivered nothing for two months and every receipt said ok. One month the turn knew it was blocked (no shell tool) and said so in plain text, but nothing structured recorded that.

User Impact

  • A run can now fail itself. A final reply whose first line is exactly AUTOMATION_FAILED records the run as error, with the lines that follow as the error text. The existing failure handling then applies: error backoff, plus failure alerts and owner-conversation repair for jobs that already have a failure route or failureAlert config.
  • Announce jobs still deliver the agent's explanation, with the token removed.
  • These stay ok: NO_REPLY runs, and replies that mention the token anywhere other than as the exact first line.
  • No change to notification contracts. An unconfigured delivery: none job still sends nothing to chat (no alert, no repair request). It now records the error in run history and job status (lastRunStatus, consecutiveErrors).

Not fixed here:

Why This Change Was Made

Provenance:

The token is a strict control line, like NO_REPLY. Only an exact first line counts, so ordinary prose is never classified. The preamble sentence is reworded in place: similar length, still static for prompt caching.

Bounded cost

New or changed paths that could lead to a model call or a job run:

  • The token parse. No new turns, runs, or notifications. It only changes the recorded status of the run that produced the reply. It is parsed only in cron finalization for that run. The delivered explanation is outbound text, never inbound, so there is no self-trigger.
  • Error status → scheduler.
    • One-shot jobs: an agent-reported failure carries errorClassification: { kind: "permanent" }, so it never enters the transient-retry path. This also means wording like "network timeout" in the explanation is never text-classified into a retry or an error reason. Tested in run.meta-error-status.test.ts.
    • Recurring jobs: the existing error backoff only delays the next run (natural schedule or later), and the existing auto-disable stops the job after 10 consecutive errors. Nothing runs sooner than scheduled.
  • Repair turns. Unchanged. They still happen only for jobs with an existing chat failure route (feat(cron): let a failing automation's owner conversation repair it before alerting #161007): at most one per failure incident, and the incident marker is persisted in job state. A repair turn can't start runs, because automation control is owner-only and the request carries no sender identity. It is an ordinary conversation turn, not a cron run, so its own failure can't open another repair.
  • The preamble text. Static; it adds no turns.

Evidence

Isolated Gateway, qa-lab mock-openai, new scenario qa/scenarios/scheduling/cron-blocked-outcome.yaml:

  • Before (origin/main): a delivery: none job whose reply starts with AUTOMATION_FAILED → status: "ok", completionStatus: "succeeded", and the summary holds the blocker text.
  • After: see the result comment below. The scenario checks:
    • An owned delivery: none job, run 3 times → each run is error with the reported reason; no repair request and no chat message.
    • An unowned announce job, run twice → error; the reason is delivered without the token, and the existing failed 2 times alert fires.
    • A mid-text quote, and NO_REPLY (with and without announce) → ok.

Focused tests (fail before, pass after): src/cron/isolated-agent/run.meta-error-status.test.ts covers token → error + permanent classification, and a mid-text quote → ok (two cases, about 1.7 s each in the shared harness). Also passing: failure-alerts.{account-routing,persistence,recovery}, service.failure-repair, and run.message-tool-policy (116 tests). pnpm tsgo:core and oxlint on the changed files are clean. run.message-tool-policy.test.ts no longer pins the full preamble wording; it keeps the ordering assertion.

LOC vs origin/main: production +36/−7, unit tests +24/−2, QA scenario and mock about +180, docs +1/−1.

Upgrade compatibility

No migration is required. The diff touches no schema, store, codec or persisted type file. Run history keeps the existing CronRunStatus values (ok | error | skipped) and the existing error/permanent classification fields, so rows written before and after this change go through the same unchanged readers. The QA scenario's "repair" wording refers to the scheduler's automation repair request, not a data repair. Existing-state compatibility is verified by the unchanged failure-alerts.persistence and service.failure-repair suites passing on this head.

@clawsweeper

clawsweeper Bot commented Oct 1, 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.

@obviyus

obviyus commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime extensions: qa-lab size: M labels Oct 1, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 1, 2026
@clawsweeper

clawsweeper Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed October 1, 2026, 7:13 AM ET / 11:13 UTC (Revision 6).

ClawSweeper review

What this changes

The PR lets scheduled agents report failure with an AUTOMATION_FAILED first line, records an execution error, and delivers the explanation without the token through existing notification policies.

Merge readiness

⛔ Blocked before merge - 1 item remains

This PR remains useful: current main still records an agent-reported blocker as success. No blocking defect remains in the reviewed patch; the prior migration concern does not apply to its unchanged stored-data contract.

Likely related people: obviyus and steipete, based on recent merged cron work.

Priority: P1
Reviewed head: 7eaa535871c1557abc9a650e639d2f8b1e37bc20

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused patch with relevant production-boundary observations and no remaining actionable finding.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): Recorded isolated Gateway QA exercises the changed cron outcome resolver through actual scheduled-run APIs with deterministic provider output, observes errors and token-free delivery after the fix, and verifies silent controls. No stored-data contract changes, so migration proof is not applicable.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): Recorded isolated Gateway QA exercises the changed cron outcome resolver through actual scheduled-run APIs with deterministic provider output, observes errors and token-free delivery after the fix, and verifies silent controls. No stored-data contract changes, so migration proof is not applicable.
Evidence reviewed 7 items Pinned introduced change: Reviewed the merge-base-to-head delta. Production changes are confined to the shared token constant, cron reply-outcome resolution, finalization classification, and static unattended instructions; the remaining changes document and exercise that behavior.
Still necessary on main: Fetched main's outcome resolver recognizes structured errors, fatal failure signals, and run-level errors, but has no AUTOMATION_FAILED parsing. The latest release's resolver likewise lacks the token path. Related merged delivery fixes address transport completion rather than this agent-reported execution outcome.
Latest release comparison: The v2026.9.7 resolver has the existing fatal-error paths but no agent failure-token handling.
Findings None None.
Security None None.

How this fits together

Cron runs scheduled agent tasks and converts their replies into execution outcomes and delivery payloads. Those outcomes feed run history, completion reporting, scheduling policy, and configured failure notifications.

flowchart TD
 A[Scheduled job] --> B[Agent task and unattended instructions]
 B --> C[Final reply and runtime errors]
 C --> D[Cron outcome resolution]
 D --> E[Run history and completion]
 D --> F[Configured output delivery]
 E --> G[Existing backoff and failure notifications]
Loading

Before merge

  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source +60, Tests +22, Docs 0, Other +149. Total +231 across 10 files.

View PR surface stats
Area Files Added Removed Net
Source 6 67 7 +60
Tests 2 24 2 +22
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 149 0 +149
Total 10 241 10 +231

Review metrics

Metric Value Why it matters
Production versus validation growth Production +36/-7; unit tests +24/-2; QA fixtures +180 Production growth implements explicit failure reporting in the existing owner; most added code exercises status, delivery, and silence controls.

Stored data model

Persistent data-model change detected: migration/backfill/repair: qa/scenarios/scheduling/cron-blocked-outcome.yaml. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Keep failure reporting in the existing cron outcome owner while preserving intentional silence, execution-versus-delivery separation, and configured notification routes.

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

Yes, from source: a scheduled reply reporting a blocker without runtime error metadata remains successful on current main. The submitted Gateway before/after observations corroborate that path; this review did not execute it.

Is this the best way to solve the issue?

Yes. An explicit control line parsed by the existing outcome owner avoids classifying ordinary prose and feeds existing failure policy without adding notification routing or persisted state.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P1: Reported scheduled work silently failed for two months while success receipts prevented existing failure handling from recognizing it.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): Recorded isolated Gateway QA exercises the changed cron outcome resolver through actual scheduled-run APIs with deterministic provider output, observes errors and token-free delivery after the fix, and verifies silent controls. No stored-data contract changes, so migration proof is not applicable.
  • proof: sufficient: Contributor real behavior proof is sufficient. Recorded isolated Gateway QA exercises the changed cron outcome resolver through actual scheduled-run APIs with deterministic provider output, observes errors and token-free delivery after the fix, and verifies silent controls. No stored-data contract changes, so migration proof is not applicable.

Evidence

What I checked:

  • Pinned introduced change: Reviewed the merge-base-to-head delta. Production changes are confined to the shared token constant, cron reply-outcome resolution, finalization classification, and static unattended instructions; the remaining changes document and exercise that behavior. (src/cron/isolated-agent/helpers.ts:294, 7eaa535871c1)
  • Still necessary on main: Fetched main's outcome resolver recognizes structured errors, fatal failure signals, and run-level errors, but has no AUTOMATION_FAILED parsing. The latest release's resolver likewise lacks the token path. Related merged delivery fixes address transport completion rather than this agent-reported execution outcome. (src/cron/isolated-agent/helpers.ts:294, d417b5202305)
  • Latest release comparison: The v2026.9.7 resolver has the existing fatal-error paths but no agent failure-token handling. (src/cron/isolated-agent/helpers.ts:294, c074824a27c9)
  • No stored-data change: The introduced delta leaves cron types, the event codec, storage, and failure-alert routing unchanged. Existing status values and permanent error classification carry the result through the existing readers and scheduler. The agentReportedFailure flag is a transient helper result, not a persisted field; the YAML file is a QA scenario. Migration proof is therefore not applicable, resolving the prior review's sole remaining blocker independently of the contributor's assertion. (src/cron/types.ts:97, 7eaa535871c1)
  • Production-boundary after-fix evidence: The captured body and fix(cron): blocked scheduled runs are recorded as ok #162391 (comment) report an isolated Gateway run with qa-channel and deterministic mock-openai responses: three owned no-delivery failures recorded error with zero repair requests or outbound messages; two unowned announce failures delivered the reason without the token and triggered the existing alert; quoted-token and NO_REPLY controls stayed successful. The inspected scenario invokes cron.add and cron.run and reads actual completion and outbound observations, exercising the changed outcome owner rather than mocking its answer. (qa/scenarios/scheduling/cron-blocked-outcome.yaml:79, 7eaa535871c1)
  • Retry and regression coverage: Finalization assigns the existing permanent classification to agent-reported failure. The scheduler already rejects transient retries for that classification, and the added runner-boundary cases cover transient-looking failure prose and a mid-text token mention. The body reports failing-before/passing-after results and focused test cost; no target code or tests were executed during this read-only review. (src/cron/isolated-agent/run-finalize.ts:265, 7eaa535871c1)

Likely related people:

  • obviyus: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (5 earlier review cycles)
  • reviewed 2026-10-01T04:30:44.347Z sha cc1fa41 :: needs real behavior proof before merge. :: [P1] Keep owner-only alerts from falling back to another conversation
  • reviewed 2026-10-01T04:58:48.988Z sha 7eaa535 :: blocked before merge. :: none
  • reviewed 2026-10-01T06:03:48.983Z sha 7eaa535 :: blocked before merge. :: none
  • reviewed 2026-10-01T10:22:09.056Z sha 7eaa535 :: blocked before merge. :: none
  • reviewed 2026-10-01T10:30:21.332Z sha 7eaa535 :: blocked before merge. :: none

@obviyus obviyus changed the title fix(cron): blocked automation runs report ok and owned no-delivery jobs never alert fix(cron): blocked scheduled runs are recorded as ok Oct 1, 2026
@obviyus

obviyus commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator Author

After-fix QA (isolated gateway, mock-openai, cron-blocked-outcome): pass. Owned delivery:none ×3 → error with reason, repairRequests=0, ownerOutbound=0. Unowned announce ×2 → error, reason delivered without token, failed 2 times alert. Quoted → ok; NO_REPLY → ok (none and announce).

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 1, 2026
@obviyus

obviyus commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator Author

Owner note on the remaining "data-model compatibility" item: this PR changes no stored data. No SQLite schema, migration, store codec, or persisted job/run fields are touched; errorClassification and status are existing run-result fields with existing values. The flagged file qa/scenarios/scheduling/cron-blocked-outcome.yaml is a QA-lab scenario fixture. It matched the heuristic only because it asserts that no owner "repair" request is sent. Nothing changes on upgrade: existing jobs and run history are read as before, and the new token only affects runs whose reply starts with AUTOMATION_FAILED.

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@obviyus
obviyus marked this pull request as ready for review October 1, 2026 10:17
@obviyus

obviyus commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper Maintainer decision (Ayaan, repository maintainer): the data-model item comes from qa/scenarios/scheduling/cron-blocked-outcome.yaml, a QA scenario fixture. This PR changes no schema, migration, persisted format or stored field; error and permanent run classification already exist (your own review verified this). Migration proof does not apply.

@obviyus

obviyus commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper approve

@obviyus

obviyus commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper assist is taking a look at your question.

I queued a lightweight read-only assist pass. It will post a separate answer comment and will not edit the durable ClawSweeper review comment or trigger close, merge, repair, label, or branch changes.

Request: Maintainer decision (Ayaan, repository maintainer): the data-model item comes from qa/scenarios/scheduling/cron-blocked-outcome.yaml, a QA scenario fixture. This PR changes no schema, migration, persisted format or stored field; error and permanent run classification already exist (your own review verified this). Migration proof does not apply.

@clawsweeper

clawsweeper Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@clawsweeper

clawsweeper Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@obviyus

obviyus commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@obviyus
obviyus merged commit 855bba4 into main Oct 1, 2026
418 of 458 checks passed
@obviyus
obviyus deleted the fix/cron-blocked-outcome branch October 1, 2026 11:25
@obviyus

obviyus commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator Author

Landed in 855bba4.

  • Problem: a scheduled agent turn that couldn't do its job, and said so in a plain final reply, was recorded as ok. Failure alerts and the run history never showed the failure.
  • Fix: an explicit AUTOMATION_FAILED control line now goes through the existing cron outcome classifier. The run is recorded as a permanent error with the reported reason, and the token is stripped from delivered output. Jobs without delivery stay silent, and failure routing is unchanged.
  • Proof: CI is fully green on 7eaa535 (https://github.com/openclaw/openclaw/actions/runs/36848233223). Focused cron outcome tests and the qa-lab scenario pass, and the hosted review lists no code findings.
  • Merge route: admin squash merge, pinned to head 7eaa535. The hosted review stayed blocked only on its "data-model compatibility proof" gate. That gate is a keyword false positive: it matches "repair" in the QA scenario's automation-repair wording. This PR changes no schema, store, codec or persisted type (see "Upgrade compatibility" in the PR body), and the review itself recorded no stored-data contract changes.

obviyus added a commit that referenced this pull request Oct 1, 2026
…et auto-disabled (#162686)

Related: #162391

## What Problem This Solves

Fixes two follow-ups to #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 #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.** #162391 classified the token in `resolveCronPayloadOutcome`, which runs on the parent's reply before #117308's descendant settlement. Two places in `dispatchCronDelivery` then adopt the settled child's reply as the run's answer: the announce settlement (#117308) and the no-delivery settlement (#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 `d8a110b1a15`, plus this PR's exact base `5c4e9aba929` 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 (`d8a110b1a15`): `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 (`5c4e9aba929`, 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 `d8a110b1a15` 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 #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 #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]>
obviyus added a commit that referenced this pull request Oct 2, 2026
## What Problem This Solves

Follow-up to #160996. The cron authoring guidance (docs `payloads.md` and the automations tool description) said failure notifications wait for consecutive failed runs, "so a one-off outage stays quiet". That isn't true, so the guidance taught models a wrong cost for failing loudly:

- A command payload with announce delivery still delivers its output when it exits non-zero: `runCommandJob` in `src/gateway/server-cron.ts` passes the summary to completion delivery without checking the exit status.
- Since #162391, an agent's `AUTOMATION_FAILED` explanation is delivered for announce jobs.

## Solution

Only the failure alert waits for consecutive failures; the run's own output still follows the job's delivery setting. Both places now say exactly that. The tool description stays static (prompt-cache stable) and grows by 12 characters. Prompt snapshots are regenerated.

## User Impact

No runtime behavior change. Models writing automations get accurate guidance about what a failed run sends.

## Evidence

The automations tool description an agent actually receives, taken from the regenerated prompt snapshot (`codex-dynamic-tools.telegram-direct.json`, built by the real prompt builder):

- Before: `throw from the script so the run records the failure (returning {error} still succeeds); failure alerts already wait for consecutive failures, so a one-off failure stays quiet.`
- After: `throw from the script so the run records the failure (returning {error} still succeeds); only the failure alert waits for consecutive failures, run output still follows the job's delivery.`

Checks on the exact head:

- `pnpm run prompt:snapshots:check`: snapshots are current (7 files).
- `node scripts/run-vitest.mjs src/agents/tools/cron-tool.test.ts`: 72 passed.

Text-only change, so no live channel proof applies: no message, delivery or runtime path changes.


Runtime output from a real OpenClaw setup on head `15919727aaa`: the actual `createCronTool()` builder run in an isolated state dir (default config), printing the failure-guidance sentences of the `automations` tool description an agent receives:

```text
tool: automations
When a run fails, throw from the script so the run records the failure (returning {error} still succeeds); only the failure alert waits for consecutive failures, run output still follows the job's delivery.
FAILURE ALERTS: jobs with a failure route default to alerting after 2 consecutive execution failures with a 1h cooldown.
```

The same sentence on `origin/main` read: `…failure alerts already wait for consecutive failures, so a one-off failure stays quiet.`

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 2, 2026
## What Problem This Solves

Fixes: a scheduled agent run that could not do its task is recorded as `ok`, so run history, `--wait`, and the configured failure alerts treat it as a success.

In our setup, a monthly isolated job delivered nothing for two months and every receipt said `ok`. One month the turn knew it was blocked (no shell tool) and said so in plain text, but nothing structured recorded that.

## User Impact

- A run can now fail itself. A final reply whose first line is exactly `AUTOMATION_FAILED` records the run as `error`, with the lines that follow as the error text. The existing failure handling then applies: error backoff, plus failure alerts and owner-conversation repair for jobs that already have a failure route or `failureAlert` config.
- Announce jobs still deliver the agent's explanation, with the token removed.
- These stay ok: `NO_REPLY` runs, and replies that mention the token anywhere other than as the exact first line.
- **No change to notification contracts.** An unconfigured `delivery: none` job still sends nothing to chat (no alert, no repair request). It now records the error in run history and job status (`lastRunStatus`, `consecutiveErrors`).

**Not fixed here:**
- A delegated (spawn-only) `delivery: none` run still ends `ok` and drops its child's result. The parent never sees the child's reply, so it can't report that failure with the token. Since openclaw#135318, cron turns also can't `sessions_yield`. A separate PR fixes settlement at openclaw#117308's spawn-only path.
- Notifying owners of failing `delivery: none` jobs is a pending product decision and is not part of this PR.

## Why This Change Was Made

Provenance:
- openclaw#110949 added the unattended-run preamble. It tells the model "If something failed, state plainly what failed … the scheduler owns retries and failure alerts", but no structured fact carried that statement. The scheduler only fails runs on run-level errors, error payloads, or exec-denied tool errors (`failure-signal.ts`, `execution_denied`).
- openclaw#126164 and openclaw#131228 deliberately keep execution status separate from delivery outcome. This PR keeps that separation: the token is an execution outcome the agent reports. It is parsed in the existing cron outcome owner (`resolveCronPayloadOutcome`), next to `failureSignal`, and is never derived from delivery.

The token is a strict control line, like `NO_REPLY`. Only an exact first line counts, so ordinary prose is never classified. Hermes Agent uses the same mechanism for cron (`[CRON_FAILURE]` on the first line; `cron/scheduler_prompt.py`, `cron/scheduler.py`). The preamble sentence is reworded in place: similar length, still static for prompt caching.

## Bounded cost

New or changed paths that could lead to a model call or a job run:

- **The token parse.** No new turns, runs, or notifications. It only changes the recorded status of the run that produced the reply. It is parsed only in cron finalization for that run. The delivered explanation is outbound text, never inbound, so there is no self-trigger.
- **Error status → scheduler.**
  - One-shot jobs: an agent-reported failure carries `errorClassification: { kind: "permanent" }`, so it never enters the transient-retry path. This also means wording like "network timeout" in the explanation is never text-classified into a retry or an error reason. **Tested** in `run.meta-error-status.test.ts`.
  - Recurring jobs: the existing error backoff only delays the next run (natural schedule or later), and the existing auto-disable stops the job after 10 consecutive errors. Nothing runs sooner than scheduled.
- **Repair turns.** Unchanged. They still happen only for jobs with an existing chat failure route (openclaw#161007): at most one per failure incident, and the incident marker is persisted in job state. A repair turn can't start runs, because automation control is owner-only and the request carries no sender identity. It is an ordinary conversation turn, not a cron run, so its own failure can't open another repair.
- **The preamble text.** Static; it adds no turns.

## Evidence

Isolated Gateway, qa-lab mock-openai, new scenario `qa/scenarios/scheduling/cron-blocked-outcome.yaml`:

- **Before** (origin/main): a `delivery: none` job whose reply starts with `AUTOMATION_FAILED` → `status: "ok"`, `completionStatus: "succeeded"`, and the summary holds the blocker text.
- **After:** see the result comment below. The scenario checks:
  - An owned `delivery: none` job, run 3 times → each run is `error` with the reported reason; no repair request and no chat message.
  - An unowned announce job, run twice → `error`; the reason is delivered without the token, and the existing `failed 2 times` alert fires.
  - A mid-text quote, and `NO_REPLY` (with and without announce) → `ok`.

Focused tests (fail before, pass after): `src/cron/isolated-agent/run.meta-error-status.test.ts` covers token → `error` + permanent classification, and a mid-text quote → `ok` (two cases, about 1.7 s each in the shared harness). Also passing: `failure-alerts.{account-routing,persistence,recovery}`, `service.failure-repair`, and `run.message-tool-policy` (116 tests). `pnpm tsgo:core` and oxlint on the changed files are clean. `run.message-tool-policy.test.ts` no longer pins the full preamble wording; it keeps the ordering assertion.

LOC vs origin/main: production +36/−7, unit tests +24/−2, QA scenario and mock about +180, docs +1/−1.


## Upgrade compatibility

No migration is required. The diff touches no schema, store, codec or persisted type file. Run history keeps the existing `CronRunStatus` values (`ok | error | skipped`) and the existing error/permanent classification fields, so rows written before and after this change go through the same unchanged readers. The QA scenario's "repair" wording refers to the scheduler's automation repair request, not a data repair. Existing-state compatibility is verified by the unchanged `failure-alerts.persistence` and `service.failure-repair` suites passing on this head.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 2, 2026
…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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 2, 2026
…w#162695)

## What Problem This Solves

Follow-up to openclaw#160996. The cron authoring guidance (docs `payloads.md` and the automations tool description) said failure notifications wait for consecutive failed runs, "so a one-off outage stays quiet". That isn't true, so the guidance taught models a wrong cost for failing loudly:

- A command payload with announce delivery still delivers its output when it exits non-zero: `runCommandJob` in `src/gateway/server-cron.ts` passes the summary to completion delivery without checking the exit status.
- Since openclaw#162391, an agent's `AUTOMATION_FAILED` explanation is delivered for announce jobs.

## Solution

Only the failure alert waits for consecutive failures; the run's own output still follows the job's delivery setting. Both places now say exactly that. The tool description stays static (prompt-cache stable) and grows by 12 characters. Prompt snapshots are regenerated.

## User Impact

No runtime behavior change. Models writing automations get accurate guidance about what a failed run sends.

## Evidence

The automations tool description an agent actually receives, taken from the regenerated prompt snapshot (`codex-dynamic-tools.telegram-direct.json`, built by the real prompt builder):

- Before: `throw from the script so the run records the failure (returning {error} still succeeds); failure alerts already wait for consecutive failures, so a one-off failure stays quiet.`
- After: `throw from the script so the run records the failure (returning {error} still succeeds); only the failure alert waits for consecutive failures, run output still follows the job's delivery.`

Checks on the exact head:

- `pnpm run prompt:snapshots:check`: snapshots are current (7 files).
- `node scripts/run-vitest.mjs src/agents/tools/cron-tool.test.ts`: 72 passed.

Text-only change, so no live channel proof applies: no message, delivery or runtime path changes.


Runtime output from a real OpenClaw setup on head `15919727aaa`: the actual `createCronTool()` builder run in an isolated state dir (default config), printing the failure-guidance sentences of the `automations` tool description an agent receives:

```text
tool: automations
When a run fails, throw from the script so the run records the failure (returning {error} still succeeds); only the failure alert waits for consecutive failures, run output still follows the job's delivery.
FAILURE ALERTS: jobs with a failure route default to alerting after 2 consecutive execution failures with a 1h cooldown.
```

The same sentence on `origin/main` read: `…failure alerts already wait for consecutive failures, so a one-off failure stays quiet.`

Co-authored-by: Ayaan Zaidi <[email protected]>
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 extensions: qa-lab gateway Gateway runtime P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant