Skip to content

fix(cron): refuse an automation add that would silently save no tools - #167550

Closed
wangmiao0668000666 wants to merge 1 commit into
openclaw:mainfrom
wangmiao0668000666:fix/cron-creator-cap-silent-empty
Closed

wangmiao0668000666 wants to merge 1 commit into
openclaw:mainfrom
wangmiao0668000666:fix/cron-creator-cap-silent-empty

Conversation

@wangmiao0668000666

@wangmiao0668000666 wangmiao0668000666 commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Related: #167281

What Problem This Solves

Fixes: cron add reports success but persists toolsAllow: [] when the request names only tools this turn does not hold, so the scheduled run silently has no tools and still reports ok.

On a complete creator capture, a finite toolsAllow request whose names all fall outside the captured surface is filtered to nothing by capCronJobToolsAllow (src/agents/tools/cron-tool-creator-cap.ts), and that empty cap is written through cron.add. #167281 hit this with a native Codex alias (mcp__<server>__get_calendar_view): add returned a job with toolsAllow: [] while update stored the same alias, and the scheduled run answered that the calendar tool "was unavailable in this run".

The incomplete-capture variant of the same decision already refuses loudly (INCOMPLETE_CRON_CREATOR_AUTHORITY_MESSAGE), so only the complete-capture path degrades silently.

Why This Change Was Made

capCronJobToolsAllow now refuses — for add only — a non-empty finite request that intersects to nothing, naming the requested tools and reusing the existing recovery guidance (CRON_CREATOR_AUTHORITY_RECOVERY_MESSAGE). A complete capture is positive proof that the creator cannot use those names, so persisting [] hides a job that can never run as asked.

  • All-unmatched finite request → error; cron.add is never called and the payload is left untouched.
  • Partially matched request → unchanged: the matching tools are still persisted (added as a positive control).
  • Empty request, wildcard, plugin group, runtime alias, script/systemEvent, and every update patch → unchanged. Updates keep their existing narrowing so unrelated edits stay possible.

Production LOC is +18/-2 in the single owner. No new validator, option, configuration, persistence, or migration surface.

Classification: behavior-completing

User Impact

An automation can no longer be created that silently runs with zero tools: the add fails at creation time and the error names the tools this turn cannot use. A caller that asks for a tool it does not hold must retry with tools it does, or create the job from the CLI/Gateway with an explicit finite list.

No stored job, schedule, delivery, or configuration changes. Existing jobs and every update path are untouched; only a new add whose whole finite selection is unusable now fails instead of saving an empty cap.

Evidence

Exact-head proof receipt

  • Product head SHA: 48b7554745de2660ba35fd5a4823ed528a551d57 (branch fix/cron-creator-cap-silent-empty)
  • Current-main RED baseline: 121417e32b0fec872d73a785865a47f1e25d797c (the branch base; none of the three touched files changed between that revision and 50d7eb1b7fbc, verified with git diff HEAD^ origin/main -- <files>)
  • Production entry: capCronJobToolsAllowOnCreate (real exported owner, src/agents/tools/cron-tool-creator-cap.ts) and the agent-tool entry executeCron → cron.add (src/agents/tools/cron-tool.ts:485)
  • Canonical owner exercised: capCronJobToolsAllow (src/agents/tools/cron-tool-creator-cap.ts:270) → createToolPolicyMatcher intersection
  • Decision surface: the persisted payload.toolsAllow cap and whether cron.add is called
  • Recorder/readback boundary: the thrown error text, the untouched payload.toolsAllow, and the cron.add call count
  • Cleanup: isolated temp state only; no Gateway, session, channel, token, or configuration was touched

Inspectable RED -> GREEN terminal trace

Remote lane 10.54.159.54, Docker lexiflow-all:latest, Node v24.18.0, against a clean origin/main tree. Base bytes re-read as md5 35578d47fcc9156f57a7bed48d7dfed7 before each run and restored byte-identical afterwards.

# RED — pristine production bytes, new expectation
$ node scripts/run-vitest.mjs run src/agents/tools/cron-tool-creator-cap.test.ts --maxWorkers=1
 × cron tool creator cap > caps explicit alias-name requests to the canonical persisted tool id
   → expected [Function] to throw an error
 Test Files  1 failed (1)
      Tests  1 failed | 17 passed (18)
[test] FAILED (exit 1)
# GREEN — exact head
$ node scripts/run-vitest.mjs run src/agents/tools/cron-tool-creator-cap.test.ts --maxWorkers=1
 Test Files  1 passed (1)
      Tests  18 passed (18)
[test] passed 1 Vitest shard
# Same lane on this workstation, Node v24.18.0 — real agent-tool entry
BASE 121417e32b0 src/agents/tools/cron-tool.test.ts
 × cron tool > refuses an add whose finite toolsAllow matches nothing instead of saving an empty cap
      Tests  1 failed | 58 passed (59)
HEAD 48b7554745d src/agents/tools/cron-tool.test.ts
      Tests  59 passed (59)

Verification

  • node scripts/run-vitest.mjs run src/agents/tools/cron-tool-creator-cap.test.ts src/agents/tools/cron-tool.test.ts --maxWorkers=1 — 18 passed, 59 passed
  • node scripts/run-vitest.mjs run src/agents/tools/cron-tool.management.test.ts src/agents/tools/cron-tool.output-contract.test.ts src/agents/tools/cron-tool.schema.test.ts src/agents/tools/cron-tool.flat-params.test.ts --maxWorkers=1 — 12 + 4 + 21 passed, including every update-patch case
  • tsc -p tsconfig.core.json --noEmit — no diagnostic in any changed file (the worktree reports 613 pre-existing declaration-portability errors in unrelated *-test-support files caused by this checkout's symlinked node_modules)
  • oxlint on the three changed files — 0 warnings, 0 errors; oxfmt --check clean; git diff --check clean
  • Not tested: the remote lane cannot execute cron-tool.test.ts, because its import graph switches Vitest to the compiled-subprocess worker and this host cannot restore the worker cache (openat2 beneath root: Function not implemented, the documented kernel 3.10 limit). That file's red→green above is the same command on the workstation lane; CI covers it.

Scope and risk

@clawsweeper

clawsweeper Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S r: too-many-prs Auto-close: author has more than twenty active PRs. labels Oct 9, 2026
@clawsweeper

clawsweeper Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper status: review started.

I am starting a fresh review of this pull request: fix(cron): refuse an automation add that would silently save no tools This is item 1/1 in the current shard. Shard 0/1.

This temporary status tracks the active review worker. The completed review will appear in the durable ClawSweeper review comment.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@openclaw-barnacle

Copy link
Copy Markdown

Closing this PR because the author has more than 20 active PRs in this repo. Please reduce the active PR queue and reopen or resubmit once it is back under the limit. You can close your own PRs to get back under the limit.

@openclaw-barnacle openclaw-barnacle Bot closed this Oct 9, 2026
@openclaw-barnacle

Copy link
Copy Markdown

Closing this PR because the author has more than 20 active PRs in this repo. Please reduce the active PR queue and reopen or resubmit once it is back under the limit. You can close your own PRs to get back under the limit.

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

Labels

agents Agent runtime and tooling r: too-many-prs Auto-close: author has more than twenty active PRs. size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant