Skip to content

fix(cron): add cron edit --clear-model to clear a job's model override#91625

Merged
vincentkoc merged 3 commits into
openclaw:mainfrom
ly-wang19:fix/cron-cli-clear-model
Jun 15, 2026
Merged

fix(cron): add cron edit --clear-model to clear a job's model override#91625
vincentkoc merged 3 commits into
openclaw:mainfrom
ly-wang19:fix/cron-cli-clear-model

Conversation

@ly-wang19

Copy link
Copy Markdown
Contributor

Summary

Root cause

src/cli/cron-cli/register.cron-edit.ts only ever assigns model when it is truthy:

assignIf(payload, "model", model, Boolean(model)); // empty/absent -> not sent

There was no clear flag, so the CLI could never produce the model: null patch that mergeCronPayload (src/cron/service/jobs.ts) already honors:

if (typeof patch.model === "string") next.model = patch.model;
else if (patch.model === null) delete next.model; // <- reachable from RPC, not CLI

--clear-tools already demonstrates the intended pattern for the sibling toolsAllow field (payload.toolsAllow = null).

What changed (src/cli/cron-cli/register.cron-edit.ts)

  • Add the --clear-model option.
  • Reject --model + --clear-model together (matches the existing --agent/--clear-agent and --session-key/--clear-session-key guards).
  • Include --clear-model in the agentTurn-payload trigger so a clear-only edit still builds the patch.
  • Emit payload.model = null when --clear-model is set (mirrors --clear-toolstoolsAllow: null).

Net +10 / -1 in prod, +28 test.

Scope boundary

Only model is addressed: its RPC null-clear already shipped (#91298), so the CLI flag is the sole missing piece. Sibling agentTurn override fields (thinking, fallbacks) are not yet clearable at the RPC layer either — open PR #67429 adds that — so their CLI clear flags are the natural follow-up once #67429 lands. This change is orthogonal to #67429 (no shared files, no overlap).

Change Type

  • Bug fix

Linked Issue

Source-discovered while reading the cron clear-override paths. Completes the CLI half of #91298 (model-clear); related: #67429 (RPC null-clear for fallbacks/thinking).

Evidence

  • Failing before / passing after. New test clears the model override with --clear-model asserts cron edit <id> --clear-model sends { payload: { kind: "agentTurn", model: null } }. Before this change the flag does not exist, so the parse errors with unknown option '--clear-model'. New help-doc test asserts --clear-model is documented alongside --clear-tools. Full file: 6/6 tests pass (Node 22.22.1).

Real behavior proof

Behavior addressed: openclaw cron edit <id> --clear-model now removes a cron job's payload.model override (reverting the job to the agent/default model); previously there was no CLI way to clear it.

Real environment tested: local OpenClaw dev gateway (gateway run --dev --auth none) on Node 22.22.1 (macOS), isolated OPENCLAW_STATE_DIR/OPENCLAW_HOME, CLI driven via scripts/run-node.mjs against the live gateway RPC.

Exact steps or command run after this patch:

$ openclaw cron add --every 1h --session isolated --message hi --model anthropic/claude-sonnet-4-6 --name clearmodel-proof
$ openclaw cron edit <id> --clear-model
$ openclaw cron edit <id> --model anthropic/claude-sonnet-4-6 --clear-model

Evidence after fix (live gateway output, payload read back via cron list --json):

BEFORE clear:
  payload = {"kind": "agentTurn", "message": "hi", "model": "anthropic/claude-sonnet-4-6"}

$ openclaw cron edit 4ee52523-084a-4fd9-9fe2-6864dfe2ba1a --clear-model
  (ok)
AFTER  clear:
  payload = {"kind": "agentTurn", "message": "hi"}          <- model override removed

$ openclaw cron edit 4ee52523-084a-4fd9-9fe2-6864dfe2ba1a --model X --clear-model
  Error: Use --model or --clear-model, not both             <- conflict guard

Observed result after fix: the model key is deleted from the stored cron payload (job now runs on the agent/default model); passing both --model and --clear-model is rejected.

What was not tested: a live agent run of the cleared cron job (the clearing behavior is fully observable in the persisted payload via the gateway; running the job would require a real model/provider).

Compatibility / Migration

Backward compatible — purely additive CLI flag. No config/schema/migration changes (the Gateway already accepts model: null on cron.update).

AI assistance

AI-assisted (Claude Code). Verified locally: 6/6 unit tests, oxlint clean, oxfmt clean, and the live before/after gateway proof above. Author understands the change.

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: XS proof: supplied External PR includes structured after-fix real behavior proof. labels Jun 9, 2026
@clawsweeper

clawsweeper Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed June 15, 2026, 11:40 AM ET / 15:40 UTC.

Summary
The branch adds openclaw cron edit --clear-model, sends payload.model = null, rejects it with --model, and updates cron docs and CLI tests.

PR surface: Source +13, Tests +28, Docs +4. Total +45 across 4 files.

Reproducibility: yes. Source inspection shows current main can clear payload.model through cron.update, but cron edit has no --clear-model option and only serializes non-empty --model strings.

Review metrics: 1 noteworthy metric.

  • CLI flags: 1 added. --clear-model is a new public cron edit flag, so maintainers should confirm the spelling, help text, and docs before merge.

Merge readiness
Overall: 🦞 diamond lobster
Proof: 🦞 diamond lobster
Patch quality: 🦞 diamond lobster
Result: ready for maintainer review.

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

Next step before merge

  • No automated repair lane is needed; the remaining action is normal maintainer review and merge decision for the clean implementation PR.

Security
Cleared: No concrete security or supply-chain concern found; the diff is limited to cron CLI code, focused tests, and public docs.

Review details

Best possible solution:

Land the additive CLI flag with docs and regression coverage so users can clear cron model overrides through the existing update contract.

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

Yes. Source inspection shows current main can clear payload.model through cron.update, but cron edit has no --clear-model option and only serializes non-empty --model strings.

Is this the best way to solve the issue?

Yes. Mapping an additive CLI flag to the already-supported model: null patch contract is the narrowest maintainable fix; adding a new backend shape would duplicate the existing contract.

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P2: This is a bounded cron CLI bugfix for model override cleanup with limited blast radius and clear workarounds.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body includes structured after-fix live dev-gateway output showing cron edit --clear-model removes payload.model and rejects --model with --clear-model.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes structured after-fix live dev-gateway output showing cron edit --clear-model removes payload.model and rejects --model with --clear-model.
Evidence reviewed

PR surface:

Source +13, Tests +28, Docs +4. Total +45 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 1 14 1 +13
Tests 1 28 0 +28
Docs 2 5 1 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 47 2 +45

What I checked:

Likely related people:

  • 849261680: Authored the current backend model-null clear commit that this CLI flag exposes. (role: introduced related backend behavior; confidence: high; commits: cfeaf6897fd8; files: src/cron/service/jobs.ts, src/cron/normalize.ts, packages/gateway-protocol/src/schema/cron.ts)
  • vincentkoc: Committed the backend model-clear fix to main and closed the related issue with proof. (role: recent fix integrator; confidence: high; commits: cfeaf6897fd8; files: src/cron/service/jobs.ts, src/cron/normalize.ts, packages/gateway-protocol/src/schema/cron.ts)
  • steipete: History shows prior cron edit payload patch refactors and preservation fixes in the same CLI command path. (role: cron CLI area contributor; confidence: medium; commits: 96be166bd6f1, 1b973caf7aea; files: src/cli/cron-cli/register.cron-edit.ts, docs/cli/cron.md)
  • andyk-ms: Added the sibling --clear-tools and nullable toolsAllow pattern that this PR mirrors. (role: adjacent clear-semantics contributor; confidence: medium; commits: 4d8c07b97c0b; files: src/cli/cron-cli/register.cron-edit.ts, src/cron/normalize.ts, src/cron/types.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.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jun 9, 2026
ly-wang19 added a commit to ly-wang19/openclaw that referenced this pull request Jun 10, 2026
Address ClawSweeper review on openclaw#91625: the new public --clear-model CLI
flag needs docs. Add it beside the existing --model param and the API
model:null clear guidance in the cron CLI reference and automation guide.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Jun 10, 2026
@ly-wang19

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review — addressed the docs finding: --clear-model is now documented in docs/cli/cron.md (Models section) and docs/automation/cron-jobs.md (the --model ParamField and the model-override clear note), beside the existing --model and API model: null guidance. Commit 0b3188d.

@clawsweeper

clawsweeper Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jun 10, 2026
ly-wang19 added a commit to ly-wang19/openclaw that referenced this pull request Jun 10, 2026
Address ClawSweeper re-review on openclaw#91625: the help text and docs said
--clear-model reverts to the agent/default model, but clearing the per-job
model restores normal cron model-selection precedence — a stored
cron-session override still applies if set. Reword help string and both
cron docs to state precedence accurately. No behavior change.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@ly-wang19

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review — addressed the P1 precedence accuracy point: the --clear-model help string and both cron docs now say clearing restores normal cron model-selection precedence (a stored cron-session override still applies if set, otherwise the agent/default model) instead of implying it always reverts to agent/default. Reworded register.cron-edit.ts:111 help text, the --clear-model ParamField in docs/automation/cron-jobs.md, and the Models line in docs/cli/cron.md. No behavior change; 6/6 tests still pass. Commit 5a394e7.

@clawsweeper

clawsweeper Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Jun 10, 2026
@clawsweeper clawsweeper Bot added rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jun 10, 2026
@ly-wang19

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review — the previous review run reported "Review did not complete" and reverted the rating to off-meta. Re-requesting a clean pass. No behavior changed since the diamond-lobster proof run: commit 5a394e7 only reworded the --clear-model help string and cron docs for model-precedence accuracy. The live before/after gateway proof in the PR body still holds (payload model removed by cron edit --clear-model).

@clawsweeper

clawsweeper Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

Re-review progress:

ly-wang19 and others added 3 commits June 11, 2026 18:40
The cron.update RPC already clears payload.model via model:null (openclaw#91298),
but CLI cron edit had no flag to send it, unlike --clear-tools for the
sibling toolsAllow. Add --clear-model mirroring that pattern, and reject
--model + --clear-model together.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Address ClawSweeper review on openclaw#91625: the new public --clear-model CLI
flag needs docs. Add it beside the existing --model param and the API
model:null clear guidance in the cron CLI reference and automation guide.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Address ClawSweeper re-review on openclaw#91625: the help text and docs said
--clear-model reverts to the agent/default model, but clearing the per-job
model restores normal cron model-selection precedence — a stored
cron-session override still applies if set. Reword help string and both
cron docs to state precedence accurately. No behavior change.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@ly-wang19
ly-wang19 force-pushed the fix/cron-cli-clear-model branch from 5a394e7 to 5eff2ff Compare June 11, 2026 10:41
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. labels Jun 15, 2026
@vincentkoc vincentkoc self-assigned this Jun 15, 2026
@vincentkoc
vincentkoc merged commit 0888deb into openclaw:main Jun 15, 2026
184 of 188 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: XS 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.

2 participants