Skip to content

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

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

wangmiao0668000666 wants to merge 2 commits 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. The refusal is gated on the existing finite/resolved request classification, so a symbolic selector (*, group:*) whose runtime expansion is empty — e.g. group:plugins against a capture with no plugin tools — keeps the base empty-cap behavior instead of throwing.

Production LOC is +32/-1 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: f4899c2a010bafbb446d0e209bd095079c913a5b (branch fix/cron-creator-cap-silent-empty, rebased onto origin/main 21ecc39d75d)
  • Current-main RED baseline: origin/main 21ecc39d75d (the rebase base); the RED runs below execute the origin/main bytes of src/agents/tools/cron-tool-creator-cap.ts, and the bug is still present there — current main assigns the filtered creator tools directly to toolsAllow without rejecting a wholly unmatched finite selection
  • 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 (Revision 1 unit-test lane)

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 (Revision 1 SHAs)
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)

Real Gateway proof (no mocks at the behavior boundary)

Revision 2, head f4899c2a010bafbb446d0e209bd095079c913a5b. Real startGatewayWithClient Gateway (token auth, cron enabled, isolated temp state dir, SQLite cron store) driven by a loopback mock model server: the model calls the automations tool with action: "add" and payload.toolsAllow: ["future__tool"]; the second provider request carries the tool result back, and cron.list is read afterward. The behavior boundary under test is the tool result the Gateway feeds the model plus the persisted job set — no callGateway mock anywhere in the path.

# RED — same driver, production bytes from origin/main (21ecc39d75d) swapped in
PROOF_CHAT_SEND_STATUS started
PROOF_AGENT_WAIT_STATUS ok
PROOF_TOOL_RESULT_TEXT { "id": "bb758538-...", "name": "pr167560-proof-job",
  "enabled": true, "schedule": { "kind": "every", "everyMs": 3600000 }, ... }   # add ACCEPTED
PROOF_REFUSAL_ERROR_VISIBLE false
PROOF_TARGET_JOBS_SAVED 1
PROOF_SAVED_JOB_TOOLS_ALLOW []          # <- the silent empty cap this PR removes
PROOF_VERDICT RED: add accepted, job saved with capped toolsAllow
 Tests  1 failed (1)                    # proof assertions fail on main bytes, as expected
