Skip to content

feat(cron): teach the automations tool to script repeatable job logic - #160996

Merged
obviyus merged 6 commits into
mainfrom
feat/cron-authoring-guidance
Sep 30, 2026
Merged

obviyus merged 6 commits into
mainfrom
feat/cron-authoring-guidance

Conversation

@obviyus

@obviyus obviyus commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Agents build recurring automations that redo all their bookkeeping in the prompt on every fire (discovering tools, re-reading state files, diffing listings by hand), which makes quiet hourly runs take 7–16 model responses and time out on slow networks, and they post raw errors to the chat on one-off outages.

User Impact

When the model creates or edits a recurring automation, the automations tool now tells it to keep the model for judgment only: repeatable logic goes in a workspace script run in one exec, detailed instructions live in a workspace file the message references ("Follow scripts/.md") so most fixes are file edits rather than job updates, the message names exact tools and arguments, toolsAllow is capped, and a trigger or script payload skips the model on quiet fires. A failed run should fail with a signal the scheduler records (throw from trigger or script payload JavaScript, or, for CLI-authored jobs in the docs, exit non-zero from a command payload; a script that returns an error field still succeeds), and failure accounting stays with the scheduler: failure alerts already wait for consecutive failed runs, so one-off outages stay quiet without scripts counting failures themselves. The docs describe the same pattern.

Why This Change Was Made

On a live gateway, rewriting two hourly MCP-backed sync jobs this way (a helper script owning diff, dedupe, checkpoints and failure counting; exact tool calls; a tight toolsAllow) cut quiet runs from 7–16 model responses to 3–4 and from minutes to 25–70 s. The tool description is the owner for this guidance because it is only present when the automations tool is available, so it adds no cost elsewhere. The script sentence, including the failure signal, is omitted when cron.triggers.enabled is false (scripts are unavailable then), and it does not mention command payloads because the agent automations tool cannot create them.

LOC vs origin/main on top of #160995: production +5 (tool description), docs +26, regenerated prompt snapshots ±25.

Evidence

  • Failure signals checked against source: trigger evaluation errors return status: "error" (src/cron/service/timer-execution.ts), a thrown script payload takes the headless failure path, and parseScriptPayloadResult treats a returned { error } object as completed.
  • pnpm prompt:snapshots:check: current (4 fixture files regenerated with pnpm prompt:snapshots:gen).
  • src/agents/tools/cron-tool.test.ts: 71/71 pass. pnpm docs:check-links: 0 broken. git diff --check clean.
  • Adds about 210 tokens to the automations tool description when triggers are enabled.

@clawsweeper

clawsweeper Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

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

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: S labels Sep 29, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. 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 Sep 29, 2026
@clawsweeper

clawsweeper Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 29, 2026, 9:55 PM ET / September 30, 2026, 01:55 UTC (Revision 5).

ClawSweeper review

What this changes

The branch adds recurring-job scripting guidance to the automations tool and public docs, then refreshes Codex prompt snapshots to reflect the new wording.

Merge readiness

✅ Ready for maintainer review

Keep open. Current main lacks this authoring guidance, the stacked MCP runtime has merged, and the earlier failure-accounting concern is resolved. No actionable patch defect remains.

Priority: P2
Reviewed head: 247167232d25e092c066ba1ffc0dcffed8e1a1d0

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused guidance matches the landed runtime contracts and has no identified correctness or security blocker.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: The provided Repository State identifies a MEMBER author, so the external contributor proof gate does not apply. The changed production owner is the automations tool description; reported live improvements from rewritten jobs do not directly show an agent authoring from this wording. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The provided Repository State identifies a MEMBER author, so the external contributor proof gate does not apply. The changed production owner is the automations tool description; reported live improvements from rewritten jobs do not directly show an agent authoring from this wording. No stored-data contract changes.
Evidence reviewed 8 items Introduced guidance: The branch adds the recurring-job authoring cue and gates its headless-script advice on triggers being enabled.
Current-main gap: Current main has trigger and payload guidance but no recurring-job authoring cue, so this PR still has a distinct contribution.
Merged prerequisite: GitHub reports #160995 merged on 2026-09-30; its commit is an ancestor of the reviewed main revision.
Findings None None.
Security None None.

How this fits together

Agents receive the automations tool description when creating or editing Gateway jobs. The scheduler later executes those jobs and records outcomes for history and failure alerts.

flowchart LR
  A[User request] --> B[Automations tool guidance]
  B --> C[Saved recurring job]
  C --> D[Gateway scheduler]
  D --> E[Script or agent turn]
  E --> F[Run outcome]
  F --> G[History and alerts]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +5, Tests 0, Docs +26. Total +31 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 1 5 0 +5
Tests 4 25 25 0
Docs 1 26 0 +26
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 56 25 +31

Review metrics

Metric Value Why it matters
Model-facing context +213 rough tokens in the Codex dynamic-tool snapshot The authoring cue adds measurable context when the automations tool catalog is provided.

Technical review

Best possible solution:

Keep the cue concise and aligned with the landed script runtime while leaving tool authorization and failure accounting with their existing owners.

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

Not applicable: this PR adds authoring guidance rather than reporting a broken existing behavior. Its wording and the runtime contracts it describes are inspectable in source.

Is this the best way to solve the issue?

Yes. The existing automations tool description and public payload docs are appropriate owners for this guidance now that the referenced runtime capability has merged.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against ff21cc82ce5f.

Labels

Label changes:

  • remove merge-risk: 🚨 other: Current PR review selected no merge-risk labels.

Label justifications:

  • P2: This is a focused recurring-automation improvement with limited blast radius.
  • 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. Not applicable: The provided Repository State identifies a MEMBER author, so the external contributor proof gate does not apply. The changed production owner is the automations tool description; reported live improvements from rewritten jobs do not directly show an agent authoring from this wording. No stored-data contract changes.

Evidence

What I checked:

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • Peter Steinberger: 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 (4 earlier review cycles)
  • reviewed 2026-09-29T05:51:12.967Z sha 474a6e5 :: blocked before merge. :: [P2] Name a failure signal the scheduler recognizes
  • reviewed 2026-09-29T12:24:38.505Z sha 08be5ca :: blocked before merge. :: none
  • reviewed 2026-09-29T12:40:20.568Z sha 63e6b88 :: blocked before merge. :: [P1] Keep failure accounting with the scheduler
  • reviewed 2026-09-29T12:51:45.855Z sha e2d9852 :: blocked before merge. :: none

@obviyus
obviyus force-pushed the feat/cron-authoring-guidance branch from 474a6e5 to 7ad1f28 Compare September 29, 2026 12:11
@obviyus

obviyus commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@obviyus

obviyus commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added 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 Sep 29, 2026
@obviyus
obviyus force-pushed the feat/cron-authoring-guidance branch from 08be5ca to 63e6b88 Compare September 29, 2026 12:32
@obviyus

obviyus commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added 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 Sep 29, 2026
@obviyus

obviyus commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot 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 Sep 29, 2026
@clawsweeper clawsweeper Bot added 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 Sep 29, 2026
@obviyus
obviyus force-pushed the feat/cron-headless-mcp branch 4 times, most recently from d2326f8 to 0198233 Compare September 29, 2026 17:52
Base automatically changed from feat/cron-headless-mcp to main September 30, 2026 01:47
@obviyus
obviyus force-pushed the feat/cron-authoring-guidance branch from e2d9852 to 2471672 Compare September 30, 2026 01:49
@obviyus
obviyus marked this pull request as ready for review September 30, 2026 01:49
@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. label Sep 30, 2026
@obviyus
obviyus merged commit b2bc8f0 into main Sep 30, 2026
267 of 278 checks passed
@obviyus
obviyus deleted the feat/cron-authoring-guidance branch September 30, 2026 02:07
@obviyus

obviyus commented Sep 30, 2026

Copy link
Copy Markdown
Collaborator Author

Landed as b2bc8f0 (squash of 2471672) on green CI and a ready hosted review at that head.

The automations tool description and cron docs now guide agents to write repeatable job logic as trigger/script code, to signal failure by throwing (or exiting non-zero for command payloads) because a returned {error} still counts as success, to leave failure alerting to the scheduler's consecutive-failure threshold, and to keep detailed job instructions in a workspace file the job message references. Prompt snapshots were regenerated after rebasing onto main once #160995 landed; focused cron tool tests pass (91/91).

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 30, 2026
…openclaw#160996)

## What Problem This Solves

Agents build recurring automations that redo all their bookkeeping in the prompt on every fire (discovering tools, re-reading state files, diffing listings by hand), which makes quiet hourly runs take 7–16 model responses and time out on slow networks, and they post raw errors to the chat on one-off outages.

## User Impact

When the model creates or edits a recurring automation, the automations tool now tells it to keep the model for judgment only: repeatable logic goes in a workspace script run in one `exec`, detailed instructions live in a workspace file the message references ("Follow scripts/<job>.md") so most fixes are file edits rather than job updates, the message names exact tools and arguments, `toolsAllow` is capped, and a trigger or script payload skips the model on quiet fires. A failed run should fail with a signal the scheduler records (throw from trigger or script payload JavaScript, or, for CLI-authored jobs in the docs, exit non-zero from a command payload; a script that returns an error field still succeeds), and failure accounting stays with the scheduler: failure alerts already wait for consecutive failed runs, so one-off outages stay quiet without scripts counting failures themselves. The docs describe the same pattern.

## Why This Change Was Made

On a live gateway, rewriting two hourly MCP-backed sync jobs this way (a helper script owning diff, dedupe, checkpoints and failure counting; exact tool calls; a tight `toolsAllow`) cut quiet runs from 7–16 model responses to 3–4 and from minutes to 25–70 s. The tool description is the owner for this guidance because it is only present when the automations tool is available, so it adds no cost elsewhere. The script sentence, including the failure signal, is omitted when `cron.triggers.enabled` is false (scripts are unavailable then), and it does not mention command payloads because the agent automations tool cannot create them.

LOC vs `origin/main` on top of openclaw#160995: production +5 (tool description), docs +26, regenerated prompt snapshots ±25.

## Evidence

- Failure signals checked against source: trigger evaluation errors return `status: "error"` (`src/cron/service/timer-execution.ts`), a thrown script payload takes the headless failure path, and `parseScriptPayloadResult` treats a returned `{ error }` object as completed.
- `pnpm prompt:snapshots:check`: current (4 fixture files regenerated with `pnpm prompt:snapshots:gen`).
- `src/agents/tools/cron-tool.test.ts`: 71/71 pass. `pnpm docs:check-links`: 0 broken. `git diff --check` clean.
- Adds about 210 tokens to the automations tool description when triggers are enabled.

No overlap with Pash/Sarah changes (their commits on the shared prompt snapshot fixtures cover Codex attribution and developer instructions, not the automations description).

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
…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

agents Agent runtime and tooling docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. 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