Skip to content

feat(cron): per-job model fallback override via payload.fallbacks (#26120)#26304

Merged
Takhoffman merged 1 commit intoopenclaw:mainfrom
yinghaosang:feat/cron-payload-fallbacks
Mar 1, 2026
Merged

feat(cron): per-job model fallback override via payload.fallbacks (#26120)#26304
Takhoffman merged 1 commit intoopenclaw:mainfrom
yinghaosang:feat/cron-payload-fallbacks

Conversation

@yinghaosang
Copy link
Copy Markdown
Contributor

@yinghaosang yinghaosang commented Feb 25, 2026

Summary

Cron jobs that pin a specific model (e.g. kimi-coding/k2p5) have no way to declare per-job fallbacks — if the model hits a rate limit, the job just fails and bumps consecutiveErrors. The global agents.defaults.model.fallbacks chain works, but you can't tailor fallback strategies per job without creating separate agents for each one.

Added payload.fallbacks to agentTurn cron payloads so each job can declare its own fallback chain. The existing runWithModelFallback machinery handles the rest — rate-limit detection, cooldown probing, candidate iteration all work unchanged.

Closes #26120

lobster-biscuit

Root Cause

cronAgentTurnPayloadSchema only exposed model as a string override. The fallbacksOverride param passed to runWithModelFallback in runCronIsolatedAgentTurn was hardwired to resolveAgentModelFallbacksOverride(cfg, agentId) — no path for per-job input.

Changes

  • Before: cron jobs inherit fallbacks from agent config or global defaults only. No per-job control.
  • After: payload.fallbacks (string array) takes priority when defined. Empty [] explicitly disables fallbacks. Undefined falls through to agent/global config as before.

Fallback resolution order is now: payload.fallbacksagents.list[id].model.fallbacksagents.defaults.model.fallbacks

Files

  • src/gateway/protocol/schema/cron.ts — added fallbacks to cronAgentTurnPayloadSchema
  • src/cron/types.ts — added fallbacks to CronPayload and CronPayloadPatch
  • src/cron/isolated-agent/run.ts — extract payload fallbacks, pass as fallbacksOverride with priority over agent-level config

Example

{
  "payload": {
    "kind": "agentTurn",
    "message": "Generate daily digest",
    "model": "kimi-coding/k2p5",
    "fallbacks": ["anthropic/claude-sonnet-4-6", "openai-codex/gpt-5.3-codex"]
  }
}

Tests

  • src/cron/isolated-agent/run.payload-fallbacks.test.ts — 3 tests: payload fallbacks forwarded to runWithModelFallback, agent-level fallbacks used when payload omits them, empty array disables fallbacks
  • pnpm build && pnpm check pass
  • pnpm protocol:check pass

Greptile Summary

Added payload.fallbacks field to cron agentTurn payloads, allowing per-job model fallback configuration. This extends the existing fallback system by enabling jobs to define their own fallback chains instead of inheriting from agent or global config.

The change integrates cleanly with the existing runWithModelFallback machinery in src/cron/isolated-agent/run.ts:408-419. The resolution order is: payload.fallbacks → agent-level fallbacks → global defaults. An empty array explicitly disables fallbacks for that job.

Key changes:

  • Schema addition in src/gateway/protocol/schema/cron.ts:10 adds optional fallbacks: Type.Array(Type.String())
  • Type definitions in src/cron/types.ts:65,81 document the new field
  • Implementation extracts payload.fallbacks with Array.isArray check before passing to runWithModelFallback
  • Three focused tests verify: payload fallbacks forwarded, agent fallbacks used when undefined, empty array disables fallbacks

Confidence Score: 5/5

  • Safe to merge with no risk
  • Clean, well-tested feature addition with no breaking changes. The implementation correctly uses the ?? operator to preserve existing fallback resolution behavior when payload.fallbacks is undefined, and the Array.isArray check ensures type safety. Tests verify all three scenarios (custom fallbacks, inherited fallbacks, disabled fallbacks). No modifications to existing behavior.
  • No files require special attention

Last reviewed commit: f3e2a87

@Takhoffman Takhoffman force-pushed the feat/cron-payload-fallbacks branch from f3e2a87 to db4bf10 Compare March 1, 2026 14:10
@Takhoffman Takhoffman merged commit f902697 into openclaw:main Mar 1, 2026
9 checks passed
@Takhoffman
Copy link
Copy Markdown
Contributor

Autoland update: rebased on latest main, re-ran full default verification, and merged.

Brutal quality take:

  • Idea quality: good. Job-scoped fallback policy is useful and avoids creating agent sprawl for scheduling-only differences.
  • Risk profile: low. Change is additive and contained to cron agent-turn payload parsing + fallback override wiring.
  • Behavior guardrails verified: payload.fallbacks has priority; undefined falls through to agent/global config; empty array intentionally disables fallback.

Verification run (worktree .worktrees/pr-26304):

  • pnpm install --frozen-lockfile
  • pnpm build
  • pnpm check
  • pnpm test:macmini

All checks passed.

zooqueen added a commit to hanzoai/bot that referenced this pull request Mar 1, 2026
CyberK13 pushed a commit to CyberK13/clawdbot that referenced this pull request Mar 1, 2026
ansh pushed a commit to vibecode/openclaw that referenced this pull request Mar 2, 2026
steipete pushed a commit to Sid-Qin/openclaw that referenced this pull request Mar 2, 2026
safzanpirani pushed a commit to safzanpirani/clawdbot that referenced this pull request Mar 2, 2026
steipete pushed a commit to Sid-Qin/openclaw that referenced this pull request Mar 2, 2026
robertchang-ga pushed a commit to robertchang-ga/openclaw that referenced this pull request Mar 2, 2026
hanqizheng pushed a commit to hanqizheng/openclaw that referenced this pull request Mar 2, 2026
execute008 pushed a commit to execute008/openclaw that referenced this pull request Mar 2, 2026
dorgonman pushed a commit to kanohorizonia/openclaw that referenced this pull request Mar 3, 2026
sachinkundu pushed a commit to sachinkundu/openclaw that referenced this pull request Mar 6, 2026
zooqueen added a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
zooqueen pushed a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
Mateljan1 pushed a commit to Mateljan1/openclaw that referenced this pull request Mar 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui gateway Gateway runtime size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Model Fallback Support for Cron Jobs

2 participants