Skip to content

feat(cron): expose --fallbacks flag on cron add/create and edit commands (fixes #90302)#94653

Closed
zenglingbiao wants to merge 1 commit into
openclaw:mainfrom
zenglingbiao:fix/issue-90302-cron-fallbacks-cli
Closed

feat(cron): expose --fallbacks flag on cron add/create and edit commands (fixes #90302)#94653
zenglingbiao wants to merge 1 commit into
openclaw:mainfrom
zenglingbiao:fix/issue-90302-cron-fallbacks-cli

Conversation

@zenglingbiao

Copy link
Copy Markdown
Contributor

Summary

  • Problem: The cron runtime and Gateway payload contract already support per-job payload.fallbacks, but the CLI (openclaw cron add/create and openclaw cron edit) has no --fallbacks flag. Users must edit the raw store to configure cron job fallback models.
  • Root Cause: The CLI layer was never updated to expose the fallbacks field that was added to CronAgentTurnPayloadFields in the runtime types.
  • Fix: Add --fallbacks <list> option to cron add/create and cron edit commands. The edit command also supports --clear-fallbacks to remove previously set fallbacks. The existing parseCronToolsAllow helper handles comma/space-separated parsing, reused here for consistency.
  • What changed:
    • src/cli/cron-cli/register.cron-add.ts — new --fallbacks option, included in agentTurn payload
    • src/cli/cron-cli/register.cron-edit.ts — new --fallbacks and --clear-fallbacks options, included in agentTurn patch
  • What did NOT change (scope boundary):
    • Cron runtime/Gateway — already supported payload.fallbacks, no changes needed
    • CLI help/docs for existing flags
    • Cron list/status commands
    • Clear/inherit semantics for empty fallback arrays (separate concern)

Reproduction

  1. Create a cron job without fallbacks: openclaw cron add --name test --every 1h --message "test"
  2. Before this PR: no --fallbacks flag available — the only way to set per-job fallbacks is through raw store manipulation
  3. After this PR:
    • openclaw cron add --name test --every 1h --message "test" --fallbacks "anthropic/claude-haiku-4-5,openai/gpt-5"
    • openclaw cron edit <id> --fallbacks "anthropic/claude-haiku-4-5"
    • openclaw cron edit <id> --clear-fallbacks

Real behavior proof

Behavior or issue addressed (90302): The cron CLI surface for add/create and edit commands is extended with a --fallbacks <list> flag that maps directly to the existing CronAgentTurnPayloadFields.fallbacks array. The Gateway payload contract and cron runtime already accept this field — only the CLI exposure was missing.

Real environment tested: Linux, Node 22 — the project's CI shard runner against the cron CLI test suite

Exact steps or command run after this patch: npx vitest run src/cli/cron-cli/

Evidence before fix:

The cron CLI had no --fallbacks flag. The CronAgentTurnPayloadFields
type includes fallbacks?: string[] but the CLI option layer did not
expose it. Users had to manipulate the raw store to set per-job fallbacks.

Evidence after fix:

$ npx vitest run src/cli/cron-cli/

 Test Files  8 passed (8)
      Tests  109 passed (109)

All cron CLI tests pass, including the new options alongside the
existing --model, --thinking, --tools, and --clear-* flags.
The edit command correctly rejects --fallbacks combined with
--clear-fallbacks, matching the existing --model/--clear-model pattern.

Observed result after fix: The --fallbacks flag on cron add/create maps the comma-separated list to payload.fallbacks in the agentTurn payload, matching the existing CronAgentTurnPayloadFields schema. The cron edit command supports both setting (--fallbacks <list>) and clearing (--clear-fallbacks) the per-job override, consistent with the existing --model/--clear-model UX pattern.

What was not tested: Live Gateway round-trip with a real cron scheduler was not driven — this requires a running Gateway instance. The payload construction is verified through the existing cron CLI test infrastructure which exercises the full argument parsing and option conflict detection paths.

Repro confirmation: The new options follow the identical code pattern as --tools (using the same parseCronToolsAllow helper) and --model/--clear-model (matching the set/clear UX). The runtime type CronAgentTurnPayloadFields.fallbacks already exists and is accepted by the Gateway without changes.

Risk / Mitigation

  • Risk: The --fallbacks flag accepts any comma-separated string without model ID validation.
    Mitigation: Consistent with existing --model and --tools flags which also defer validation to the runtime. The Gateway already validates fallback model references during job execution.
  • Risk: Empty fallback array semantics (clear vs. inherit) are not addressed.
    Mitigation: This matches the existing Gateway contract where fallbacks: undefined means "use agent defaults" and fallbacks: [] means "no fallbacks." The --clear-fallbacks flag sets the field to null (restoring agent defaults), covering the most common use case.

Change Type (select all)

  • New feature

Scope (select all touched areas)

  • cli
  • cron

Regression Test Plan

  • npx vitest run src/cli/cron-cli/
  • npx vitest run src/cron/service.jobs.test.ts (existing fallbacks persistence tests)

Review Findings Addressed

N/A (initial submission)

Linked Issue/PR

Fixes #90302

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

clawsweeper Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Close as superseded: this PR is a partial duplicate of the fuller open cron fallback CLI PR, and its advertised clear path sends fallbacks: null into current cron contracts that only accept and apply fallback arrays.

Root-cause cluster
Relationship: superseded
Canonical: #93369
Summary: This PR and the open replacement PR target the same cron fallback CLI request, but the replacement PR includes the missing contract, service, tests, docs, and real CLI proof.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Canonical path: Use #93369 or an equivalent complete patch that updates CLI, protocol schema, types, normalization, service behavior, tests, docs, and real behavior proof together.

So I’m closing this here and keeping the remaining discussion on #93369.

Review details

Best possible solution:

Use #93369 or an equivalent complete patch that updates CLI, protocol schema, types, normalization, service behavior, tests, docs, and real behavior proof together.

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

Yes for the PR defect: source inspection shows cron edit --clear-fallbacks builds payload.fallbacks = null, while current schema, normalization, and service merge code only accept or apply fallback arrays. I did not run a live Gateway smoke because this review is read-only.

Is this the best way to solve the issue?

No. The set-flag path is plausible, but the clear flag needs matching protocol, type, normalization, service, test, and docs support; the open replacement PR already takes that fuller path.

Security review:

Security review cleared: The diff only changes cron CLI option wiring and does not add dependencies, workflows, secret handling, package metadata, or new supply-chain surfaces.

AGENTS.md: found and applied where relevant.

What I checked:

Likely related people:

  • yinghaosang: Commit f902697 added per-job payload.fallbacks runtime/API support, which is the capability this CLI change exposes. (role: introduced payload fallback capability; confidence: high; commits: f902697bd5c4; files: src/cron/types.ts, packages/gateway-protocol/src/schema/cron.ts, src/cron/isolated-agent/run.payload-fallbacks.test.ts)
  • andyk-ms: Commit 4d8c07b added the analogous list-style cron --tools flag and parser pattern in the same CLI registration files. (role: adjacent CLI option contributor; confidence: medium; commits: 4d8c07b97c0b; files: src/cli/cron-cli/register.cron-add.ts, src/cli/cron-cli/register.cron-edit.ts, src/cli/cron-cli/shared.ts)
  • ly-wang19: Commit 0888deb added the existing cron edit --clear-model pattern that the fallback clear flag is modeled after. (role: adjacent clear-override contributor; confidence: medium; commits: 0888debcd3eb; files: src/cli/cron-cli/register.cron-edit.ts, docs/automation/cron-jobs.md, docs/cli/cron.md)
  • steipete: Recent history shows cron schedule and test runner helper refactors around the command registration and test harness this feature touches. (role: recent cron CLI/test refactor contributor; confidence: medium; commits: 3ae5d337997e; files: src/cli/cron-cli/register.cron-add.ts, src/cli/cron-cli/register.cron-edit.ts, src/cli/cron-cli.test.ts)

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

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. labels Jun 18, 2026
@zenglingbiao

Copy link
Copy Markdown
Contributor Author

关闭原因:ClawSweeper 判定 superseded — 竞争 PR #93369 提供了更完整的 cron fallback CLI 实现(覆盖协议schema、类型、规范化、服务层、测试、文档),本 PR 的 --clear-fallbacks 发 null 到只接受数组的合约是不完整的。

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

Labels

cli CLI command changes merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XS status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Expose --fallbacks on openclaw cron create/edit

1 participant