#9467: Cron: support flat params in cron.add tool call
agents
stale
Cluster:
Swarm Bug Fixes and Feature Requests
## Summary
LLMs (like Qwen 3 Coder) sometimes send job properties as flat params at the top level instead of nesting them in a `job` object. This adds support for both formats:
- **Nested** (existing): `{ action: "add", job: { name, schedule, ... } }`
- **Flat** (new): `{ action: "add", name, schedule, sessionTarget, payload, ... }`
The fix detects if `params.job` is missing but job properties (`schedule`, `payload`, `sessionTarget`) exist at the top level, and constructs the job object from those properties.
## Test plan
- [x] Added unit test for flat params format
- [x] All existing tests pass (16 tests)
Fixes #9283
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR updates the `cron` agent tool to accept `cron.add` parameters in either the existing nested format (`{ action: "add", job: {...} }`) or a new flat format (`{ action: "add", name, schedule, sessionTarget, payload, ... }`). It adds a unit test covering the flat format and adjusts the add-path to normalize whichever input shape is provided before calling the gateway’s `cron.add`.
<h3>Confidence Score: 4/5</h3>
- Mostly safe to merge, but a couple input-shape edge cases can cause incorrect cron.add payloads or unexpected errors.
- Change is small and has test coverage for the main new behavior, but the flat-param conversion currently forwards unrelated tool keys into the job payload and uses truthiness for detection, both of which can produce deterministic failures for certain inputs.
- src/agents/tools/cron-tool.ts
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#9430: fix: accept flat params for cron.add tool action
by dbottme · 2026-02-05
91.6%
#23221: fix(cron): recover flat patch params for update action and fix schema
by charojo · 2026-02-22
79.1%
#2071: fix: accept JSON string for cron.add job parameter (#1940)
by andrescardonas7 · 2026-01-26
77.6%
#18743: Cron Tool Hardening: Normalize Gateway Params and Enforce Valid Sch...
by cccat6 · 2026-02-17
73.8%
#8698: fix(cron): default enabled to true for new jobs
by emmick4 · 2026-02-04
73.1%
#13288: fix(cron): normalize string schedule/payload from non-frontier LLMs
by M00N7682 · 2026-02-10
72.4%
#12303: fix(cron): correct nextRunAtMs calculation and prevent timer stall
by colddonkey · 2026-02-09
72.3%
#5977: fix(ui): handle optional agentId and add updateCronJob function
by xpnobug · 2026-02-01
71.8%
#8701: fix: default enabled to true for cron jobs created via tool API
by maximus-claw · 2026-02-04
71.5%
#8307: fix(cron): improve tool description with reliable reminder guidance
by vishaltandale00 · 2026-02-03
71.3%