Skip to content

fix(cron): expose flat cron job fields and normalize malformed tool args - #97339

Closed
LinuxMum wants to merge 46 commits into
openclaw:mainfrom
LinuxMum:fix/cron-tool-schema-fix
Closed

LinuxMum wants to merge 46 commits into
openclaw:mainfrom
LinuxMum:fix/cron-tool-schema-fix

Conversation

@LinuxMum

@LinuxMum LinuxMum commented Jun 28, 2026 •

Copy link
Copy Markdown

What Problem This Solves

Less-capable models (tested locally with Gemma 4 26B and Qwen3.8 27B) often flatten cron add/update arguments beside action, or send a malformed job string. Validation then fails and the automation is never created or changed.

Why This Change Was Made

  • Advertises ten flat fields for ordinary add/update: name, enabled, sessionTarget, at, everyMs, expr, tz, message, toolsAllow, text. The prompt says to prefer them only when nested objects are unreliable.
  • prepareCronToolArguments turns flat input into the existing nested job before schema validation. The Gateway still receives one canonical job format.
  • Nested jobs keep main's boundary (fix(cron): recover flat params when LLM omits job wrapper #12124). A nonempty job takes main's route unchanged, including normalization of stale schedule/payload fields. Flat recovery runs only when job is missing, malformed, or {}. Nested and flat fields are never merged.

Deliberate differences from main:

  • Mixed input is rejected. A nonempty job plus any advertised flat field except name fails before the Gateway call. Main silently ignored these, which would drop a tz, toolsAllow, enabled or sessionTarget and change timing or tool access without telling the user. Blank filler strings are ignored, and name beside job is still ignored as on main.
  • Text-only updates keep the stored type. Flat or nested, a text-only update keeps the stored reminder/task kind. On main, a nested {payload:{text}} update turns a task into a reminder. If the stored kind is unreadable or incompatible, the update errors without writing.
  • Flat guards. Only one of at/everyMs/expr; tz only with expr; text or message, not both (unless identical).
  • Empty wrapper. job: {} with no flat content fails with job required before the Gateway call.

User Impact

Weaker models can create and edit automations with flat fields. Existing nested callers are unaffected apart from the two deliberate differences above.

Maintainer decision still open: whether to adopt the flat form as a supported model-facing contract. ClawSweeper recommends adopting the narrow flat form.

Evidence

  • Real scheduled run (attached): a flat-created job with payload.toolsAllow:["read"]. tools/list showed only read, the allowed read succeeded, and a raw write call was denied (Tool not available: write) with the sentinel file still absent.
  • Regression tests (cron-tool.flat-params.test.ts), through prepare → validate → execute:
    • ClawSweeper's nested reminder with tz:"" inside the at schedule
    • main's STALE_AT_SCHEDULE fixture
    • nested leftover text/message
    • blank filler fields beside job
    • mixed-input rejection
    • end-to-end text-only updates for stored task and reminder jobs, flat and nested
    • every prompt example run verbatim (the test also checks each example appears in the tool description)
  • Test results: on this head (merged with main fa86f99a19), cron-tool.flat-params, cron-tool.schema, cron-tool and src/cron/normalize pass, 218/218. On the previous head 56e8b31ce653, ClawSweeper's nested reminder fails with tz needs expr; the new test reproduces that input.
  • Prompt snapshots: regenerated on Linux for the updated cron tool description.

Related: #3569, #64721, #12124, #121645

create.json
run.json
scheduled-run-toolsallow-read-proof.json

Everything below is a chronological log of earlier review cycles, kept for history purposes.
Where it conflicts with this summary (e.g. field counts, head SHAs, test totals) this summary
is current as at the time of writing

PR #97339 ClawSweeper proof

Identity

  • Main: 7ff455860b90a1c63070952cf1cbd190b6a8e22b
  • PR source: LinuxMum/openclaw fix/cron-tool-schema-fix at 6c5069e1cdc573df86d5099455482594663d7d04
  • PR delta base: 74db4da9de9f042215ac5bdf1966987daacc020f
  • Built staged tree: 78baf2562a7f6f2d09a0f51ae68f1d6202aac65c
  • Build: qaRuntime passed

Main changes affecting PR files

  • src/agents/tools/cron-tool.ts: kept main CronToolOutputSchema import plus PR prepareCronToolArguments import.
  • config/assertion-safety-baseline.txt: updated to current counts: cron-tool.ts 9, dashboard-tool.ts 2.
  • Prompt snapshots conflicted; not regenerated. Main snapshots were kept only for this rehearsal build.

Proof achieved

  • raw MCP tools/call to cron using flat fields created job 2bf5e1a0-1ab6-4651-9288-6fcfd8ddad4d with initial payload.toolsAllow:["automations"], sessionTarget:"isolated", and account scheduled-tool policy.

  • real scheduled restricted run through the genuine Gemini CLI package tree:

  • allowlist: payload.toolsAllow:["read"]

  • tools/list: only read

  • allowed read: succeeded

  • raw omitted write call: denied with isError:true, Tool not available: write

  • sentinel: proof/DENIED-WRITE-SENTINEL.txt remained absent

This proves final-boundary denial for a scheduled restricted run: an omitted raw MCP tool call was denied and had no side effect.

Remaining gap

Exact scheduled proof with payload.toolsAllow:["automations"] did not complete.

Finding: the genuine Gemini package passes durable executable binding, but toolsAllow:["automations"]/["cron"] materializes a non-usable OpenClaw MCP settings entry, however toolsAllow:["read"] materializes and proves the denial boundary.

Related: #3569
Related: #64721

Current status as at 2026-09-04

Summarised from the below PR body to save reading time:

What this adds: ten flat top-level fields to assist lower capability models usable for
add/update - name, enabled, sessionTarget, at, everyMs, expr, tz, message, toolsAllow, and
text (previously documented for wake only). Nine are new properties: text is existing, newly
documented for add/update. This set has narrowed since the PR opened as earlier revisions
advertised fourteen fields, several of which became unnecessary as cron changed in main.
The nested job form is unchanged and still works

Scope: ten files, all under src/agents/tools/ plus regenerated prompt snapshots.
Flat input is canonicalised into the existing nested job before dispatch

Head 6c5069e1cd: cron-tool.flat-params.test.ts 41/41 green in CI, including creator
capability capping for both an allowed and an unavailable tool. The only red lane is
control-ui-performance, a repo-wide Control UI (this PR changes no UI code)

Local models used for testing. Local models Gemma 4 26B Q5 K_S and more recently Qwen3.8
27B Q5 K_S (Llama.cpp) were used as test subjects for the model-facing schema in my
live Openclaw

Open items: maintainer review - whether to adopt the flat contract as a supported
model-facing form


What Problem This Solves

src/agents/tools/cron-tool.ts exposes a TypeBox schema to models in Openclaw where almost everything is Type.Optional. However the contract is enforced downstream in normalize.ts and persisted-shape.ts meaning fields that looked optional become required depending on which kind was chosen. The code says at ln 54–55:

"Spell out job/patch properties for model-facing schema; runtime validation still happens in
normalizeCronJob* to avoid nested union schemas."

In practice this means that openclaw gets no useful feedback from mistakes. Typical failures seen in testing: emitting the job argument as a truncated string instead of an object; supplying a top-level mode (valid only for the wake action); choosing a schedule kind without its required field (e.g. kind: "cron" with no expr, or omitting payload.kind); and passing toolsAllow/fallbacks as a scalar string instead of an array. Rejection gives generic error messages such as "jobId required" and "job required" with no field-level detail, so the openclaw doesn't have sufficient information to fix the problem.

Why This Change Was Made

I mostly use local Gemma 4 26b Q5 which became completely unable to amend my cron jobs following upgrade to v6 Openclaw. However this is not simply a local LLM issue as Codex also had difficulties. Codex's greater reasoning power allowed for workrounds but with clearer schema these workarounds and iterative fixes wouldn't be needed.

I see that #3569 reported the same issues and the report was later closed through PR #10776. But #10776 did not address the TypeBox schema. @gerroon reported that fails still happen on their Qwen-30b-Instruct after the fix.

Also #64721 reports the same kind of problem: payload.model, payload.timeoutSeconds,
payload.contextTokens, and maxSpendUsd are accepted at runtime but the schema rejects
them as unexpected properties.

Fix could be with a discriminated union, making the model reason about nested conditional types. However my concern is that lower-reasoning local LLMs will not manage this reasoning adequately.

Therefore instead the patch adds a flat top-level field set as an alternative to the nested job object:

Field Type Notes
name string job name
enabled boolean
sessionTarget string main | isolated | current | session:<id>
at string ISO-8601, one-shot
everyMs integer recurring interval in ms
expr string cron expression
tz string IANA timezone for expr
message string agentTurn prompt — implies agentTurn payload
anchorMs integer start anchor for everyMs schedules
model string agentTurn model override
fallbacks string[] agentTurn fallback models
toolsAllow string[] agentTurn allowed tool ids
thinking string agentTurn thinking override
timeoutSeconds number agentTurn timeout override

The canonicalizer (cron-tool-canonicalize.ts) infers schedule.kind and payload.kind from whichever fields are present, so the model never has to deal with the nested union. Also
descriptions for text (implies systemEvent) and mode (wake only, not delivery mode)
have been tightened up.

The implementation now also normalises scalar toolsAllow / fallbacks into arrays and reconstructs job / patch from recoverable flat fields when the request is clearly a cron add/update call. This deals with an issue found in testing where openclaw incorrectly tries toolsAllow as a scalar string, or emits a malformed non-object job / patch alongside flat fields.

User Impact

Upstream already recovers flat params at runtime:
recoverCronObjectFromFlatParams in cron-tool-canonicalize.ts (with
CRON_FLAT_PAYLOAD_KEYS / CRON_FLAT_SCHEDULE_KEYS)

The patch simply exposes in the model-facing schema what the runtime already accepts but doesn't show. Note the nested job form still works also. There is no negative user impact to the fix.

Evidence

Tested on OpenClaw gateway version 2026.6.10
OS: Linux Mint 22.3 (Zena)
Kernel: Linux 6.17.0-23-generic (x86_64)
LLMs used for testing: Local Gemma 4 26b Q5 (llama.cpp); openai/gpt-5.4
Tests designed and run by: Claude (Anthropic Claude Opus 4.8); OpenAI Codex (gpt-5.4)

Focused validation on fix/cron-tool-schema-fix (~/code/openclaw-main) currently passes for the actual patch surface:

  • corepack pnpm test src/agents/tools/cron-tool.schema.test.ts src/agents/tools/cron-tool.test.ts
    • schema shard: 20 passed
    • agents shard: 135 passed

