-
-
Notifications
You must be signed in to change notification settings - Fork 52.7k
Description
Bug: cron.add tool call systematically fails due to schema mismatch & infinite retry loop
Summary
What went wrong?
The cron.add tool call fails systematically due to a schema mismatch between the LLM's perception (the tool definition) and the Gateway's internal validator. The LLM (e.g., Qwen 3 Coder) attempts to send a nested job: { ... } object, but the Gateway validator rejects it, explicitly requiring properties (name, schedule, sessionTarget, payload) at the top level. Additionally, the Gateway/Agent fails to handle the INVALID_REQUEST error as a fatal exception, causing the agent to enter an infinite retry loop, which results in a continuous stream of validation errors in the logs.
Steps to reproduce
- Start OpenClaw Gateway (v2026.2.2-3) from a local npm build.
- Use an LLM agent and ask it to: "Create a cron job named 'test' to run 'echo hello' every day at 5am".
- Observe the Gateway logs: the tool call is sent with a nested
jobobject as per the LLM's system instructions/tool schema. - The Gateway returns
errorCode=INVALID_REQUESTwith the message:must have required property 'name'; .... - The agent retries the call immediately, looping indefinitely every ~3 seconds with the same payload.
Expected behavior
- The
cron.addtool call should succeed when provided with valid parameters, aligning with the flat structure used by the CLI:openclaw cron add --name "test" --cron "0 5 * * *" --session main --system-event "echo hello"
- The tool definition (JSON Schema) provided to the LLM should be synchronized with the Gateway's internal validator (either both should be nested or both should be flat).
- The agent should stop and report a fatal error upon receiving an
INVALID_REQUEST(validation error) instead of retrying the same invalid payload.
Actual behavior
The tool call is rejected by the validator because it expects root-level properties instead of a nested job object. This triggers an infinite loop of failed tool calls, flooding the logs and preventing the task from ever finishing.
Environment
- OpenClaw version:
2026.2.2-3 (9c5941b) - Node version:
v25.5.0 - OS:
Linux 6.8.0-94-generic (x64)/ Ubuntu 24.04 - Install method: Local build / npm
- Model used: Local GPU / QWEN 3 CODER NEXT Q4_KXL
Logs or screenshots
02:18:03 info gateway/ws ⇄ res ✗ cron.add 0ms errorCode=INVALID_REQUEST errorMessage=invalid cron.add params: must have required property 'name'; must have required property 'schedule'; must have required property 'sessionTarget'; must have required property 'payload' conn=0021d9e7…2bd1 id=33fff351…dab1
02:18:03 error [tools] cron failed: invalid cron.add params: must have required property 'name'; must have required property 'schedule'; must have required property 'sessionTarget'; must have required property 'payload'
02:18:06 debug agent/embedded embedded run tool start: tool=cron
02:18:06 info gateway/ws ⇄ res ✗ cron.add 0ms errorCode=INVALID_REQUEST ...
Diagnosis
- The CLI
openclaw cron addworks with flat flags (--name,--cron,--session,--system-event). - The tool call schema (as received by the LLM) expects nested
job: { ... }. - The Gateway validator expects flat top-level fields (
name,schedule,sessionTarget,payload). - The agent retries validation failures, causing the infinite loop.
Suggested Fix
-
Align tool schema with validator
Update thecron.addtool definition to match the Gateway's internal validator — use flat, top-level fields (name,schedule,sessionTarget,payload) instead of nestedjob: { ... }. -
Prevent infinite retry on
INVALID_REQUEST
Modify the agent to treatINVALID_REQUESTerrors as terminal (no retry), since they indicate a user/tool mistake rather than a transient failure. -
Improve error messages
When validation fails, return a working CLI equivalent in the error response so users can work around the issue:Example usage: openclaw cron add --name "test" --cron "0 5 * * *" --session main --system-event "echo hello" -
Add tool call test suite
Include a test forcron.addto ensure the tool schema and Gateway validator stay in sync during future changes.