# GREEN — exact head f4899c2a010
PROOF_CHAT_SEND_STATUS started
PROOF_AGENT_WAIT_STATUS ok
PROOF_TOOL_RESULT_TEXT { "status": "error", "tool": "automations",
  "error": "Cron add requested tools outside this turn's captured tool surface (future__tool).
            Retry from a fresh authenticated direct-local operator turn, or create/edit via the CLI
            or Gateway with an explicit finite toolsAllow list containing only currently visible
            tools; no automation changes were saved." }
PROOF_REFUSAL_ERROR_VISIBLE true
PROOF_TARGET_JOBS_SAVED 0               # cron.list: nothing persisted
PROOF_VERDICT GREEN: unmatched finite add refused, no job saved
 Tests  1 passed (1)

Lane: this workstation, Node v24.18.0, vitest run --config test/vitest/vitest.e2e.config.ts against src (tsx). The driver is an untracked proof file; it is not part of the PR diff.

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 (Revision 1)
  • Revision 2 (rebased head, this workstation, Node v24.18.0): vitest run src/agents/tools/cron-tool-creator-cap.test.ts src/agents/tools/cron-tool.test.ts — 78 passed (both files), including the new symbolic-group regression case (group:plugins, and group:plugins mixed with an unmatched finite name, against a read-only capture both keep the empty-cap base behavior)
  • 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 in progress

ClawSweeper is reviewing this revision. This supersedes any previous blocked status.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Oct 9, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 9, 2026
@clawsweeper

clawsweeper Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

The automation tool rejects a new job when every explicitly requested tool is unavailable in the creating turn, instead of silently saving a job with no tools.

Example: An agent creates an automation requesting toolsAllow: ["future__tool"] while its captured tools contain only read.

  • Before: Creation succeeds and saves toolsAllow: [].
  • After: Creation returns an error naming future__tool and saves no automation.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The narrow patch has convincing Gateway proof and no remaining code findings, while partial issue coverage and the creation-policy decision limit overall readiness.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The exact-head terminal trace drives the production automation tool through an authenticated isolated Gateway using a synthetic loopback model, observes the future__tool refusal in the returned tool result, and confirms zero saved jobs through cron.list; the baseline saves an empty cap. This proves the changed creation boundary, without claiming native Codex alias resolution. Stored formats and existing-state readers are 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: Partial
User problem: An automation is reported as successfully created even though none of its requested tools will be available when it runs.
Reason: Early refusal prevents a concrete misleading success and is narrowly implemented. Because the existing creator-cap contract accepts the available intersection, its owner should approve changing the wholly unmatched creation outcome.

Merge readiness

⛔ Blocked before merge - 1 item remains

This PR contains useful work that current main does not provide. The prior symbolic-selector finding is fixed, and no introduced correctness defect remains; changing the established creation-success behavior still needs the area's owner decision.

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

Decision needed

  • Question: Should a wholly unmatched finite tool selection make a new agent automation fail atomically, while existing update narrowing remains unchanged?
  • Recommendation: Approve the narrow refusal: Reject wholly unmatched finite adds with the demonstrated actionable error while preserving partially matched adds and updates.
  • Why: The existing owner-built policy and tests deliberately save the available intersection, including an empty one; this PR changes its successful creation outcome, and no area-owner acceptance of that change is recorded.

Before merge

  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.

Findings

None.

Agent review details

How this fits together

OpenClaw's automation tool turns agent requests into scheduled jobs stored by the Gateway. Its creator-tool policy limits requested tools to those available to the creating turn before the job is saved.

flowchart LR
A[Agent requests automation] --> B[Capture available creator tools]
B --> C[Intersect requested tool selection]
C --> D{Finite selection has no matches?}
D -->|Yes on new add| E[Return actionable error]
D -->|No| F[Gateway saves scheduled job]
F --> G[Scheduled execution applies tool policy]
Loading

Technical review

Best possible solution:

Approve the narrow add-time refusal while leaving authenticated native alias resolution and add/update identity consistency with the linked issue.

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

Yes: current-main source saves an empty intersection for future__tool against a read-only capture, and the contributor supplies a baseline-to-head real-Gateway trace for that exact scenario. This read-only review did not execute the reproduction.

Is this the best way to solve the issue?

Yes for the narrow silent-creation problem: the change uses the existing cap owner and preserves partial matches, symbolic groups, and updates. It is only a partial response to the linked issue's native alias and add/update identity requirements.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 2c5b2ccaa776.

Provenance checked

  • src/agents/tools/cron-tool-creator-cap.ts: finite creator-tool intersection changes intended behavior with a stated reason (151fbaa: The canonical-capture repair persisted canonical identities while matching trusted runtime aliases without widening the creator's finite tool ceiling.)
  • src/agents/tools/cron-tool-creator-cap.test.ts: unmatched explicit selection changes intended behavior with a stated reason (151fbaa: Canonical alias-capture coverage verified that unrelated selections could not authorize tools outside the creator's surface.)
  • src/agents/tools/cron-tool.test.ts: unknown finite add result keeps the original intent (test(ui,plugins,agents): remove low-value tests (batch d200) #164928: The test-cleanup batch consolidated equivalent scenarios while retaining distinct authorization and regression cases.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +31, Tests +48. Total +79 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 32 1 +31
Tests 2 70 22 +48
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 102 23 +79

Review metrics

Metric Value Why it matters
Production versus test LOC Production +32/-1; tests +70/-22 Production growth stays within the existing policy owner and provides bounded diagnostics without adding another validation surface.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • remove status: 📣 needs proof: Current PR status no longer selects a status label.

Label justifications:

  • P2: The change addresses a concrete but limited automation-creation failure with a successful canonical-tool workaround.
  • merge-risk: 🚨 compatibility: A previously successful wholly unmatched finite add now returns an error, although existing jobs and useful partially matched requests remain intact.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • 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 need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-09T01:43:31.250Z sha 48b7554 :: needs real behavior proof before merge. :: [P2] Restrict the new refusal to finite tool selections
  • reviewed 2026-10-09T01:51:22.432Z sha 48b7554 :: needs real behavior proof before merge. :: [P2] Restrict the new refusal to finite tool selections

Reviewed October 9, 2026, 8:34 AM ET / 12:34 UTC (Revision 3).

wangmiao0668000666 and others added 2 commits October 9, 2026 18:19
The unmatched-add refusal now fires only for finite selections. A
symbolic selector such as group:plugins resolves at runtime, so an
empty plugin expansion keeps the base behavior of an empty cap instead
of throwing.

Co-Authored-By: Claude Code <[email protected]>
@wangmiao0668000666
wangmiao0668000666 force-pushed the fix/cron-creator-cap-silent-empty branch from 48b7554 to f4899c2 Compare October 9, 2026 12:19
@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

Round 2 addresses both blocking items from the last review.

P2 finding (symbolic selectors rejected): the refusal is now gated on the existing finite/resolved request classification (classifyExplicitToolsAllow), so it fires only for finite selections. A symbolic selector whose runtime expansion is empty — group:plugins against a capture with no plugin tools — keeps the base empty-cap behavior, covered by a new regression case in cron-tool-creator-cap.test.ts (["group:plugins"] and ["group:plugins", "future__tool"] against a read-only capture both persist [] without throwing). Rebased onto current origin/main (21ecc39d75d); the branch also picks up the main-side fix for the prepared-model-catalog import cycle that was failing check-guards-architecture.

Real behavior proof: added to the body under "Real Gateway proof (no mocks at the behavior boundary)". A real Gateway (token auth, cron enabled, isolated temp state, SQLite cron store) is driven by a loopback mock model; the model calls automations add with toolsAllow: ["future__tool"].

  • RED (origin/main bytes of the owner file): add accepted, cron.list shows pr167560-proof-job persisted with toolsAllow: [].
  • GREEN (head f4899c2a010): tool result is "status": "error" with Cron add requested tools outside this turn's captured tool surface (future__tool). …no automation changes were saved., and cron.list shows nothing saved.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 9, 2026
@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

Closing this PR: the current empty-intersection persistence is deliberate owner-designed behavior (introduced and tested in #130579 — the creator-cap contract intentionally saves the available intersection, including an empty one). This PR changes that established creation-success outcome, which is an area-owner design decision, not a defect fix. Withdrawing rather than leaving it parked on a maintainer decision.

The silent-empty-cap observation stays documented in #167281 for the owner to weigh against the alias-resolution work there.

@wangmiao0668000666
wangmiao0668000666 deleted the fix/cron-creator-cap-silent-empty branch October 10, 2026 01:10
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: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant