Repository navigation
feat(cron): teach the automations tool to script repeatable job logic - #160996
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 29, 2026, 9:55 PM ET / September 30, 2026, 01:55 UTC (Revision 5). ClawSweeper reviewWhat this changesThe 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 Review scores
Verification
How this fits togetherAgents 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]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +5, Tests 0, Docs +26. Total +31 across 6 files. View PR surface stats
Review metrics
Technical reviewBest 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. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
474a6e5 to
7ad1f28
Compare
|
@clawsweeper review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper review |
|
🦞👀 Re-review progress:
|
08be5ca to
63e6b88
Compare
|
@clawsweeper review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper review |
|
🦞👀 Re-review progress:
|
d2326f8 to
0198233
Compare
e2d9852 to
2471672
Compare
|
Landed as b2bc8f0 (squash of 2471672) on green CI and a 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 |
…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]>
## 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]>
…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]>
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,toolsAllowis 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 whencron.triggers.enabledis false (scripts are unavailable then), and it does not mention command payloads because the agent automations tool cannot create them.LOC vs
origin/mainon top of #160995: production +5 (tool description), docs +26, regenerated prompt snapshots ±25.Evidence
status: "error"(src/cron/service/timer-execution.ts), a thrown script payload takes the headless failure path, andparseScriptPayloadResulttreats a returned{ error }object as completed.pnpm prompt:snapshots:check: current (4 fixture files regenerated withpnpm prompt:snapshots:gen).src/agents/tools/cron-tool.test.ts: 71/71 pass.pnpm docs:check-links: 0 broken.git diff --checkclean.