openclaw/test
Ayaan Zaidi b2bc8f05e7
feat(cron): teach the automations tool to script repeatable job logic (#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 #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 <hi@obviy.us>
2026-09-30 10:07:07 +08:00
..
contracts
e2e refactor(gateway): deslop gateway core files (#159999) 2026-09-29 18:47:40 -07:00
fixtures feat(cron): teach the automations tool to script repeatable job logic (#160996) 2026-09-30 10:07:07 +08:00
helpers fix(test): capture startup diagnostics after pipe drainage 2026-09-29 14:40:10 -07:00
mocks
plugins refactor(cron): move guarded job writes off the Gateway thread (#161241) 2026-09-29 10:42:51 -07:00
scripts feat(ios): distribute daily TestFlight builds for external testing (#161460) 2026-09-29 20:43:46 -05:00
tsconfig fix: dashboards require approval after native app authentication (#159860) 2026-09-28 16:16:53 -06:00
type-contracts refactor(cron): read run history through its worker (#158222) 2026-09-26 00:07:06 -07:00
types refactor(mcp): bind idle cleanup to the lifecycle scheduler (#159481) 2026-09-27 22:54:48 +00:00
vitest test(core,discord,ui): remove low-value tests (batch d100) (#161213) 2026-09-30 00:05:14 +00:00
agent-exec-code-mode.live.test.ts fix(test): restore the installed Code Mode live fixture (#153442) 2026-09-19 22:55:17 -07:00
AGENTS.md
apns-worker-test-ownership.test.ts test: diagnose stalled infra test workers (#152381) 2026-09-19 03:53:39 -07:00
appcast.test.ts fix: keep cold child compilation outside CI test deadlines (#156011) 2026-09-22 17:41:19 -07:00
architecture-smells.test.ts test(core, plugins, ui): remove low-value tests (batch d040) (#159093) 2026-09-26 18:32:26 +00:00
buzz-account-config-mutation.test.ts
canonical-descendant.integration.test.ts refactor(mcp): bind idle cleanup to the lifecycle scheduler (#159481) 2026-09-27 22:54:48 +00:00
channel-message-read-authority.integration.test.ts refactor: reuse live placement authority for worker checks (#155898) 2026-09-24 00:24:40 -07:00
clawrouter-managed-gateway.e2e.test.ts fix(clawrouter): enable transport logs in managed Gateway test (#158457) 2026-09-25 17:23:54 -07:00
cli-json-stdout.agents.e2e.test.ts test(cli): trim redundant agent process cases (#153993) 2026-09-20 23:19:41 -07:00
cli-json-stdout.automation.e2e.test.ts refactor: remove Tasks and TaskFlow runtime (#159179) 2026-09-27 10:40:29 -07:00
cli-json-stdout.config.e2e.test.ts
cli-json-stdout.e2e.test.ts fix(state): repair index-only corruption explicitly in Doctor (#156761) 2026-09-24 13:38:25 -07:00
cli-json-stdout.gateway.e2e.test.ts fix(health): surface config read failures from the non-observing health reader (#160885) 2026-09-29 02:11:20 +00:00
cli-json-stdout.hooks.e2e.test.ts fix(test): execute CLI fixture preloads on Node and Bun (#152076) 2026-09-18 15:12:46 -07:00
cli-json-stdout.models.e2e.test.ts fix(test): align CLI release fixtures with runtime owners (#157780) 2026-09-25 14:11:51 -07:00
cli-json-stdout.plugins.e2e.test.ts fix(test): execute CLI fixture preloads on Node and Bun (#152076) 2026-09-18 15:12:46 -07:00
cli-json-stdout.sessions.e2e.test.ts test(cli): trim redundant session process cases (#153994) 2026-09-20 23:19:04 -07:00
cli-json-stdout.skills.e2e.test.ts test(cli): restore skills process coverage (#154686) 2026-09-21 15:52:00 -07:00
cli-json-stdout.test-support.ts fix(test): execute CLI fixture preloads on Node and Bun (#152076) 2026-09-18 15:12:46 -07:00
cli-message-authority.integration.test.ts refactor: reuse live placement authority for worker checks (#155898) 2026-09-24 00:24:40 -07:00
cli-state-sqlite.e2e.test.ts
codex-node-cancellation.integration.test.ts fix(codex): keep catalog actions bound to their source (#151854) 2026-09-19 02:32:25 -07:00
codex-settled-turn-finalization.integration.test.ts
control-ui-import-boundary.test.ts
conversation-tools.codex.integration.test.ts fix(codex): preserve delivery facts and native approval semantics (#151863) 2026-09-19 16:45:20 -07:00
copilot-tool-policy-handoff.integration.test.ts
copilot-tool-policy-handoff.live.test.ts
cron-conversation-delivery.codex.integration.test.ts fix(codex): preserve delivery facts and native approval semantics (#151863) 2026-09-19 16:45:20 -07:00
cron-edit-trigger-preservation.e2e.test.ts
cron-message-read.integration.test.ts test: isolate maintainer and scheduled-message fixtures (#159200) 2026-09-26 16:22:45 -07:00
discord-live-policy.integration.test.ts refactor(cron): move due timers into the Gateway scheduler (#159099) 2026-09-26 18:54:20 +00:00
discord-metadata-read-authority.integration.test.ts fix: avoid blocking channel operations on stored account credentials (#156267) 2026-09-23 03:27:50 -07:00
docker-entrypoint.test.ts fix(startup): keep legacy state repair in Doctor (#151025) 2026-09-25 13:43:40 -07:00
doctor-copied-state-migration.e2e.test.ts fix: avoid slow task lookups and maintenance as history grows (#153548) 2026-09-20 03:00:27 -07:00
doctor-legacy-whatsapp-ack-migration.e2e.test.ts
dreaming-startup-cleanup.e2e.test.ts
embedded-transcript-cursor.e2e.test.ts
extension-import-boundaries.test.ts
extension-test-boundary.test.ts ci: reduce Node fixture overhead and defer seven release matrices (#157341) 2026-09-24 08:17:47 -07:00
external-script-modules.d.ts fix(release): release notes abort when a commit body mentions a deleted PR (#160305) 2026-09-28 02:11:49 -07:00
feishu-message-mutations.integration.test.ts
feishu-message-read-authority.integration.test.ts refactor: reuse live placement authority for worker checks (#155898) 2026-09-24 00:24:40 -07:00
gateway-a2a.e2e.test.ts fix(a2a): complete tasks under message-tool-only reply policy (#154317) 2026-09-21 18:32:35 +05:30
gateway-account-history.e2e.test.ts test(gateway): await account-history turn settlement (#157530) 2026-09-24 13:56:36 -07:00
gateway-cold-agent-abort.e2e.test.ts refactor: remove Tasks and TaskFlow runtime (#159179) 2026-09-27 10:40:29 -07:00
gateway-completion-replay.e2e.test.ts fix(state): fail readiness on shared-state integrity loss (#156700) 2026-09-23 22:58:58 +00:00
gateway-copied-codex-session-resume.e2e.test.ts
gateway-external-state-ownership.e2e.test.ts fix: prevent temporary-file exhaustion from SQLite coordination (#157413) 2026-09-27 05:30:41 -07:00
gateway-hook-concurrency.e2e.test.ts
gateway-no-op-mutation.e2e.test.ts
gateway-openai-compaction-replay.e2e.test.ts
gateway-queued-session-rotation.e2e.test.ts
gateway-restored-requester-settle.e2e.test.ts test(release): repair release-check lanes after settle, Responses body, and scheduler changes 2026-09-28 16:18:09 -07:00
gateway-rpc-exporters.test.ts
gateway-session-end-shutdown.e2e.test.ts
gateway-steer-fifo.e2e.test.ts fix(test): restore gateway steering fixture contracts (#158478) 2026-09-25 22:42:41 -07:00
gateway-subagent-restart.live.test.ts refactor: remove Tasks and TaskFlow runtime (#159179) 2026-09-27 10:40:29 -07:00
gateway-widget-restart.live.test.ts
gateway.multi.e2e.test.ts refactor(cron): move due timers into the Gateway scheduler (#159099) 2026-09-26 18:54:20 +00:00
git-hooks-pre-commit-boundaries.test.ts improve(tooling): reduce commit formatting resource use (#152297) 2026-09-18 18:01:21 -07:00
git-hooks-pre-commit.test-support.ts
git-hooks-pre-commit.test.ts test(runtime,ui,tooling): remove low-value tests (batch d013) (#158691) 2026-09-26 08:48:53 +00:00
github-cli-preflight.e2e.test.ts
huggingface-local-app-openclaw.e2e.test.ts
image-generation.infer-cli.live.test.ts
image-generation.runtime.live.test.ts
imessage-reply-alias.integration.test.ts fix(telegram): retain discussion between mentions without flooding context (#151911) 2026-09-19 09:40:19 +05:30
jsdom-compat.mts perf(test): defer jsdom loading for Node tests (#158125) 2026-09-25 06:52:00 -07:00
jsdom-compat.test.ts fix(tooling): enforce Linux process-tree memory limits (#160024) 2026-09-28 11:58:07 +08:00
jsdom-custom-elements.test.ts
jsdom-custom-elements.ts chore(deps): refresh dependencies with a seven-day cutoff (#157238) 2026-09-25 02:38:45 +00:00
line-question-gateway.test.ts
linux-dashboard-recovery.test.ts fix(linux): show clear update status and recover release-page retries (#158037) 2026-09-25 18:22:02 +08:00
linux-quickchat-stream.test.ts perf(gateway): stream append deltas to every client (#158587) 2026-09-27 05:53:39 +00:00
loopback-ask-user-telegram-channel.test.ts
matrix-channel-read-authority.integration.test.ts refactor: reuse live placement authority for worker checks (#155898) 2026-09-24 00:24:40 -07:00
matrix-client-crypto-authority.integration.test.ts
matrix-transport-read-authority.integration.test.ts
mcp-show-redact.e2e.test.ts
msteams-read-authority.integration.test.ts refactor: reuse live placement authority for worker checks (#155898) 2026-09-24 00:24:40 -07:00
msteams-read-target.integration.test.ts refactor: reuse live placement authority for worker checks (#155898) 2026-09-24 00:24:40 -07:00
node-host-launcher.test.ts perf(plugins): reuse and bound CLI compile caches (#157528) 2026-09-24 20:18:39 +00:00
non-isolated-runner.agent-reader-fixtures.ts fix: close agent database readers between test files (#153749) 2026-09-20 07:33:20 -07:00
non-isolated-runner.gateway-lifecycle-fixtures.ts
non-isolated-runner.mock-resolution-fixtures.ts
non-isolated-runner.sqlite-fixtures.ts fix: retain shared-state snapshots through worker failures (#160946) 2026-09-29 07:40:30 -07:00
non-isolated-runner.sqlite.test.ts fix(test): retire subagent sweepers before SQLite owners 2026-09-28 23:38:55 -07:00
non-isolated-runner.test-api-fixtures.ts refactor: remove Tasks and TaskFlow runtime (#159179) 2026-09-27 10:40:29 -07:00
non-isolated-runner.test.ts test(runner): assert the gateway drain by error name in the cleanup fixture 2026-09-28 23:29:40 -07:00
non-isolated-runner.ts fix(test): retire subagent sweepers before SQLite owners 2026-09-28 23:38:55 -07:00
npm-publish-plan.test.ts chore(release): retire the internal Tideclaw alpha release track (#160261) 2026-09-28 10:01:49 -07:00
oauth-refresh-authority-chain.e2e.test.ts test(e2e): seed OAuth authority-chain shared store through its owner 2026-09-28 18:48:40 -07:00
official-channel-catalog.test.ts fix(agentmail): allow official ClawHub channel to load (#155097) 2026-09-28 16:10:33 -07:00
onboard-plugin-warnings.e2e.test.ts
openai-model-discovery-auth-order.test.ts test(runtime,ui,tooling): remove low-value tests (batch d013) (#158691) 2026-09-26 08:48:53 +00:00
openai-onboarding.live.test.ts
openclaw-launcher-version.e2e.test.ts perf(plugins): reuse and bound CLI compile caches (#157528) 2026-09-24 20:18:39 +00:00
openclaw-launcher.e2e.test.ts refactor: remove Tasks and TaskFlow runtime (#159179) 2026-09-27 10:40:29 -07:00
openclaw-npm-postpublish-verify.test.ts fix(release): admit 2026.9.7 recovery helper and plugin scan inventory (#160717) 2026-09-28 14:36:10 -07:00
openclaw-npm-prepublish-verify.test.ts
openclaw-npm-release-check.test.ts chore(release): retire the internal Tideclaw alpha release track (#160261) 2026-09-28 10:01:49 -07:00
openclaw-prepack.test.ts test(runtime,ui,tooling): remove low-value tests (batch d013) (#158691) 2026-09-26 08:48:53 +00:00
outbound-sanitize-text-delivery.test.ts test(core, plugins, ui): remove low-value tests (batch d040) (#159093) 2026-09-26 18:32:26 +00:00
package-manager-config.test.ts test(runtime,ui,tooling): remove low-value tests (batch d013) (#158691) 2026-09-26 08:48:53 +00:00
package-scripts.test.ts fix(browser): read Windows browser version via environment data so spaced paths stop breaking the PowerShell probe (#160432) 2026-09-29 02:51:17 +05:30
plugin-clawhub-metadata.test.ts
plugin-clawhub-release.test.ts test(runtime,ui,tooling): remove low-value tests (batch d013) (#158691) 2026-09-26 08:48:53 +00:00
plugin-cron-registry-owner.e2e.test.ts
plugin-extension-import-boundary.test.ts
plugin-npm-package-manifest.test.ts test(runtime,ui,tooling): remove low-value tests (batch d013) (#158691) 2026-09-26 08:48:53 +00:00
plugin-npm-release.test.ts chore(release): retire the internal Tideclaw alpha release track (#160261) 2026-09-28 10:01:49 -07:00
plugin-npm-runtime-build.test.ts test: isolate plugin runtime package build fixtures 2026-09-28 19:10:28 -07:00
pr111899-accepted-run-transport-loss.e2e.test.ts
pr119473-real-runtime-proof.e2e.test.ts
pr126853-heartbeat-visible-lane-proof.e2e.test.ts
pr142176-real-runtime-proof.e2e.test.ts
pr154462-real-runtime-proof.e2e.test.ts fix(agents): keep active turns working through configuration reloads (#154462) 2026-09-27 15:50:52 -07:00
progress-card-channel-literals.integration.test.ts refactor(channels): centralize progress and final delivery (#155639) 2026-09-22 17:39:33 +05:30
provider-auth-method.openai-siwc.integration.test.ts perf(agents): serialize large model requests once (#159574) 2026-09-27 12:22:40 +00:00
provider-auth-method.radius.integration.test.ts
qa-channel-message-tool-delivery.test.ts
qa-convex-credential-payload-validation.test.ts test(core, plugins, ui): remove low-value tests (batch d040) (#159093) 2026-09-26 18:32:26 +00:00
release-check.test.ts test(runtime,ui,tooling): remove low-value tests (batch d013) (#158691) 2026-09-26 08:48:53 +00:00
release-version.test.ts test(core, plugins, ui): remove low-value tests (batch d040) (#159093) 2026-09-26 18:32:26 +00:00
repository-test-api-publications.ts test(state,ui,browser,agents): remove low-value tests (batch d095) (#161041) 2026-09-30 01:46:57 +00:00
runtime-agent.codex-initialization.integration.test.ts fix: keep native sessions responsive during database contention (#158396) 2026-09-26 01:05:45 +00:00
scripts-update-gateway-build.test.ts fix(update): keep native service identities during discovery (#161238) 2026-09-29 16:05:40 -07:00
scripts-update-gateway-legacy.test.ts test(update): align legacy build refusal diagnostic 2026-09-28 12:09:51 -07:00
scripts-update-gateway.test.ts fix(update): prepare source replacements before service stop (#161110) 2026-09-29 03:02:35 -07:00
setup-home-isolation.test.ts
setup-openclaw-runtime.plugin-cache.test.ts test: cover shared runtime plugin retirement 2026-09-24 13:49:45 -07:00
setup-openclaw-runtime.ts fix(test): prevent plugin cache accumulation in shared workers (#157470) 2026-09-24 13:18:36 -07:00
setup.env.ts
setup.extensions.ts refactor(mcp): bind idle cleanup to the lifecycle scheduler (#159481) 2026-09-27 22:54:48 +00:00
setup.shared.ts
setup.signal.ts
setup.ts fix(update): back up every database before migrations and restore them on rollback (#158163) 2026-09-26 02:30:17 +00:00
signal-approval-forwarding.integration.test.ts fix(channels): restore system-agent approval reactions (#159132) 2026-09-26 18:11:51 -07:00
skill-usage.codex.integration.test.ts refactor(skills): move usage and curator status SQL off the caller thread (#152319) 2026-09-20 09:12:28 -07:00
skills-proposal-manual-target.e2e.test.ts
slack-download-read-authority.integration.test.ts refactor: reuse live placement authority for worker checks (#155898) 2026-09-24 00:24:40 -07:00
slack-outbound-permanent-rejection-loopback.test.ts test(core, plugins, ui): remove low-value tests (batch d040) (#159093) 2026-09-26 18:32:26 +00:00
sqlite-test-lifecycle.ts fix(test): prevent SQLite pathname failures in shared Gateway shards (#160838) 2026-09-29 01:53:26 +00:00
stable-release-closeout.test.ts fix(release): record a withdrawn macOS appcast at stable closeout (#157082) 2026-09-23 23:34:27 -07:00
status-shared-state-readonly.e2e.test.ts fix(test): keep absent Gateway status fixtures unreachable (#161032) 2026-09-29 00:58:46 -07:00
subagent-announce-origin.integration.test.ts
subagent-requester-owner.e2e.test.ts refactor: remove Tasks and TaskFlow runtime (#159179) 2026-09-27 10:40:29 -07:00
system-agent-managed-auth.e2e.test.ts
talk-browser-defaults.test.ts fix(voice): share one realtime agent context across Talk, Discord, FaceTime, and voice-call (#159548) 2026-09-27 03:24:12 -07:00
telegram-history-read.integration.test.ts fix(telegram): retain discussion between mentions without flooding context (#151911) 2026-09-19 09:40:19 +05:30
telegram-outbound-permanent-rejection-loopback.test.ts test(core, plugins, ui): remove low-value tests (batch d040) (#159093) 2026-09-26 18:32:26 +00:00
telegram-question-gateway.test.ts refactor(gateway): schedule question deadlines (#160334) 2026-09-28 05:02:09 -07:00
telegram-recovery-notice-send.test.ts test(telegram): remove rate waits from recovery fence (#151424) 2026-09-19 19:49:14 -07:00
telegram-reply-conversation.test.ts refactor(telegram): remove redundant test coverage (#155040) 2026-09-23 00:50:06 -07:00
test-env.state-lifetime.test.ts
test-env.test.ts
test-env.ts
test-helper-extension-import-boundary.test.ts
test-home-context.mts
test-home-policy.mts
transcripts-discord-audio.integration.test.ts fix(voice): keep audio flowing while the Gateway is busy (#154119) 2026-09-20 21:49:35 -07:00
transcripts-tool.discord-lifecycle.integration.test.ts perf(sessions): reduce recovery ownership-check allocations (#160831) 2026-09-29 03:45:31 +00:00
transcripts-tool.discord-provider.integration.test.ts
tsconfig.json
twitch-message-tool-delivery.test.ts test(runtime,ui,tooling): remove low-value tests (batch d013) (#158691) 2026-09-26 08:48:53 +00:00
ui.presenter-next-run.test.ts
vitest-boundary-config.test.ts
vitest-cli-ownership.test.ts perf(sessions): publish transcript projections off thread (#154069) 2026-09-25 10:44:21 -07:00
vitest-credential-redaction.test.ts
vitest-dependency-resolution.test.ts
vitest-light-paths.test.ts test(core, plugins, ui): remove low-value tests (batch d040) (#159093) 2026-09-26 18:32:26 +00:00
vitest-performance-config.test.ts test(runtime,ui,tooling): remove low-value tests (batch d013) (#158691) 2026-09-26 08:48:53 +00:00
vitest-pr-exempt-retention.test.ts refactor: use fs-safe for file watching and preserve Doctor plugin captures (#159226) 2026-09-29 01:05:11 -07:00
vitest-projects-config.test-support.ts feat: select and manage installed agents from Models (#150224) 2026-09-20 18:00:12 +05:30
vitest-projects-config.test.ts fix: preserve owner access after child follow-up results (#160018) 2026-09-28 11:51:36 -04:00
vitest-redacting-reporter.test.ts fix: keep cold child compilation outside CI test deadlines (#156011) 2026-09-22 17:41:19 -07:00
vitest-reporters-config.test.ts fix(ci): emit elapsed tooling file timings (#156013) 2026-09-23 00:29:50 +00:00
vitest-scoped-config.test.ts refactor: remove Tasks and TaskFlow runtime (#159179) 2026-09-27 10:40:29 -07:00
vitest-ui-e2e-config.test.ts refactor: remove Tasks and TaskFlow runtime (#159179) 2026-09-27 10:40:29 -07:00
vitest-ui-e2e-prebuilt.test.ts fix(test): prepare matching Control UI assets before E2E (#159624) 2026-09-27 19:46:53 +07:00
vitest-ui-e2e-preflight.test.ts fix(test): stop preflight mocks leaking into shared workers (#157207) 2026-09-24 23:46:44 +08:00
vitest-ui-package-config.test.ts fix(ci): keep reply-preview retention proof on Node (#159991) 2026-09-27 22:32:12 -03:00
vitest-unit-config.test.ts test(core, plugins, ui): remove low-value tests (batch d040) (#159093) 2026-09-26 18:32:26 +00:00
vitest-unit-fast-config.test.ts test(ci): settle cron wakes and refresh fast-lane fixtures 2026-09-29 19:42:50 -05:00
vitest-unit-paths.test.ts perf(test): speed up literal unit exclusions (#157901) 2026-09-26 11:33:18 -07:00