Repository navigation
Conversation
Greptile SummaryThis PR adds an optional Key issues found:
Confidence Score: 4/5
Prompt To Fix All With AIReviews (1): Last reviewed commit: "fixup: trim command in zod schema; rejec..." | Re-trigger Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4154ef65cb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
4154ef6 to
d3f2624
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d3f2624c8e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8bc78b4c79
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Could someone please look into my proposal? |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 61eced56fd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
c05702c to
79d854b
Compare
There was a problem hiding this comment.
💡 Codex Review
https://github.com/openclaw/openclaw/blob/79d854b0676e012995e86757cc200ebaed716186/src/agents/tools/cron-tool.ts#L561
Recover preHook in flattened cron job params
The flat-params recovery block for cron.add still filters keys through CRON_RECOVERABLE_OBJECT_KEYS, which does not include preHook, so a top-level preHook from flattened tool calls is silently dropped and the created job runs without its intended gate. This directly affects the non-frontier fallback path this code is meant to support (the same pattern is repeated in the cron.update recovery loop), so users can believe they configured preHook when it was actually discarded.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5511622537
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 708f7c6268
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
f03392b to
9e66ca4
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9e66ca4e98
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
6cc8e12 to
7977b73
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7977b73e03
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
CI Status UpdateAll review threads are now resolved. Here is a summary of current CI: ✅ Passing (new in this run)
❌ Still Failing — Pre-existing on
|
| Check | Root cause |
|---|---|
check-additional / lint:plugins:plugin-sdk-subpaths-exported |
openclaw/plugin-sdk/secret-input-runtime not in package exports — pre-existing on main |
extension-fast (synology-chat) / checks-fast-extensions-shard-* |
createSubsystemLogger is not a function in ollama extension — pre-existing on main |
checks-fast-contracts-protocol |
missing bundled channel plugin: slack — pre-existing on main |
checks-node-channels |
Same ollama/slack import chain failures — pre-existing on main |
This PR's own changes are clean: pnpm check passes, cron/pre-hook/normalize/heartbeat tests all pass, and no regressions were introduced.
Add a preHook config to cron jobs and heartbeat that runs a shell script before the agent turn. If the script exits non-zero, the run is skipped. This enables lightweight pre-flight checks (e.g. are there new emails?) without waking an LLM agent. Changes: - Add preHook config to cron job schema and heartbeat config - Wire preHook execution into cron isolated runner and heartbeat scheduler - Wire abort signal into pre-hook subprocess - Handle maxBuffer overrun as error to preserve non-zero exit codes - Support Windows shell (cmd.exe) and Unix shells - Allow null preHook in CronJobPatch type for clearing via cron.update - Add Zod schema validation for preHook fields - Add tests for pre-hook gating behavior
… signal, baseline)
…reHook after preflight - pre-hook.ts: undefined exit status on maxBuffer now resolves as 'error' instead of 'skip' — prevents broken hooks that print >64KB from being silently masked as intentional skips, suppressing error/backoff/failure-alert behavior. - heartbeat-runner.ts: moved preHook execution to after resolveHeartbeatPreflight so the shell command only runs for heartbeats that will actually proceed. Previously the hook ran before preflight, causing side effects for runs that preflight would skip (e.g. empty-heartbeat-file).
Without emitHeartbeatEvent, a heartbeat blocked by preHook never updated system.last-heartbeat or event subscribers. Monitoring surfaces would show stale state when preHook starts failing in production. Now emits a skipped or failed event (with reason and durationMs) before each early return.
- pre-hook.ts: use exitCode: -1 instead of undefined for unknown maxBuffer exit status (PreHookResult type requires exitCode: number) - state.ts: add abortSignal?: AbortSignal to runHeartbeatOnce opts type - heartbeat-runner.ts: fix log.info/warn call signature (message first, meta second — subsystem logger is not pino-style) - schema.base.generated.ts: regenerate stale output (new preHook fields)
…on.ts The runHeartbeatOnce call in the CronServiceDeps adapter was not forwarding opts.abortSignal to runHeartbeatOnce, so in wakeMode=now runs with a heartbeat preHook, a cron job timeout would not cancel the pre-hook shell process — it would continue running until its own timeout even after the cron job was already marked timed out. Fix: pass abortSignal: opts?.abortSignal to the runHeartbeatOnce call.
…beatNow call
requestHeartbeatNow opts type only supports { reason, agentId, sessionKey }.
The heartbeat.target and abortSignal properties were passed here but not
defined in the type. Since requestHeartbeatNow is fire-and-forget (void),
the heartbeat.target override belongs only on the runHeartbeatOnce path
where it already exists correctly (~line 1210).
…-tool.ts These constants were declared but never used — the recovery loop uses CRON_RECOVERABLE_OBJECT_KEYS instead. oxlint 1.58+ correctly flags them as unused variables. Removing the dead declarations.
…erId with positional args
…efore pre-hook launch - Add 'preHook' to CRON_RECOVERABLE_OBJECT_KEYS so flat-param recovery in both cron.add and cron.update correctly forwards preHook when models omit the job/patch wrapper object. Without this, a top-level preHook field was silently dropped, creating an ungated job instead of one with the pre-run check. - Add abortSignal check before the pre-hook gate in executeJobCore so that an already-cancelled job does not launch the pre-hook shell command. Previously, a timed-out run could start the subprocess after cancellation had already fired.
…nnectionDetails mock Parameters<> for a function with a default parameter resolves to [] in newer tsgo, causing 'Expected 0 arguments, but got 1' when spreading. Cast via any[] to preserve the pass-through mock behavior without the false tsgo error.
Both the heartbeat and cron preHook descriptions incorrectly stated that any non-zero exit skips the run. The actual behavior (per PRE_HOOK_SKIP_EXIT_CODE=10 in src/cron/pre-hook.ts) is: - Exit code 10 → skip (heartbeat/cron run is skipped) - Any other non-zero → error (heartbeat still fires; cron job is marked failed) Updated both occurrences in configuration-reference.md to match the implementation.
…preHook docs accuracy
9d3069c to
087249c
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 087249c62c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
preHook was added to CRON_RECOVERABLE_OBJECT_KEYS for flat-argument recovery but was absent from CronJobObjectSchema (add) and CronPatchObjectSchema (update). Tool-calling models had no schema signal to generate the field, making preHook effectively hidden. - CronJobObjectSchema: preHook as optional Type.Object (command, timeoutSeconds) - CronPatchObjectSchema: preHook as Type.Unsafe<...| false> with clear-sentinel description, mirroring the failureAlert pattern - cron-tool.schema.test.ts: updated field snapshots for both job and patch Fixes PRRT_kwDOQb6kR855It1h.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0d5b735208
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } else { | ||
| // Non-object, non-null, non-undefined (e.g. a bare string or number) — drop it. | ||
| delete next.preHook; |
There was a problem hiding this comment.
Preserve preHook clear sentinel during patch normalization
The new cron.update tool schema describes preHook: false as the way to clear an existing hook (src/agents/tools/cron-tool.ts), but this normalization branch drops every non-object/non-null preHook value. When a tool caller follows that contract and sends false, the field is removed from the patch instead of being converted to a clear operation, so the stored preHook remains active and continues blocking runs unexpectedly. Please map this sentinel to null (clear) rather than deleting it.
Useful? React with 👍 / 👎.
|
Closing this as duplicate or superseded after Codex automated review. PR #54239 is an older v2 implementation of cron/heartbeat preHook support and is superseded by the newer open PR #62195, which tracks the same feature and explicitly carries forward review feedback from #54239. Current main does not yet implement preHook, so this should close as superseded rather than implemented. Best possible solution: Close #54239 as superseded and continue review on #62195, the newer open v3 PR for the same cron/heartbeat preHook feature. Do not treat this as implemented until the canonical PR or another implementation lands on main. What I checked:
So I’m closing this here and keeping the remaining discussion on the canonical linked item. Codex Review notes: model gpt-5.5, reasoning high; reviewed against 06d409dc2738. |
Summary
Closes #49370
Operators running OpenClaw on resource-constrained hosts (Raspberry Pi, shared VMs, metered cloud instances) currently have no native way to gate cron or heartbeat agent runs on system preconditions — things like checking disk space, network reachability, API availability, or whether a dependent service is healthy. Everyone ends up rebuilding custom wrapper logic independently outside of OpenClaw, which is fragile and hard to maintain.
This PR adds an optional
preHookfield to cron job and heartbeat configs. When set, OpenClaw runs the specified shell command before launching the agent. If the command exits non-zero, the run is skipped (not failed) and a reason is logged. If it exits 0, the run proceeds normally.What's changed
src/cron/pre-hook.ts— core preHook runner (exec, timeout, skip-on-failure)src/cron/pre-hook.test.ts— unit testssrc/cron/normalize.ts— normalization + validation for preHook input; rejects malformed objects (missing/non-string command)src/cron/normalize.test.ts— normalize testssrc/cron/types.ts/types-shared.ts— type definitionssrc/cron/service/jobs.ts/timer.ts— integrate preHook into job execution pipelinesrc/config/zod-schema.agent-runtime.ts— zod schema with.trim().min(1)on commandsrc/config/types.agent-defaults.ts— TypeScript typessrc/agents/tools/cron-tool.ts— expose preHook in cron tool schemasrc/gateway/protocol/schema/cron.ts— protocol schemasrc/infra/heartbeat-runner.ts— preHook support for heartbeat runsapps/macos//apps/shared/— GatewayModels.swift updateddocs/— config reference, cron-jobs.md, heartbeat.md, config-baseline.json/jsonlExample usage
{ "schedule": "cron 0 8 * * 1-5", "preHook": { "command": "ping -c1 -W2 api.openai.com > /dev/null 2>&1", "timeoutSeconds": 10 } }If the ping fails (e.g. no internet), the cron run is skipped with a log entry. No agent spin-up, no wasted tokens.
Clean branch note
This is a clean rebase of #49415 (which was closed by the bot due to unrelated commits on the branch). All changes here are strictly related to the preHook feature.