Skip to content

fix(cron-tool): add typed properties to job/patch schemas#55043

Merged
altaywtf merged 5 commits into
openclaw:mainfrom
brunolorente:fix/cron-tool-schema-empty-job
Apr 1, 2026
Merged

fix(cron-tool): add typed properties to job/patch schemas#55043
altaywtf merged 5 commits into
openclaw:mainfrom
brunolorente:fix/cron-tool-schema-empty-job

Conversation

@brunolorente

@brunolorente brunolorente commented Mar 26, 2026

Copy link
Copy Markdown
Contributor

Problem

CronToolSchema defines job and patch as Type.Object({}, { additionalProperties: true }), producing "properties": {}. Strict models (GPT-5.4) follow the schema literally and send job: {}, which the gateway rejects.

Closes #55035

Solution

Spell out the sub-properties for job, patch, and their nested objects (schedule, payload, delivery, failureAlert) so that models know which fields to send.

What does NOT change

  • Runtime validation (handled by normalizeCronJob*)
  • additionalProperties: true (preserved everywhere)
  • Flattened schema with per-action parameters

Tests

cron-tool.schema.test.ts: 6 regression tests that assert the exact field list for job, patch, and nested objects. Any accidental field removal breaks the test.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Mar 26, 2026
@greptile-apps

greptile-apps Bot commented Mar 26, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR replaces the opaque Type.Object({}, { additionalProperties: true }) placeholders for job and patch in CronToolSchema with fully-typed sub-schemas, so that strict LLMs like GPT-5.4 know exactly which fields to send. It also extends the flattened-field recovery lists for both add and update actions to include failureAlert, fallbacks, and lightContext, and adds normalisation helpers for schedule field pruning (by kind), payload field pruning (by kind), and fallbacks cleaning.

Key changes:

  • CronScheduleSchema, CronPayloadSchema, CronDeliverySchema, CronFailureAlertSchema, CronJobObjectSchema, CronPatchObjectSchema added to cron-tool.ts; CronToolSchema is now exported for schema regression tests.
  • normalize.ts: new kind-specific pruning in coerceSchedule and coercePayload, fallbacks normalization, inferTopLevelPayload helper, and toolsAllow unconditionally removed from payloads.
  • service/jobs.ts: fallbacks wired into mergeCronPayload and buildPayloadFromPatch.
  • Comprehensive test coverage across cron-tool.schema.test.ts, cron-tool.test.ts, normalize.test.ts, and service.jobs.test.ts.

One P1 bug found: the new schedule-pruning block in coerceSchedule deletes staggerMs inside the kind === "every" branch, yet staggerMs is the random-jitter field that is only valid for kind=every schedules. Any every schedule that includes a stagger value will have it silently dropped after this PR.

Confidence Score: 4/5

  • Safe to merge after fixing the staggerMs deletion bug in the every-schedule pruning block.
  • The overall schema expansion is well-structured and tested. One confirmed P1 bug: delete next.staggerMs appears inside kind === "every" in the new coerceSchedule pruning, silently discarding a field that is explicitly documented as the random-jitter value for that exact schedule kind. All other changes (payload pruning, fallback normalisation, service-layer merge wiring) look correct and are covered by tests.
  • src/cron/normalize.ts — the kind=every branch in coerceSchedule incorrectly deletes staggerMs.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: src/cron/normalize.ts
Line: 92-96

Comment:
**`staggerMs` silently deleted for `kind=every` schedules**

`staggerMs` is the random-jitter field explicitly tied to `kind=every` — the schema description reads `"Random jitter in ms (kind=every)"` and the `CronScheduleSchema` places it alongside `everyMs` and `anchorMs`. The pruning block above (lines 79-84) already normalises `staggerMs` correctly via `normalizeCronStaggerMs`; if it was valid, `next.staggerMs` is set before this block executes. The `delete next.staggerMs` inside the `kind === "every"` branch then silently discards it on every `every` schedule, regardless of whether the value was legitimately set.

`staggerMs` should be removed from the `kind === "every"` branch (it belongs there, not in `kind === "at"` or `kind === "cron"`):

```suggestion
  } else if (next.kind === "every") {
    delete next.at;
    delete next.expr;
    delete next.tz;
  } else if (next.kind === "cron") {
```

How can I resolve this? If you propose a fix, please make it concise.

Reviews (4): Last reviewed commit: "fix: preserve explicit cron delivery int..." | Re-trigger Greptile

Comment thread src/agents/tools/cron-tool.ts
Comment thread src/agents/tools/cron-tool.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 71bd5d9342

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/agents/tools/cron-tool.ts Outdated
Comment thread src/agents/tools/cron-tool.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2096292eb5

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/agents/tools/cron-tool.ts Outdated
@brunolorente

Copy link
Copy Markdown
Contributor Author

@hydro13 @tyler6204 :)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c4411b27b4

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/agents/tools/cron-tool.ts Outdated
Comment thread src/agents/tools/cron-tool.ts Outdated
@altaywtf altaywtf self-assigned this Mar 26, 2026
@altaywtf

Copy link
Copy Markdown
Member

Thanks for tackling the job: {} failure mode, but I don’t think this is ready yet.

  • This changes the provider-facing JSON Schema and adds no schema regression test. That is the main thing this PR is touching, so shipping it without a schema assertion/snapshot is a miss.
  • The new schema is still incomplete versus the runtime contract. patch.agentId, patch.sessionKey, and patch.failureAlert are still supported by runtime code/tests, but the schema no longer advertises them.
  • The nested schema also drops supported fields like schedule.staggerMs, delivery.accountId, and delivery.failureDestination, so strict models will now be guided away from valid cron requests.
  • There is also a lot more comment/schema churn here than this fix should need, which makes the patch harder to review.

