Skip to content

fix(cron): recover whitespace-padded tool keys before validation - #95427

Closed
ZengWen-DT wants to merge 1 commit into
openclaw:mainfrom
ZengWen-DT:fix/95407-cron-whitespace-padded-keys
Closed

ZengWen-DT wants to merge 1 commit into
openclaw:mainfrom
ZengWen-DT:fix/95407-cron-whitespace-padded-keys

Conversation

@ZengWen-DT

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes #95407. Some small/local model tool-call serializers emit valid JSON for the cron tool's add action where specific top-level keys in the job object carry trailing whitespace — "schedule ", "sessionTarget ", "payload ", "enabled " — while keys like name/description and nested keys stay intact. The gateway cron.add schema is strict (additionalProperties: false), so these padded keys make the call fail validation with "must have required properties schedule, sessionTarget, payload", and the job is never created.

Why This Change Was Made

The cron tool already canonicalizes model-friendly/malformed shorthands before strict gateway validation in src/agents/tools/cron-tool-canonicalize.ts — including a sibling repairConcatenatedCronToolKeys recovery for an earlier local-model key-corruption shape (concatenated keys). The trailing-space variant is the same class of defect at the same boundary, so the narrowest, consistent fix is a sibling recovery step in that canonicalizer rather than loosening the gateway schema or touching shared cross-provider JSON parsing.

repairWhitespacePaddedCronToolKeys trims each top-level key and, only when the trimmed name is a known cron key, renames it onto the canonical key. It deliberately skips renaming when the canonical key already exists, so a genuine duplicate (e.g. both enabled and "enabled ") is left for strict validation to reject instead of being silently merged.

User Impact

Local/non-frontier models that pad cron job keys with whitespace can now successfully create scheduled jobs through the cron tool. Gateway validation stays strict; no config, schema, or migration changes. Frontier models that already emit clean keys are unaffected (the trim loop is a no-op when no padded known keys are present).

Evidence

Real-behavior proof: drove the actual production canonicalizeCronToolObject plus the real strict gateway validator validateCronAddParams (@openclaw/gateway-protocol) on the reporter's exact mangled payload. The mangled (trailing-space) input is rejected before the fix path and the recovered output is accepted after:

valid input accepted by strict schema:   true
mangled input accepted by strict schema: false
  first schema error: "must have required properties schedule, sessionTarget, payload"
mangled keys: ["name","schedule ","sessionTarget ","wakeMode","payload ","enabled "]
recovered keys: ["name","wakeMode","schedule","sessionTarget","payload","enabled"]
recovered input accepted by strict schema: true

Added regression tests through the full cron tool execute path in src/agents/tools/cron-tool.test.ts:

  • recovers whitespace-padded cron add keys from local tool-call parsers (asserts the gateway receives canonical keys and no padded key leaks);
  • keeps a padded duplicate key when the canonical cron key already exists (asserts no silent merge).

Test run (worktree-safe runner, full cron-tool suite):

node scripts/run-vitest.mjs src/agents/tools/cron-tool.test.ts
 Test Files  1 passed (1)
      Tests  126 passed (126)

Formatting (oxfmt --check) and lint (oxlint) pass on both touched files.

AI-assisted.

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

clawsweeper Bot commented Jun 20, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed June 20, 2026, 7:58 PM ET / 23:58 UTC.

Summary
The branch adds whitespace-padded cron job key recovery in src/agents/tools/cron-tool-canonicalize.ts and regression tests in src/agents/tools/cron-tool.test.ts.

PR surface: Source +21, Tests +46. Total +67 across 2 files.

Reproducibility: yes. as a source-reproducible path: current-main cron canonicalization leaves schedule , sessionTarget , payload , and enabled unchanged while strict cron.add validation requires exact keys. I did not run the live qwen35b/llamacpp serializer path in this read-only review.

Review metrics: none identified.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #95407
Summary: This PR is one open candidate fix for the canonical trailing-space cron job key bug; two sibling PRs attempt the same issue, and the older merged PR only covered concatenated key names.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🐚 platinum hermit
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P2] Wait for exact-head required checks to finish before merge.

Risk before merge

  • [P1] Exact-head CI was still queued or in progress, so maintainers should wait for required checks before merge.
  • [P1] The live qwen35b/llamacpp serializer path was not replayed; confidence comes from reporter evidence plus production canonicalizer/schema validation proof.

Maintainer options:

  1. Decide the mitigation before merge
    Land one narrow cron canonicalizer fix for the trailing-space key shape while keeping gateway schemas strict; this PR is a strong candidate if exact-head checks complete cleanly.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • No ClawSweeper repair lane is needed because the branch already contains a concrete candidate fix and no actionable code defect was found.

Security
Cleared: The diff only changes cron argument normalization and tests; it does not touch dependencies, workflows, secrets, auth, storage, or package execution paths.

Review details

Best possible solution:

Land one narrow cron canonicalizer fix for the trailing-space key shape while keeping gateway schemas strict; this PR is a strong candidate if exact-head checks complete cleanly.

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

Yes, as a source-reproducible path: current-main cron canonicalization leaves schedule , sessionTarget , payload , and enabled unchanged while strict cron.add validation requires exact keys. I did not run the live qwen35b/llamacpp serializer path in this read-only review.

Is this the best way to solve the issue?

Yes. The existing cron tool canonicalizer is the narrowest maintainable layer because related local-parser key recovery already lives there, while global JSON parsing or gateway schema loosening would broaden the blast radius.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 22bdda25551e.

Label changes

Label justifications:

  • P2: This is a normal-priority bug fix for cron job creation through affected local-model tool calls with a bounded agents/cron surface.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body includes copied live output exercising the production canonicalizer plus strict gateway validator on the reported mangled payload, along with the focused cron test command output.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes copied live output exercising the production canonicalizer plus strict gateway validator on the reported mangled payload, along with the focused cron test command output.
Evidence reviewed

PR surface:

Source +21, Tests +46. Total +67 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 21 0 +21
Tests 1 46 0 +46
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 67 0 +67

What I checked:

  • Current main lacks whitespace-key recovery: canonicalizeCronToolObject on current main copies the unwrapped job, then runs concatenated-key repair, schedule canonicalization, and payload canonicalization without any whitespace-padded key normalization. (src/agents/tools/cron-tool-canonicalize.ts:247, 22bdda25551e)
  • Cron add uses this canonicalization boundary: The cron.add path canonicalizes params.job before delivery checks, create normalization, and gateway submission, so this is the existing model-input repair layer. (src/agents/tools/cron-tool.ts:918, 22bdda25551e)
  • Gateway validation is strict: CronAddParamsSchema requires exact schedule, sessionTarget, and payload fields and rejects additional properties, matching the reported failure for keys like schedule . (packages/gateway-protocol/src/schema/cron.ts:478, 22bdda25551e)
  • PR adds narrow known-key repair: The PR diff trims leading/trailing whitespace only when the trimmed key is a known recoverable cron key, and skips overwriting an already-present canonical key. (src/agents/tools/cron-tool-canonicalize.ts:110, f7355ce394ba)
  • PR adds focused execute-path coverage: The PR adds a cron tool execute-path test for schedule , sessionTarget , payload , and enabled , plus a duplicate-key preservation test. (src/agents/tools/cron-tool.test.ts:1098, f7355ce394ba)
  • Canonical related issue remains open: Live issue data shows this PR uses closing syntax for the open bug report, and the issue describes the same trailing-space cron job key shape.

Likely related people:

  • vincentkoc: Current-main blame for CRON_RECOVERABLE_OBJECT_KEYS, repairConcatenatedCronToolKeys, and the cron add call path points to Vincent Koc's recent commit that carried the current cron tool surface. (role: recent area contributor; confidence: high; commits: 7c2fb845dbdf, 844f405ac1be; files: src/agents/tools/cron-tool-canonicalize.ts, src/agents/tools/cron-tool.ts, src/agents/tools/cron-tool.test.ts)
  • steipete: History shows Peter Steinberger authored the prior concatenated cron key recovery and earlier cron flat recovery refactors in the same tool boundary. (role: related fix author; confidence: high; commits: 810ef28557ed, efda761724fb, cc9be84b9c5b; files: src/agents/tools/cron-tool-canonicalize.ts, src/agents/tools/cron-tool.ts, src/agents/tools/cron-tool.test.ts)
  • Tyler Yust: Earlier history shows the flat-parameter recovery change for cases where LLMs omit the cron job wrapper, adjacent to this model-input repair surface. (role: earlier cron recovery contributor; confidence: medium; commits: 07375a65d898; files: src/agents/tools/cron-tool.ts, src/agents/tools/cron-tool.test.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@ZengWen-DT

Copy link
Copy Markdown
Contributor Author

Closing this one — it's a third competing one-line fix for the same trailing-whitespace cron key bug (#95407) already covered by sibling PRs #95421 and #95424. No need for another duplicate; deferring to whichever the maintainers prefer.

@ZengWen-DT ZengWen-DT closed this Jun 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: cron tool add action mangles certain key names in job parameter

1 participant