These tests cover:

  • flat-field exposure in the model-facing cron schema
  • canonicalization of malformed flat toolsAllow / fallbacks
  • synthesis of job / patch from recoverable flat arguments
  • the drift guard that ensures any advertised flat field is still recoverable by the canonicalizer

Earlier branch testing also included:

  • node scripts/run-vitest.mjs src/agents/tools/cron-tool.schema.test.ts
  • node scripts/run-vitest.mjs src/agents/tools/cron-tool.test.ts
  • pnpm tsgo:core:test

Live installed testing on patched OpenClaw 2026.6.10 also succeeded in creating disposable cron jobs through the flat-field interface, confirming the path works in a real installed gateway and not only in unit tests.

This four-file branch is green on the patch-local validation that actually exercises the cron-tool
change. The remaining PR-guide blockers are upstream baseline failures outside this patch scope.

Current upstream-baseline validation also shows:

  • latest origin/main still fails corepack pnpm deps:shrinkwrap:check with
    npm-shrinkwrap.json is stale. Run pnpm deps:shrinkwrap:generate.
  • clean origin/main is also currently red in unrelated test areas, including
    src/gateway/server-methods/agent.test.ts and src/media-understanding/image.test.ts
    (reported for completeness only)

So the branch is green for the cron-tool patch itself, while the remaining check / full-suite
test reds are upstream, pre-existing, and unrelated to this four-file change. codex review --base origin/main stated the patch appears to correctly expose the flat cron fields and normalize them before validation without introducing a concrete regression in the touched surfaces.

Update 2026-08-18

The sections above are kept for history. Current state and evidence requested by ClawSweeper below.

Current flat contract (10 fields)

As per my #97339 (comment) below, the advertised flat top-level contract is now deliberately limited to ten fields:

Field Type Meaning
name string Job name
enabled boolean Enabled state for add/update
sessionTarget string main, isolated, current, or session:<id>
at string One-shot ISO-8601 schedule
everyMs integer Recurring interval in milliseconds
expr string Cron expression
tz string IANA timezone used with expr
message string agentTurn prompt; implies an agentTurn payload
text string systemEvent text; implies a systemEvent payload
toolsAllow string[] agentTurn tool allowlist, e.g. ["read"]
  • An add requires exactly one of at, everyMs, or expr. Updates remain partial jobs under main's unified API.
  • The nested job form remains supported and takes precedence if both nested and flat forms are supplied.
  • Earlier flat aliases for pacing, triggers, streams, model routing, fallbacks, thinking, timeout, and anchoring were removed; those advanced settings remain available through the nested job contract.

Codex harness