I’d expand the schema to match the actual cron contract first, then add a schema-level regression test before landing.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5f277ed22e

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/agents/tools/cron-tool.ts Outdated
Comment thread src/agents/tools/cron-tool.ts Outdated
@brunolorente
brunolorente force-pushed the fix/cron-tool-schema-empty-job branch from 5f277ed to e6dcc36 Compare March 27, 2026 08:39

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e6dcc36479

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/agents/tools/cron-tool.ts Outdated
Comment thread src/agents/tools/cron-tool.ts Outdated
@brunolorente
brunolorente force-pushed the fix/cron-tool-schema-empty-job branch 2 times, most recently from 7e1ac01 to 99b13f5 Compare March 27, 2026 12:27

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 99b13f517b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/agents/tools/cron-tool.ts Outdated
Comment thread src/agents/tools/cron-tool.ts Outdated
@brunolorente

Copy link
Copy Markdown
Contributor Author

Thanks for the review @altaywtf! pushed the fixes:

  • Added cron-tool.schema.test.ts with 6 tests that assert the exact field list for job, patch, and their nested objects. Any field removal will break the test.
  • patch.agentId, patch.sessionKey, patch.failureAlert are all in the schema now.
  • Same for schedule.staggerMs, delivery.accountId, and delivery.failureDestination (modeled as an object to match the gateway schema).
  • failureAlert no longer uses Type.Union (avoids anyOf in the tool schema), and dropped the enabled field since it's not consumed by mergeCronFailureAlert.

CI is failing on format:check but it seems to be a repo-wide thing, is that known?

@brunolorente
brunolorente force-pushed the fix/cron-tool-schema-empty-job branch from 99b13f5 to 28f6484 Compare March 27, 2026 18:41

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f284633627

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/agents/tools/cron-tool.ts
@brunolorente

Copy link
Copy Markdown
Contributor Author

@altaywtf :)

@brunolorente
brunolorente requested a review from altaywtf March 30, 2026 19:49
@altaywtf

Copy link
Copy Markdown
Member

@brunolorente checking, will rebase and take from there thank you!

@altaywtf
altaywtf force-pushed the fix/cron-tool-schema-empty-job branch from f284633 to 71aeafa Compare March 30, 2026 20:39
@altaywtf
altaywtf force-pushed the fix/cron-tool-schema-empty-job branch from 71aeafa to 48fac5d Compare March 30, 2026 20:41

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 09056d5a97

ℹ️ 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".

Comment thread src/agents/tools/cron-tool.ts Outdated
@altaywtf
altaywtf force-pushed the fix/cron-tool-schema-empty-job branch 4 times, most recently from 611e046 to 09bb27b Compare April 1, 2026 20:39
brunolorente and others added 5 commits April 1, 2026 23:39
Spell out sub-properties in CronToolSchema so that strict models
(e.g. GPT-5.4) know which fields to populate instead of sending
job: {}.

Addresses review feedback:
- Add schema regression test (non-empty job/patch properties)
- Add missing patch fields: agentId, sessionKey, failureAlert
- Add missing nested fields: schedule.staggerMs, delivery.accountId,
  delivery.failureDestination (object), payload.allowUnsafeExternalContent,
  payload.fallbacks
- failureAlert accepts false | object to match runtime contract
- failureDestination modelled as object (channel/to/accountId/mode)

Runtime validation in normalizeCronJobCreate/Patch is unchanged.
additionalProperties: true preserved everywhere.

Fixes openclaw#55035
- Remove Type.Union from failureAlert (avoid anyOf in tool schemas)
- Remove unused failureAlert.enabled field
- Add failureAlert.channel and failureAlert.to (consumed by mergeCronFailureAlert)
- Improve schema regression test with exact field-list assertions
@altaywtf
altaywtf force-pushed the fix/cron-tool-schema-empty-job branch from 09bb27b to 979bb0e Compare April 1, 2026 20:40
@altaywtf
altaywtf merged commit ca76e2f into openclaw:main Apr 1, 2026
10 checks passed
@altaywtf

altaywtf commented Apr 1, 2026

Copy link
Copy Markdown
Member

Merged via squash.

Thanks @brunolorente!

steipete pushed a commit to duncanita/openclaw that referenced this pull request Apr 4, 2026
…5043)

Merged via squash.

Prepared head SHA: 979bb0e
Co-authored-by: brunolorente <[email protected]>
Co-authored-by: altaywtf <[email protected]>
Reviewed-by: @altaywtf
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
…5043)

Merged via squash.

Prepared head SHA: 979bb0e
Co-authored-by: brunolorente <[email protected]>
Co-authored-by: altaywtf <[email protected]>
Reviewed-by: @altaywtf
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
…5043)

Merged via squash.

Prepared head SHA: 979bb0e
Co-authored-by: brunolorente <[email protected]>
Co-authored-by: altaywtf <[email protected]>
Reviewed-by: @altaywtf
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
…5043)

Merged via squash.

Prepared head SHA: 979bb0e
Co-authored-by: brunolorente <[email protected]>
Co-authored-by: altaywtf <[email protected]>
Reviewed-by: @altaywtf
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
…5043)

Merged via squash.

Prepared head SHA: 979bb0e
Co-authored-by: brunolorente <[email protected]>
Co-authored-by: altaywtf <[email protected]>
Reviewed-by: @altaywtf
Nachx639 pushed a commit to Nachx639/clawdbot that referenced this pull request Jun 17, 2026
…5043)

Merged via squash.

Prepared head SHA: 979bb0e
Co-authored-by: brunolorente <[email protected]>
Co-authored-by: altaywtf <[email protected]>
Reviewed-by: @altaywtf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui gateway Gateway runtime size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] CronToolSchema: job property has empty properties — causes GPT-5.4 to send job: {}

2 participants