openclaw/src/cron
Tyler Yust 07375a65d8
fix(cron): recover flat params when LLM omits job wrapper (#12124)
* fix(cron): recover flat params when LLM omits job wrapper (#11310)

Non-frontier models (e.g. Grok) flatten job properties to the top level
alongside `action` instead of nesting them inside the `job` parameter.
The opaque schema (`Type.Object({}, { additionalProperties: true })`)
gives these models no structural hint, so they put name, schedule,
payload, etc. as siblings of action.

Add a flat-params recovery step in the cron add handler: when
`params.job` is missing or an empty object, scan for recognised job
property names on params and construct a synthetic job object before
passing to `normalizeCronJobCreate`. Recovery requires at least one
meaningful signal field (schedule, payload, message, or text) to avoid
false positives.

Added tests:
- Flat params with no job wrapper → recovered
- Empty job object + flat params → recovered
- Message shorthand at top level → inferred as agentTurn
- No meaningful fields → still throws 'job required'
- Non-empty job takes precedence over flat params

* fix(cron): floor nowMs to second boundary before croner lookback

Cron expressions operate at second granularity. When nowMs falls
mid-second (e.g. 12:00:00.500) and the pattern targets that exact
second (like '0 0 12 * * *'), a 1ms lookback still lands inside the
matching second.  Croner interprets this as 'already past' and skips
to the next occurrence (e.g. the following day).

Fix: floor nowMs to the start of the current second before applying
the 1ms lookback.  This ensures the reference always falls in the
*previous* second, so croner correctly identifies the current match.

Also compare the result against the floored nowSecondMs (not raw nowMs)
so that a match at the start of the current second is not rejected by
the >= guard when nowMs has sub-second offset.

Adds regression tests for 6-field cron patterns with specific seconds.

* fix: add changelog entries for cron fixes (#12124) (thanks @tyler6204)

* test: stabilize warning filter emit assertion (#12124) (thanks @tyler6204)
2026-02-08 23:10:09 -08:00
..
isolated-agent fix: context overflow compaction and subagent announce improvements (#11664) (thanks @tyler6204) 2026-02-07 20:02:32 -08:00
service fix(cron): share isolated announce flow + harden cron scheduling/delivery (#11641) 2026-02-07 19:46:01 -08:00
cron-protocol-conformance.test.ts fix(cron): fix test failures and regenerate protocol files 2026-02-04 01:03:59 -08:00
delivery.test.ts fix: cron scheduler reliability, store hardening, and UX improvements (#10776) 2026-02-06 18:03:03 -08:00
delivery.ts fix: cron scheduler reliability, store hardening, and UX improvements (#10776) 2026-02-06 18:03:03 -08:00
isolated-agent.delivers-response-has-heartbeat-ok-but-includes.test.ts fix(cron): share isolated announce flow + harden cron scheduling/delivery (#11641) 2026-02-07 19:46:01 -08:00
isolated-agent.skips-delivery-without-whatsapp-recipient-besteffortdeliver-true.test.ts fix(cron): share isolated announce flow + harden cron scheduling/delivery (#11641) 2026-02-07 19:46:01 -08:00
isolated-agent.ts chore: migrate to oxlint and oxfmt 2026-01-14 15:02:19 +00:00
isolated-agent.uses-last-non-empty-agent-text-as.test.ts fix: cron scheduler reliability, store hardening, and UX improvements (#10776) 2026-02-06 18:03:03 -08:00
normalize.test.ts fix: cron scheduler reliability, store hardening, and UX improvements (#10776) 2026-02-06 18:03:03 -08:00
normalize.ts fix: cron scheduler reliability, store hardening, and UX improvements (#10776) 2026-02-06 18:03:03 -08:00
parse.ts chore: Enable "curly" rule to avoid single-statement if confusion/errors. 2026-01-31 16:19:20 +09:00
payload-migration.ts chore: Enable "curly" rule to avoid single-statement if confusion/errors. 2026-01-31 16:19:20 +09:00
run-log.test.ts fix: cron scheduler reliability, store hardening, and UX improvements (#10776) 2026-02-06 18:03:03 -08:00
run-log.ts fix: cron scheduler reliability, store hardening, and UX improvements (#10776) 2026-02-06 18:03:03 -08:00
schedule.test.ts fix(cron): recover flat params when LLM omits job wrapper (#12124) 2026-02-08 23:10:09 -08:00
schedule.ts fix(cron): recover flat params when LLM omits job wrapper (#12124) 2026-02-08 23:10:09 -08:00
service.delivery-plan.test.ts fix: cron scheduler reliability, store hardening, and UX improvements (#10776) 2026-02-06 18:03:03 -08:00
service.every-jobs-fire.test.ts fix: cron scheduler reliability, store hardening, and UX improvements (#10776) 2026-02-06 18:03:03 -08:00
service.issue-regressions.test.ts fix: cron scheduler reliability, store hardening, and UX improvements (#10776) 2026-02-06 18:03:03 -08:00
service.jobs.test.ts feat(cron): enhance legacy delivery handling in job patches 2026-02-04 01:03:59 -08:00
service.prevents-duplicate-timers.test.ts feat(cron): enhance delivery modes and job configuration 2026-02-04 01:03:59 -08:00
service.read-ops-nonblocking.test.ts fix: cron scheduler reliability, store hardening, and UX improvements (#10776) 2026-02-06 18:03:03 -08:00
service.restart-catchup.test.ts fix: cron scheduler reliability, store hardening, and UX improvements (#10776) 2026-02-06 18:03:03 -08:00
service.runs-one-shot-main-job-disables-it.test.ts fix: cron scheduler reliability, store hardening, and UX improvements (#10776) 2026-02-06 18:03:03 -08:00
service.skips-main-jobs-empty-systemevent-text.test.ts fix: cron scheduler reliability, store hardening, and UX improvements (#10776) 2026-02-06 18:03:03 -08:00
service.store-migration.test.ts fix: cron scheduler reliability, store hardening, and UX improvements (#10776) 2026-02-06 18:03:03 -08:00
service.store.migration.test.ts fix: cron scheduler reliability, store hardening, and UX improvements (#10776) 2026-02-06 18:03:03 -08:00
service.ts chore: Enable "experimentalSortImports" in Oxfmt and reformat all imorts. 2026-02-01 10:03:47 +09:00
store.test.ts fix(paths): respect OPENCLAW_HOME for all internal path resolution (#12091) 2026-02-08 16:20:13 -05:00
store.ts fix(paths): respect OPENCLAW_HOME for all internal path resolution (#12091) 2026-02-08 16:20:13 -05:00
types.ts fix(cron): share isolated announce flow + harden cron scheduling/delivery (#11641) 2026-02-07 19:46:01 -08:00
validate-timestamp.ts feat(cron): enhance delivery modes and job configuration 2026-02-04 01:03:59 -08:00