Skip to content

fix(cron): delegated blocked runs report ok and silent blocked jobs get auto-disabled - #162686

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

obviyus merged 5 commits into
mainfrom
fix/cron-blocked-outcome-followup

Conversation

@obviyus

@obviyus obviyus commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

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 fix(cron): no-delivery spawn-only runs drop the child's result #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. fix(cron): blocked scheduled runs are recorded as ok #162391 classified the token in 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 in dispatchCronDelivery then 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 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).
  • 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 consecutiveErrors1…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): ⚠️ Your "Nightly ledger sync" automation was automatically disabled after 10 consecutive failures. … openclaw automations enable `. 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 fix(cron): no-delivery spawn-only runs drop the child's result #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.

@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 re-review

@clawsweeper

clawsweeper Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 1, 2026
@clawsweeper

clawsweeper Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 1, 2026, 12:49 PM ET / 16:49 UTC (Revision 7).

ClawSweeper review

What this changes

The 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
Reviewed head: 8b77715ba4f1b5514b94872f161f540620067b6d

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with strong before/after runtime evidence, meaningful regressions, and no remaining actionable findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The captured exact-head Telegram Test Server observations exercise production child settlement, finalization, outbound delivery, and eleven scheduled silent failures with a live provider: failure status and token removal improve, and silent jobs remain enabled without notices. The ingress limitation does not bypass these changed owners. The new classification flag is transient; stored-data formats remain unchanged.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The captured exact-head Telegram Test Server observations exercise production child settlement, finalization, outbound delivery, and eleven scheduled silent failures with a live provider: failure status and token removal improve, and silent jobs remain enabled without notices. The ingress limitation does not bypass these changed owners. The new classification flag is transient; stored-data formats remain unchanged.
Evidence reviewed 8 items Pinned introduced changes: Reviewed the merge-base-to-head delta, independently of base-only changes. The child-answer adoption uses the existing failure parser, and finalization carries the resulting permanent agent-reported classification.
Current main still needs the repair: Current main has no settled-child failure accumulator or silent agent-report exemption; its existing child adoption and recurring failure cutoff do not implement the requested follow-ups. The latest supplied release predates the October 1 prerequisite merges.
Prior findings resolved: The cleanup decision now recognizes a settled child's failure before deleting a no-delivery transcript. The added regression checks that sessions.delete is not called, and delivery documentation explains the exception while retaining consecutiveErrors and backoff.
Findings None None.
Security None None.

How this fits together

OpenClaw’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]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +29, Tests +99, Docs 0. Total +128 across 11 files.

View PR surface stats
Area Files Added Removed Net
Source 6 54 25 +29
Tests 3 100 1 +99
Docs 2 2 2 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 11 156 28 +128

Review metrics

Metric Value Why it matters
Production versus regression growth production net +29 lines; tests net +99 lines Production growth carries failure provenance through existing owners; regressions cover delivery, transcript retention, and scheduler backoff without adding a second counter.

Technical review

Best 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.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded automation outcome and notification repair with direct runtime evidence.
  • merge-risk: 🚨 availability: The accepted policy keeps silent agent-reported failures running beyond ten failures at the existing backed-off cadence, with the documented startup-replay limitation.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster 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): The captured exact-head Telegram Test Server observations exercise production child settlement, finalization, outbound delivery, and eleven scheduled silent failures with a live provider: failure status and token removal improve, and silent jobs remain enabled without notices. The ingress limitation does not bypass these changed owners. The new classification flag is transient; stored-data formats remain unchanged.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured exact-head Telegram Test Server observations exercise production child settlement, finalization, outbound delivery, and eleven scheduled silent failures with a live provider: failure status and token removal improve, and silent jobs remain enabled without notices. The ingress limitation does not bypass these changed owners. The new classification flag is transient; stored-data formats remain unchanged.
  • proof: telegram-e2e: This PR needs Telegram Test Server proof with the repository E2E skill. Token removal and suppression of silent-job auto-disable notices are Telegram-visible behavior, covered by the supplied Test Server proof.

Evidence

What I checked:

  • Pinned introduced changes: Reviewed the merge-base-to-head delta, independently of base-only changes. The child-answer adoption uses the existing failure parser, and finalization carries the resulting permanent agent-reported classification. (src/cron/isolated-agent/delivery-dispatch.ts:89, 8b77715ba4f1)
  • Current main still needs the repair: Current main has no settled-child failure accumulator or silent agent-report exemption; its existing child adoption and recurring failure cutoff do not implement the requested follow-ups. The latest supplied release predates the October 1 prerequisite merges. (src/cron/service/timer-outcomes.ts:187, c66d7fbc08ac)
  • Prior findings resolved: The cleanup decision now recognizes a settled child's failure before deleting a no-delivery transcript. The added regression checks that sessions.delete is not called, and delivery documentation explains the exception while retaining consecutiveErrors and backoff. (src/cron/isolated-agent/delivery-dispatch.ts:120, 8b77715ba4f1)
  • Exact-head real behavior proof: The captured PR body reports Telegram Test Server runs using a live provider on head 8b77715. Announce settlement changes from ok with the visible control token to error with only the explanation delivered; no-delivery settlement records error without a message. Eleven normally scheduled silent failures leave the job enabled, advance the error streak to 11, and produce no auto-disable notice. Telegram ingress was unavailable on both sides, but the exercised scheduler and outbound delivery paths operated. These are supplied runtime observations, not reviewer-executed tests. (8b77715ba4f1)
  • Accepted recovery and scheduling tradeoffs: The owner decision at fix(cron): delegated blocked runs report ok and silent blocked jobs get auto-disabled #162686 (comment) accepts leaving finalized-run startup replay unchanged without a history schema extension. Repository permission inspection verifies that obviyus has write permission. The body also accepts that a later runtime error can disable a silent job whose accumulated streak already exceeds the cutoff; continued agent-reported failures retain normal backoff. (src/cron/service/timer-outcomes.ts:191, 8b77715ba4f1)
  • Stored-data boundary unchanged: reportedByAgent is an execution-result fact consumed by scheduler policy. The unchanged run-event codec persists existing status, error, and error-reason fields rather than this new flag; no schema, config migration, or serialized-format change is introduced. (src/cron/run-event-codec.ts:25, 8b77715ba4f1)

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 (6 earlier review cycles)
  • reviewed 2026-10-01T12:35:15.805Z sha 0530dc9 :: needs changes before merge. :: [P2] Preserve the silent-failure exemption through finalized-run recovery
  • reviewed 2026-10-01T13:39:44.746Z sha ee6d9e07fdf04f3a3bb50dc98ec20957b53085a4 :: needs changes before merge. :: [P3] Document the silent agent-failure exception to auto-disable
  • reviewed 2026-10-01T14:02:39.976Z sha bfe1f0f :: blocked before merge. :: [P2] Retain the transcript when a settled child reports failure | [P3] Document the silent agent-failure exception to auto-disable
  • reviewed 2026-10-01T14:31:16.533Z sha bfe1f0f :: blocked before merge. :: [P2] Retain the transcript when a settled child reports failure | [P3] Document the silent agent-failure exception to auto-disable
  • reviewed 2026-10-01T16:15:17.385Z sha 8b77715 :: needs changes before merge. :: none
  • reviewed 2026-10-01T16:41:44.894Z sha 8b77715 :: needs changes before merge. :: none

@obviyus

obviyus commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator Author

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

@clawsweeper

clawsweeper Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@obviyus
obviyus force-pushed the fix/cron-blocked-outcome-followup branch from 0530dc9 to ee6d9e0 Compare October 1, 2026 13:34
@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. 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. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 1, 2026
@obviyus
obviyus force-pushed the fix/cron-blocked-outcome-followup branch from 8e15da1 to bfe1f0f Compare October 1, 2026 13:54
@clawsweeper clawsweeper Bot added merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed 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. labels Oct 1, 2026
@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 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:

@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Oct 1, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. 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: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 1, 2026
@obviyus
obviyus marked this pull request as ready for review October 1, 2026 16:44
@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 2f4d475 into main Oct 1, 2026
219 checks passed
@obviyus
obviyus deleted the fix/cron-blocked-outcome-followup branch October 1, 2026 17:00
@obviyus

obviyus commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator Author

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.

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]>
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 merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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