Feat/add cron execution hook clean#29682
Open
Patrick-Barletta wants to merge 2 commits intoopenclaw:mainfrom
Open
Feat/add cron execution hook clean#29682Patrick-Barletta wants to merge 2 commits intoopenclaw:mainfrom
Patrick-Barletta wants to merge 2 commits intoopenclaw:mainfrom
Conversation
Add `cron_execution` plugin hook that fires when a cron job completes. - Add `cron_execution` to `PluginHookName` type - Add `PluginHookCronExecutionEvent` with job metadata (jobId, cronName, success, duration, error) - Dispatch hook in `server-cron.ts` when `action === "finished"` - Hook fires after cron job execution with success status derived from `status === "completed" && !error` Enables plugins to observe cron job executions for trust tracking, logging, and monitoring.
- Add runCronExecution method to hooks.ts and export it - Import PluginHookCronExecutionEvent type in hooks.ts - Fix cron success check to use 'ok' status instead of 'completed' - Use hookRunner.runCronExecution() instead of runVoidHook() - Add type annotation for error parameter in catch block
Contributor
Greptile SummaryAdded Key changes:
Implementation quality:
Confidence Score: 5/5
Last reviewed commit: 16b3c99 |
thomasxm
pushed a commit
to thomasxm/openclaw
that referenced
this pull request
Feb 28, 2026
…cation, hook bridge Comprehensive cron subsystem reliability overhaul addressing 9 open issues: **Configurable retry policy (openclaw#29527, openclaw#29546)** - Extract backoff logic into `retry-policy.ts` with configurable `cron.retryBackoff` schedule and `cron.stuckRunTimeoutMs` config fields - Classify execution errors as transient (retry with backoff) or terminal (disable job immediately) to prevent futile retry storms - Add Zod validation for new config fields **Fix delivery status reporting (openclaw#29660)** - `resolveDeliveryStatus` now accepts `deliveryAttempted` and returns "not-delivered" when delivery was attempted but not confirmed - Add explicit `delivered: false` to all error paths in delivery-dispatch.ts - Pass `deliveryAttempted` through the full result chain **Configurable response prefix (openclaw#29687)** - Add `responsePrefix` to CronServiceDeps (defaults to "Cron") - Use dep-injected prefix for main session summary messages **Strip directive tags from cron output (openclaw#29646)** - Strip `[[reply_to_current]]`, `[[reply_to:<id>]]`, `[[audio_as_voice]]` from isolated cron run output before delivery **Startup schedule preservation (openclaw#29690)** - Use maintenance-only recompute in `start()` to avoid advancing past-due `nextRunAtMs` values for jobs that `runMissedJobs` intentionally skipped - Clear `nextRunAtMs` for interrupted jobs so they get fresh schedule computation **Internal hook bridge (openclaw#29682)** - Add "cron" to `InternalHookEventType` with `CronExecutionHookEvent` type - Bridge `emitJobFinished` to `triggerInternalHook` so extensions can react to cron job completions (alerting, chaining, etc.) - Add `isCronExecutionEvent` type guard **Per-job skip-if-active flag (openclaw#29659)** - Add `skipIfRunActive?: boolean` to CronJob type for semantic overlap prevention Tests: 290 cron tests + 21 new retry-policy tests pass. Fixes: openclaw#29527, openclaw#29546, openclaw#29601, openclaw#29646, openclaw#29659, openclaw#29660, openclaw#29682, openclaw#29687, openclaw#29690
Closed
5 tasks
Contributor
|
Thanks for the contribution. Closing this PR because it adds a new plugin hook surface ( For this workstream we are avoiding new extension points and prioritizing stability and operator clarity improvements only. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
cron_executionhook that fires after cron jobs complete, providing cronName, success status, and durationChange Type
Scope
Linked Issue/PR
User-visible / Behavior Changes
For plugin developers:
cron_executionhook available in plugin APIcronName: Job identifiersuccess: Boolean (derived from status === "ok" && !error)durationMs: Execution timesessionId,status,error: Additional metadataFor end users:
Security Impact
Repro + Verification
Environment
openclaw.jsonSteps
cron_executionhookExpected
cron_executionevent with cronName, success, durationMsActual
Evidence
Before: Plugins could not observe cron executions - no hook available
After:
Implementation in server-cron.ts:
Human Verification
Verified scenarios:
Edge cases checked:
What I did NOT verify:
Compatibility / Migration
Existing plugins continue working without changes. New plugins can opt-in to
cron_executionhook.Failure Recovery
How to disable/revert quickly:
hookRunner.runCronExecution()call in server-cron.tsFiles to restore:
src/gateway/server-cron.ts(remove lines ~270-290 in onEvent handler)Known bad symptoms:
Risks and Mitigations
Risk: Plugin hook handlers block cron completion handler
Risk: High-frequency cron jobs + heavy plugin hooks cause memory/perf issues
Risk: Event payload includes sensitive cron job data