This PR changes no openai/codex source or Codex harness/runtime code. The change runs end-to-end on an installed build using the OpenClaw Codex harness (noted in my #97339 (comment) below)

Mode invariant (addressed ClawSweeper P2)

Top-level mode is wake-only. prepareCronToolArguments now rejects a top-level mode on action="add" and action="update" (including when a nested job is present) before any Gateway write, and returns guidance to remove the field. This replaces the earlier guard that only rejected mode when no nested job was supplied, that dropped mode silently on the nested path.

Evidence (final head 18cdfb2)

node --import tsx - <<'EOF'
import { createCronTool } from "./src/agents/tools/cron-tool.ts";
const prep = createCronTool().prepareArguments;
console.log("[1] flat:", JSON.stringify(prep({ action:"add", name:"REPORT", everyMs:3_600_000, message:"status summary" }).job));
for (const c of [
  { action:"add", mode:"now", job:{ schedule:{ kind:"every", everyMs:300_000 }, payload:{ message:"x" } } },
  { action:"update", id:"job-1", mode:"now", job:{ enabled:false } },
]) { try { prep(c); console.log("NO THROW"); } catch (e) { console.log("reject:", e.message); } }
EOF

Output:

[1] FLAT add {name,everyMs,message} -> prepared.job =
    {"name":"REPORT","schedule":{"everyMs":3600000,"kind":"every"},"payload":{"message":"status summary","kind":"agentTurn"}}
[2] NESTED add + top-level mode -> REJECTED: Remove the top-level "mode" field and retry. "mode" is only valid for action="wake".
[3] UPDATE + top-level mode -> REJECTED: Remove the top-level "mode" field and retry. "mode" is only valid for action="wake".
  • [1] confirms flat-field recovery: a low-capability-model shorthand call (name/everyMs/message, no nested structure) is prepared into the canonical nested job (schedule.kind="every", payload.kind="agentTurn").
  • [2]/[3] confirm the wake-only mode guard rejects a top-level mode on both add and update, including with a nested job present.

A live gateway session where the model (local Gemma as before) emitted a top-level mode on an add; the Gateway returned the rejection end-to-end with head 18cdfb2's exact message, and no job was created:

MODEL   -> automations { action:"add", mode:"now", name:"MODETEST-1", … }
GATEWAY -> isError=true : Remove the top-level "mode" field and retry. "mode" is only valid for action="wake".

Update — 2026-08-19

Resynced onto current main and closed the last flat-schedule invariant. prepareCronToolArguments now rejects, before canonicalization, an add that supplies more than one schedule field (at / atMs / everyMs / every / expr / cron), or a bare tz without expr. Schedule ambiguity is rejected because a wrong schedule fails invisibly and time-shifted; payload conflicts (message/text, toolsAllow) stay recoverable by documented precedence. Rejecting these would negatively impact the low-capability-model tolerance this contract exists for.

Verified live on my installed openclaw (v2026.8.1-beta.2 carrying the PR97339 fixes, local Gemma model as before):

add (flat)        -> FLATLIFE-1 created
get               -> persisted: schedule {everyMs:3600000, kind:"every"}, payload {kind:"agentTurn", …}
update (flat)     -> everyMs -> 7200000; get confirms persisted
add everyMs+expr  -> error: "A cron add takes exactly one schedule field; received everyMs, expr…"; list -> no job created
add expr+tz       -> created (a single schedule + tz is valid; only orphan tz rejects)
cleanup           -> FLATLIFE-1 removed

cron-tool.flat-params.test.ts adds regression tests for schedule-conflict rejection, tz-without-expr, and the deliberate payload-conflict tolerance; all cron suites pass.

Update — 2026-09-03: mode-guard proof

The earlier evidence is retained above for history. This update addresses the
current ClawSweeper proof request after the final resync at head
92d5db6f333bad2a02cd6a1df1bdaea458adf9b8.

Live testing

The live run used my installed build based on upstream tag v2026.9.1-beta.1 at
1d96e5aee2d49cde999ed055eda113e2523a7b5c and has the updated PR #97339
mode/recovery implementation folded into it. The local model was
Qwen 3.8 27B Q5_K_S. I supplied each case separately through the installed
OpenClaw desktop UI and let the model call the real automations tool; these
were not direct calls to a mocked tool.

The tested prepareCronToolArguments mode/recovery block is the same block now
present at the current PR head.

At the exact PR head, the focused cron-tool.flat-params.test.ts and
cron-tool.schema.test.ts suites pass. The flat-stream regression test covers
both mode:"line" and mode:"match"; for each mode it asserts that:

  • recovery produces job.schedule.kind="stream" with the mode preserved;
  • the wake-only top-level mode is removed before validation; and
  • execution reaches cron.add with the recovered stream schedule.

The rejection cases also assert that nested or non-stream top-level modes throw
the actionable wake-only error and that the Gateway mock is not called.

Telegram

This PR changes the transport-independent automations tool schema and cron
argument-preparation path. It changes no Telegram source, Telegram parsing,
channel routing, or delivery code.

After any chat transport has delivered a prompt to the agent, the relevant
path is the same:

agent/model -> automations tool schema and argument preparation -> Gateway cron.add

The installed Control UI run crosses that complete affected path: a real model
emitted the tool arguments, OpenClaw prepared and validated them, and the real
Gateway either persisted the canonical job or returned the visible error.
Starting the same prompt in Telegram would add Telegram ingress before this
path, but would not exercise a different cron schema, canonicalizer, mode
guard, or Gateway write. A Telegram-specific E2E run therefore would not add
extra evidence about this PR.

Mode invariant and silent-failure protection

Top-level mode remains wake-only. For add/update:

  • a nested job plus a top-level mode is rejected before any Gateway write;
  • a non-stream flat schedule plus any top-level mode is rejected before any
    Gateway write; and
  • the legacy unadvertised flat-stream shape is accepted only when recovery
    yields schedule.kind="stream". Its stream mode is preserved inside the
    schedule and the copied top-level field is removed before schema validation.

This prevents the two silent-drop cases: normalize.ts cannot silently erase a
mode from a non-stream job, and a top-level mode alongside a nested job cannot
be orphaned. Invalid input fails visibly with:

Remove the top-level "mode" field and retry. "mode" is only valid for action="wake".

Live installed-build results — 2026-09-02

Case Result Observed behavior
T1: nested stream + mode:"match" PASS Job was created; readback contained schedule.kind="stream" and schedule.mode="match".
T2: nested stream + mode:"line" INCONCLUSIVE Qwen entered a visible validation/correction loop. It did not report success, and this was not counted as a pass. The exact-head regression test covers this mode.
T3: flat everyMs + top-level mode:"now" PASS The actionable wake-only error was returned; list showed no job.
T4: flat everyMs + top-level mode:"line" PASS The actionable wake-only error was returned; list showed no job. This is the former silent-drop case.
T5: nested non-stream job + top-level mode:"match" PASS The actionable wake-only error was returned; list showed no job. This is the former orphaned-mode case.
T6: action:"wake", mode:"now" PASS Wake succeeded and created no cron job.
T7: ordinary natural-language flat add PASS MODETEST-7 persisted as schedule.kind="every", everyMs=300000, with an agent-turn message payload.

The retained Gateway log independently records the T7 write:

cron: job added  jobName=MODETEST-7
res ✓ cron.add 52ms

Only T1 and T7 created jobs. The Gateway log records two successful
cron.remove calls immediately after the run (55ms and 65ms), completing
the cleanup.

This evidence covers both sides of the change: valid flat and stream inputs
survive canonicalization and persist, while invalid mode placements return a
visible error before any write rather than being silently ignored.

Update 2026-09-03

Live validation tests were run on an installed bespoke OpenClaw build combining PR head
92d5db6f333bad2a02cd6a1df1bdaea458adf9b8 with then-current upstream main
740b2447b4d762bfb7a5ca53fc6794cff778f526. The model was local Qwen 3.8 27B
Q5_K_S.

  • Flat add recovered everyMs and message into canonical schedule.kind="every"
    and payload.kind="agentTurn".
  • A self-contained flat add/update changed the returned job from
    everyMs=3600000 to everyMs=7200000; the returned persisted job confirmed
    the update.
  • A non-stream top-level mode="line" was rejected before any write with the
    wake-only guidance. It was not silently dropped.
  • An exact installed-build probe recovered the legacy flat stream input into
    schedule.kind="stream", preserving mode="match" and match="ERROR",
    removing top-level mode, and then stopping at the explicit trusted-run gate.cd

During testing, main advanced to
3e8bda1d0aaae7cbcee19924370e5d743371584d. There was no upstream overlap in
the cron implementation or tests; the only non-snapshot overlap was the
generated assertion baseline. The branch was resynced and prompt snapshots
were regenerated. The Telegram files in the diff are generated prompt
snapshots reflecting the automations schema; this PR does not change Telegram
runtime code.

Update - 2026-09-04

Automated proof: cron-tool.flat-params.test.ts passes 39/39 at 3a34311e37, including
rejects incomplete flat schedule updates before Gateway dispatch and
accepts a complete flat cron schedule update with a timezone.

The guard requires a flat update to recover exactly one complete, kind-consistent
schedule; ambiguous or incomplete schedules fail visibly before dispatch.

Live corroboration: I fetched upstream immediately before building
(origin/main = 0c2da1da0315, the latest main available when the build began),
applied pushed PR head 3a34311e37, built it, and ran the compiled output through
the live Gateway. Local Qwen3.8 27B Q5_K_S (as before) created a flat expr + tz job;
a timezone-only update was rejected, no cron.update was logged, and readback
retained {kind:"cron",expr:"17 4 * * *",tz:"Europe/London"}.

The tested checkout was not byte-identical to 3a34311e37, so to be exact:
cron-tool-prepare.ts differs only in that the pushed head passes action
as a parameter where the tested tree read next.action

The guard path exercised live is the guard path in the pushed head.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: M labels Jun 28, 2026
@clawsweeper

clawsweeper Bot commented Jun 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR advertises flat automation fields, repairs malformed arguments before validation, and preserves stored job types during text-only updates.

Example: A model sends action="add", job="truncated", everyMs=300000, and message="Check for urgent mail".

  • Before: The malformed job fails validation before existing flat recovery can run.
  • After: Preparation constructs a canonical five-minute agentTurn job before validation.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The supplied runtime evidence is strong and no discrete bug was found; product acceptance of the expanded contract remains unresolved.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Installed Gateway and local-model traces exercise flat creation, persisted updates, mixed-input rejection, and stored payload-type preservation; attached MCP output also demonstrates allowed read and denied write without a sentinel effect, and the relevant preparation logic remains unchanged.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Needs a maintainer decision · Fix scope: Complete
User problem: Some local models cannot create or edit automations because malformed job wrappers fail before otherwise usable flat arguments can be recovered.
Reason: The recovery addresses a concrete failure, but the patch also establishes a supported model-facing alternative and changes existing input precedence without recorded owner approval.

Merge readiness

⛔ Blocked before merge - 2 items remain

This PR retains useful recovery work absent from current main, with credible live proof and no actionable correctness findings; adopting the advertised flat contract still needs an owner decision.

Priority: P2
Reviewed head: ab29d42991058514151118333b4c52d0083092a8
Owner decision: Required. See Decision needed.

Decision needed

  • Question: Should automations advertise the ten-field flat form and reject meaningful mixed nested/flat input?
  • Recommendation: Adopt the narrow flat contract: Accept the measured prompt overhead and visible mixed-input rejection while retaining the canonical Gateway job format.
  • Why: The live evidence establishes usefulness, but existing owner work favors one compact schema and nested-job precedence; no maintainer approval of this changed contract appears in the discussion.

Before merge

  • Complete next step - Resolve the GitHub-reported merge conflicts while preserving current main's cron behavior.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.

Findings

None.

Agent review details

How this fits together

The automations agent tool converts model arguments into canonical jobs and patches, then sends them through existing creator-authority planning and Gateway cron APIs.

flowchart LR
  A[Model tool call] --> B[Argument preparation]
  B --> C[Schema validation]
  C --> D[Cron canonicalization]
  D --> E[Creator authority planner]
  E --> F[Gateway cron API]
  F --> G[Stored job and scheduler]
Loading

Technical review

Best possible solution:

Keep one pre-validation adapter feeding existing canonicalization and authority owners, with explicit owner acceptance of the advertised flat contract.

Do we have a high-confidence way to reproduce the issue?

Current source shows malformed non-JSON job strings fail object validation before execution-time recovery; supplied live traces demonstrate the repaired boundary, but no target code was run during this review.

Is this the best way to solve the issue?

Preparation before validation fixes the boundary using existing owners; advertising additional fields and changing mixed-input precedence require an explicit product choice.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 50ff12b5a680.

Provenance checked

  • Flat recovery and nested-job precedence changes intended behavior with a stated reason (fix(cron): recover flat params when LLM omits job wrapper #12124: Recover fields emitted beside action when the job wrapper is missing or empty, while preserving nonempty nested-job precedence.)
  • Unified model-facing job schema changes intended behavior with a stated reason (perf(agents): ship one automations job schema for add and update #121645: Ship one canonical job schema for add and update to reduce duplicated prompt content and maintenance.)
  • Text-only payload inference changes intended behavior with a stated reason (96c9cc1: The reviewed change preserved script precedence while inferring agent turns from task hints and reminders from text; this PR explains why updates instead inherit the stored type.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 96c9cc1 adds src/agents/tools/cron-tool-canonicalize.ts:253 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 96c9cc112cca; files: src/agents/tools/cron-tool-canonicalize.ts)
  • Ayaan Zaidi: Raw commit 08498ec adds src/agents/tools/cron-tool-creator-cap.ts:35 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 08498ec40de5; files: src/agents/tools/cron-tool-creator-cap.ts)

PR surface

Source +297, Tests +1204, Other 0. Total +1501 across 13 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 5 335 38 +297
Tests 7 1227 23 +1204
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 13 1563 62 +1501

Review metrics

Metric Value Why it matters
Model-facing surface 9 new top-level properties; existing text reused The ten-field flat contract expands the model-facing surface without adding configuration options.
Prompt overhead +2,857 serialized characters; +714 rough tokens The regenerated Telegram dynamic-tool snapshot quantifies the recurring cost relevant to the owner's schema-size decision.

Labels

Label changes:

  • add merge-risk: 🚨 compatibility: Meaningful mixed nested/flat calls that main accepts will now fail visibly, and text-only updates intentionally preserve the stored payload type.
  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: The repair improves automation creation and editing for models emitting malformed arguments, with a limited tool-boundary scope.
  • merge-risk: 🚨 compatibility: Meaningful mixed nested/flat calls that main accepts will now fail visibly, and text-only updates intentionally preserve the stored payload type.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (47 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-04T20:04:14.763Z sha 6c5069e :: needs real behavior proof before merge. :: [P2] Reject mixed flat message and text inputs
  • reviewed 2026-09-21T10:04:36.111Z sha aba035a :: blocked before merge. :: [P2] Check the recovered schedule before rejecting a timezone
  • reviewed 2026-09-23T08:17:51.664Z sha 446b26d :: blocked before merge. :: [P2] Preserve JSON-array coercion before wrapping scalar hints
  • reviewed 2026-09-23T22:12:12.862Z sha d296d3e :: blocked before merge. :: none
  • reviewed 2026-10-08T11:17:30.730Z sha 56e8b31 :: blocked before merge. :: none
  • reviewed 2026-10-16T06:01:04.658Z sha 56e8b31 :: blocked before merge. :: [P2] [P2] Preserve normalization for fully nested schedules
  • reviewed 2026-10-17T09:07:11.547Z sha aaf41bb :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-17T14:19:51.450Z sha aaf41bb :: blocked before merge. :: none

Reviewed October 19, 2026, 2:42 AM ET / 06:42 UTC (Revision 48).

@harjothkhara

Copy link
Copy Markdown
Contributor

Source audit note on the linked issue scope: this looks like a useful repair for #3569-style flat cron tool calls, but I would keep #64721 open after this PR.

At this head, createCronFlatJobSchemaProperties() advertises flat model, fallbacks, toolsAllow, thinking, and timeoutSeconds, but not contextTokens or maxSpendUsd (cron-tool.ts#L365-L434). On current main, those two names also are not part of the cron gateway protocol payload schema (cron.ts#L13-L35) or the cron runtime payload type (types.ts#L236-L265), so a schema-only flat-field patch cannot settle the remaining context/spend contract from #64721.

One related polish point: the PR head canonicalizer already recovers flat lightContext and allowUnsafeExternalContent (cron-tool-canonicalize.ts#L14-L24), and those are real current cron agentTurn fields, but the new flat schema does not advertise them. That is fine if the intent is a deliberately narrow “common fields” slice; I’d just make the PR body explicit that it covers the model/timeout/flat-add-update part and leaves #64721’s contextTokens / maxSpendUsd work to the maintainer/product-design follow-up.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels Jun 28, 2026
@LinuxMum

Copy link
Copy Markdown
Author

Thanks. I've done a follow-up fix for the review point on flat nullable clears, so this PR now also allows flat top-level update calls to pass model: null, fallbacks: null, and toolsAllow: null. Those fields can be explicitly cleared instead of being rejected at schema validation.

I have re-tested the installed build. Test was run end to end with vllm/local_llama.gguf (Gemma 4 26b Q5), rather than relying on a stronger model.

TEST - text pasted from TEST-flatfields-extended.md

Goal: prove the cron tool accepts the flat top-level fields added by the PR, and that flat update
can clear model, fallbacks, and toolsAllow with null.

Step 1

Run one agent turn and tell it to use the cron tool exactly once to create a disabled test job with
these flat top-level arguments:

{
  "action": "add",
  "name": "flat-nullclear-test-DELETEME",
  "enabled": false,
  "expr": "0 */6 * * *",
  "message": "Disposable flat-field proof job.",
  "model": "openai/gpt-5.4",
  "fallbacks": ["openai/gpt-5-mini"],
  "toolsAllow": ["exec"],
  "timeoutSeconds": 60
}

Requirements:

  • Do not nest a job object.
  • Do not create any other jobs.
  • After success, reply with the new job id only.

Step 2

Run a second agent turn and tell it to use the cron tool exactly once to update that same job with
these flat top-level arguments:

{
  "action": "update",
  "jobId": "<JOB_ID_FROM_STEP_1>",
  "model": null,
  "fallbacks": null,
  "toolsAllow": null
}

Requirements:

  • Use flat top-level update fields only.
  • Do not send a nested patch object.
  • After success, reply with one short sentence confirming the update.

Step 3

Verify in the cron job view that model, fallbacks, and toolsAllow are no longer present on the
stored payload.

Step 4

Delete the test job.

Output from openclaw:
"The test steps from TEST-flatfields-extended.md have been executed.

Execution Log

Step Action Details Result
1 Create Job action: "add", name: "flat-nullclear-test-DELETEME", model: "openai/gpt-5.4", fallbacks: ["openai/gpt-5-mini"], toolsAllow: ["exec"] Success. Created job bda0c0b8-39fd-4441-8c88-869fc1987cb4.
2 Update Job action: "update", jobId: "bda0c0b8-39fd-4441-8c88-869fc1987cb4", model: null, fallbacks: null, toolsAllow: null Success. Payload message updated to "nulling fields test".
3 Verify Payload Inspecting job bda0c0b8-39fd-4441-8c88-869fc1987cb4 Success. The payload object no longer contains model, fallbacks, or toolsAllow keys.
4 Delete Job action: "remove", jobId: "bda0c0b8-39fd-4441-8c88-869fc1987cb4" Success. Job removed.

Verdict: The cron tool successfully handles flat top-level fields for creation and uses null to effectively clear those fields from the stored payload during an update.

Model: vllm/local_llama.gguf"

As before a separate test was also run with openai/gpt-5.4 for completeness, also successful.

This should satisfactorily demonstrate the claims made for the patch, i.e. exposed flat top-level cron payload fields are accepted on create/update; flat null updates correctly clear model, fallbacks, and toolsAllow from the stored payload; the fixed call shape works on the local-LLM path

Scope note: yes, agreed that this fix is intentionally narrow. It deals with the flat add/update schema but does not claim to resolve the separate contextTokens / maxSpendUsd contract discussed on '#64721'

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jun 28, 2026
@LinuxMum
LinuxMum force-pushed the fix/cron-tool-schema-fix branch from e9993f0 to 329900d Compare June 28, 2026 14:13
…fter main wake-routing changes; successfully tested on OpenClaw v2026.6.11-beta.2; prompt snapshots regenerated

Expose provider-compatible flat cron fields while retaining nested job and
patch support. Normalize malformed or stringified cron tool arguments,
preserve nullable flat update clears, and validate the prepared nested patch
after argument preparation.

Merge in the upstream wake-scope hardening from main so explicit wake
sessionKey and agentId targets remain constrained to the calling agent.

Verification:
- corepack pnpm test src/agents/tools/cron-tool.schema.test.ts src/agents/tools/cron-tool.test.ts src/agents/tools/cron-tool.flat-params.test.ts
- corepack pnpm prompt:snapshots:check
- live flat create/read/update/remove proof passed on OpenClaw v2026.6.11-beta.2
- live wake-scope proof rejected cross-agent sessionKey and agentId targets with the expected validation errors
@LinuxMum
LinuxMum force-pushed the fix/cron-tool-schema-fix branch from 329900d to 5b5f513 Compare June 30, 2026 08:48
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jul 2, 2026
@LinuxMum
LinuxMum force-pushed the fix/cron-tool-schema-fix branch from 2b1972e to 63894a8 Compare July 2, 2026 13:31
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. label Jul 2, 2026
Fix to reject incomplete flat schedule updates before dispatch
Keep the flat cron job fields out of Control UI admin schema
@LinuxMum

LinuxMum commented Sep 4, 2026

Copy link
Copy Markdown
Author

@clawsweeper re-review

Requesting a fresh review to reconcile inconsistent review outcomes.

(1) cron-tool.ts (c63a721f2523) and cron-tool-prepare.ts (0d957a3e8208) are byte-identical between the 12:55 and 13:16 reviews of the same head 3a34311. The first review reported Security: None, the second raised a medium security item citing cron-tool.ts:406. Nothing changed in that file inbetween
(2) toolsAllow recovery from flat arguments is pre-existing in main - CRON_FLAT_PAYLOAD_KEYS in cron-tool-canonicalize.ts already carries it into the payload. This PR adds only scalar-to-array normalisation, which routes a scalar from classifyExplicitToolsAllow's "resolved" branch into "finite", where each name is checked against the creator allowlist
(3) proof: Exact-head live proof is not humanly possible in this repo e.g. main advanced 51 commits in the 86 minutes around this PR's last sync, and two more in the 3 minutes between fetch and merge. Any build is inevitably behind head before it finishes and I then have to take time user testing the cron fixes in my live openclaw, by which time main has advanced further. I have provided log evidence from my live tests, if there is other proof you need please specify what is required (4) checks-node-compact-small-11 fails on incognito-session-transcript.test.ts, a session/state test outside this PR's ten-file diff

@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

Prove flat toolsAllow stays capped to creator authority before dispatch
@LinuxMum

LinuxMum commented Sep 4, 2026

Copy link
Copy Markdown
Author

Once stored, toolsAllow enforcement applies equally to nested jobs and flat-form jobs. Both become the same canonical payload and follow the same scheduler/runtime path.

This PR97339 changes only how flat input is recovered and capped before Gateway dispatch. It does not change later scheduled-run enforcement, which is the same for both flat form and nested jobs. Nothing at that stage differentiates persisted jobs created from flat input from nested jobs. This PR's changes are therefore irrelevant to that stage and so testing if a persisted toolsAllow is enforced when the job later executes is cron runtime code - src/cron/** - and beyond the remit of this PR

Request that PR97339 is returned to the maintainer look queue so a maintainer decision can be reached on whether to approve the flat contract for ongoing use and maintenance

@LinuxMum

LinuxMum commented Sep 4, 2026

Copy link
Copy Markdown
Author

On the flat message + text precedence comment from clawsweeper 2026-09-04

This is a deliberate, previously justified choice - see src/agents/tools/cron-tool-prepare.ts:40-44
at head 6c5069e1cd. The comment explains the distinction: schedule ambiguity is
rejected "because a wrong schedule fails invisibly", while payload conflicts are tolerated
because "their result is visible on the created job."

The invariant this PR enforces is fail visibly before any write. Schedule ambiguity is
rejected because its consequence is invisible and deferred: the job fires at the wrong
time, or a partial update silently replaces a stored schedule, but the user is likely unaware.

Payload precedence is different. cron.add returns the created job to the caller,
so the resolved payload.kind is in the immediate response. Nothing is hidden and nothing
is lost that isn't visible on readback

The bounded-risk case is also covered: toolsAllow is capped to creator authority before
dispatch, proven by two tests at this head — caps an allowed scalar flat toolsAllow to creator authority before dispatch and strips a scalar flat toolsAllow outside creator authority before dispatch

As stated, rejecting would cost exactly the tolerance this flat contract exists to provide.

Merge remote-tracking branch 'origin/main' into fix/cron-tool-schema-fix
Merge remote-tracking branch 'origin/main' into fix/cron-tool-schema-fix
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

Merge remote-tracking branch 'origin/main' into fix/cron-tool-schema-fix
…ts, preserve nested handling and update payload types, clarify guidance, and refresh regression tests and prompt snapshots.

Merge remote-tracking branch 'origin/main' into fix/cron-tool-schema-fix
@LinuxMum

LinuxMum commented Oct 17, 2026 •

Copy link
Copy Markdown
Author

@clawsweeper re-review
Your comments have been addressed, please return Ready for Maintainer Look label

@clawsweeper

clawsweeper Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@LinuxMum

Copy link
Copy Markdown
Author

live Gateway / local LLM proof

2026-10-17. All six acceptance checks passed.

  • Built from upstream 10204a799b492cf1e630ee4e74a6293c2b9c3929 with PR head aaf41bbd5e48905bb043b944e1e94faaf5526770.
  • Actual tool-calling assistant metadata: provider local Qwen3.8-27B-Q5_K_S on Llama.cpp (alias "vllm/local_llama.gguf"), verified on all eight calls. No external model supplied these calls.
  • Each prompt requested one exact dispatch_action call for automations. The controller checked actual arguments/results, not the model's narrative. Turns were deliberately aborted after the first result to prevent repair attempts; this is tool-level runtime proof, not a claim of normally completed assistant turns.
  • Fixtures were disabled. Authenticated Gateway readbacks independently checked persisted state; fixture creation and updates were performed by the local LLM through the live Gateway.
Check Result
Mixed nested + flat add Rejected; snapshot revision unchanged
Mixed nested + flat update Rejected; complete stored job unchanged, including revision
Flat text-only task update Retained agentTurn; edited message, no text
Nested text-only task update Retained agentTurn; edited message, no text
Flat text-only reminder update Retained systemEvent; edited text, no message
Nested text-only reminder update Retained systemEvent; edited text, no message

All fixture jobs were removed. Original job IDs and configuration revisions were unchanged after cleanup. Gateway configuration was unchanged; fallback settings were not modified.

Evidence

proof-transcript.txt
validation.json

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@LinuxMum

LinuxMum commented Oct 18, 2026 •

Copy link
Copy Markdown
Author

ClawSweeper has accepted the proof and reports no actionable findings. The remaining item is a maintainer decision on the flat contract. @clawsweeper re-review please restore “ready for maintainer look” and remove "stale" label

@LinuxMum

Copy link
Copy Markdown
Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@steipete

Copy link
Copy Markdown
Contributor

A focused repair from this investigation has shipped in #182824: 2cd2e62.

Malformed job wrappers now reach the existing flat/dotted/alias recovery before schema validation. Valid nested and serialized jobs retain precedence, and the advertised schema is unchanged. The scheduler's scoped-read path recognizes only the exact native preparer; write authority remains enforced.

The repair has 134 passing focused tests and isolated Gateway creation/readback proof. It landed through the native inherited-failure exception for the separate stream-approval agent.wait timeout, reproduced with the unchanged test on the exact base; that CI run remains recorded as failed.

This does not adopt the broader flat-field schema or the other behavior changes proposed here, so this PR remains open. Thanks @LinuxMum for the work that motivated the investigation.

@steipete

Copy link
Copy Markdown
Contributor

Thanks @LinuxMum. This PR prompted a proper look at how small local models handle the cron/automation tool, and that turned up a real bug, now fixed separately.

We measured instead of guessing: 10 cron tasks × 3 runs × 3 local models (Qwen3 8B, Qwen3.5 4B, Qwen2.5 7B) through a real Gateway, checking the saved job each time. We compared the current schema, this PR's flat form, and two general redesigns applied to every model instead of only small ones.

  • This PR's flat advertisement cost about 520–580 more tool tokens per request, with mixed results.
  • Flattening the job fields for everyone helped the smaller models a lot (Qwen3.5 4B 9→23/30, Qwen2.5 7B 7→16/30) and was slightly cheaper, but it consistently hurt Qwen3 8B (24→17/30). It started confusing sessionTarget with delivery.target, and once overwrote a stored prompt on an interval-only update.

Because the strongest local model regressed, we're keeping the current nested schema for now.

The concrete failure you hit, a string job with otherwise usable flat fields being rejected with job: must be object before recovery ran, is fixed in #182824 (2cd2e629), which credits you. Such calls are now recovered and saved.

Closing this one as not planned. Thanks again for pushing on small-model reliability here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL stale Marked as stale due to inactivity status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants