Skip to content

fix(cron): let configured fallbacks on other providers run for account-bound automations - #196539

Merged
fuller-stack-dev merged 14 commits into
mainfrom
openclaw/rapid-krill
Nov 12, 2026
Merged

fuller-stack-dev merged 14 commits into
mainfrom
openclaw/rapid-krill

Conversation

@obviyus

@obviyus obviyus commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #192009
Related: #192463, #172590

What Problem This Solves

Fixes: since #172590, a scheduled automation records one inference account and refuses every model on any other provider. Configured cross-provider fallbacks never run, so a quota failure, outage or rate limit on the primary provider fails the job. The same refusal fires when a job with no model of its own follows a default that moved to another provider, and a replaced or signed-out account fails the run before any fallback is tried.

User Impact

Cron jobs fail over to their configured fallback models on other providers again, with no Doctor step, edit or new command. That includes jobs already stored by 2026.10.10 and 2026.11.2.

  • The job's recorded account still governs its own provider exactly as before. Changing interactive defaults, auth order or last-used account never moves the job to another account on that provider, so fix: automations switch accounts when interactive defaults change #172590's billing guarantee holds.
  • Models on other providers select credentials live, the same way an interactive run does (auth order, last good, cooldowns).
  • A replaced, signed-out or removed recorded account refuses only that provider's models; the rest of the fallback chain still runs.
  • A job with no model of its own follows a default that moved to another provider, on live credentials.
  • Refusals name the automation and its real id, and print a command that works as typed. --model help now mentions @<profileId>.

Why This Change Was Made

#172590's goal was account and billing continuity on the provider a job already uses. Refusing every other provider protected nothing (the job had no account there to protect) and broke the documented fallback feature.

The recorded binding now applies per provider. prepareCronRunInference returns run parameters for a provider: the pinned recorded account for the binding's provider, or scheduledLiveProviderAuth for any other provider. The embedded runner's unrecorded-account guard (which exists for legacy unbound jobs) lets those live candidates through. A failed authorization of the recorded account is held and thrown only by that provider's candidate checks, so the chain continues.

No new state is stored and no schema, Doctor or standing-grant change is needed: stored bindings are read exactly as 10.10/11.2 wrote them, and older builds keep reading them the same way.

Accepted tradeoffs:

  • A fallback provider uses whatever account its live config selects, including an API key if that's what its auth order picks. The user configured that fallback chain; interactive runs behave the same.
  • Legacy jobs with no recorded account keep today's behavior (stored accounts need adoption). That rule is unchanged here.
  • @profile on a fallback entry isn't applied to scheduled runs yet (same as interactive runs today).
  • A healthy primary can still be skipped right after a quota failure while its billing cooldown lasts; that's existing fallback behavior, not specific to cron.

Evidence

Real-process matrix (published npm builds and this branch on the same state, isolated env -i state, loopback providers; the primary fails with insufficient_quota unless noted).

Latest stable, 2026.11.2 → this branch, with no Doctor step or edit:

  • 11.2: a --model …@profile job refuses its configured fallback ("incompatible").
  • This branch, one or two backup accounts: the same stored job fails over to the backup provider on its live account. The stored binding is unchanged.

2026.10.9 → 2026.10.10 → this branch (the #192463 path):

  • 10.9: fallback works. 10.10, after the documented --model …@profile repair: refused as incompatible. This branch: fails over.

Fresh jobs on this branch:

  • insufficient_quota, rate_limit and 503 on the primary all fail over to the backup provider.
  • After openclaw models auth logout of the recorded account, the run still fails over (it sends nothing to the primary).
  • A healthy primary runs on its recorded account.

Known limitation (unchanged by this PR): a branch-written state database is schema 39, which 2026.11.2 refuses to open, so rollback from this branch to 11.2 isn't possible. A stable hotfix needs a re-implementation on the release branch; this change is small enough for that.

Integration tests (real runner, SQLite, auth stores; only provider HTTP is faked, on loopback):

  • src/cron/isolated-agent.cross-provider-fallback.integration.test.ts:
    • a job stored exactly as 10.10/11.2 write it fails over to the backup provider; the backup follows its live auth order across runs; no state is written;
    • recorded account replaced, removed, or signed out (store and config): backup still serves the run, nothing is sent to the primary;
    • a job with no model of its own follows a default that moved to another provider, on live credentials;
    • the recorded provider stays on its recorded account even when interactive auth order prefers another one.
  • src/cron/session-run.cross-provider-fallback.integration.test.ts: the same failover through the session: target path, live and with the recorded account removed.
  • src/cron/isolated-agent.auth-continuity.integration.test.ts: a replaced or revoked recorded account never reaches the primary provider with any key, and the configured fallback serves the run.
  • src/auto-reply/reply/agent-runner-execution-session-events.test.ts: a session-target job bound to openai:primary falls back to a Claude CLI candidate, which selects its own account instead of rejecting the recorded openai profile.
  • src/cron/isolated-agent.auth-profile-propagation.test.ts: CLI-runtime mismatches on the recorded provider still refuse, with the new message and real job id.

Mutation checks: restoring main's refusal of other providers, or failing the run when the recorded account can't be authorized, fails 4 of the 5 new isolated-path cases. Removing the per-provider scoping of the selected account fails the signed-out case; passing the recorded selection to a cross-provider CLI fallback fails the Claude CLI case.

Suites (clean environment): 131 related files (cron isolated/session/doctor, Gateway cron methods, plugin scheduled runs, reply-runner CLI/embedded/fallback candidates, embedded auth plan, exec cron grants, cron CLI): all pass, 1 skipped. pnpm tsgo:core, pnpm tsgo:core:test, oxlint, format, line-cap and test-lines ratchets clean.

obviyus and others added 2 commits November 10, 2026 14:23
Jobs bound to one inference account (#172590) refused every fallback
candidate on another provider, so a provider outage or exhausted
subscription failed the run even with a configured cross-provider
fallback chain (#192009, #192463).

The binding now also records one account per fallback provider, captured
with the same rules as the primary. Each candidate runs on its own
provider's recorded account; interactive default or order changes still
cannot switch accounts. Unrecorded, replaced, or revoked fallback
accounts fail closed only when the chain reaches them. Gateway create and
fallback edits record the accounts, and Doctor adds missing fallback
accounts to legacy and already-bound jobs without touching recorded ones.

Co-authored-by: obviyus <[email protected]>
…ls on other providers

OpenClaw-Publication: b5f61b94-9163-4491-b59b-3ffe1014b644
@clawsweeper

clawsweeper Bot commented Nov 10, 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 docs Improvements or additions to documentation gateway Gateway runtime commands Command implementations size: XL labels Nov 10, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 10, 2026
@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR limits an automation’s recorded account binding to its provider and lets other configured providers select credentials live.

Example: An automation bound to openai:primary receives insufficient_quota and has backup/gpt-4.1 configured.

  • Before: The backup candidate is rejected because its provider differs from the recorded account.
  • After: The backup provider selects its live account and completes the run while OpenAI remains restricted to openai:primary.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused repair and authority-boundary coverage are sound; directly inspected executable proof is primarily integration coverage, and the linked explicit-authorization request is only partly addressed.
Proof confidence 🦐 gold shrimp (3/6) Sufficient (live_output): The maintainer reports isolated real-process fresh-install and published-build upgrade runs against loopback providers, including quota, rate-limit, outage and logout recovery; source-inspected production-runner HTTP cases cover allowed backup requests and rejection of replaced, removed or signed-out primary credentials before primary I/O. The separate proposal’s editor screenshots add no runtime coverage here.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Partial
User problem: Scheduled work fails during a primary-provider outage or quota limit even when another configured provider can complete it.
Reason: The maintainer-authored direction restores useful unattended recovery, but #192009 also requests explicit fallback-account approvals and support beyond bound jobs; this PR should relate to that request rather than close it.

Regression provenance

Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed.

Merge readiness

✅ Ready for maintainer review

This PR addresses a regression still present on main, resolves the previous CLI-profile finding, and introduces no further actionable defect found in this review.

Priority: P1
Reviewed head: 849dfc2711e7494268a53a90e869835c5c2c7285

Before merge

None.

Findings

None.

Agent review details

How this fits together

Cron sends isolated and session-targeted jobs through shared inference policy, which supplies candidate-specific account and runtime parameters to embedded or CLI execution.

flowchart TD
  A[Stored automation] --> B[Cron execution]
  B --> C[Shared inference policy]
  C --> D[Recorded provider account]
  C --> E[Other provider live selection]
  D --> F[Embedded or CLI runtime]
  E --> F
  F --> G[Provider request and run result]
Loading

Technical review

Best possible solution:

Land the focused provider-scoping repair while keeping explicit per-fallback account authorization tracked separately.

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

Current main deterministically rejects a fallback whose provider differs from the stored binding; affected-user traces and the supplied real-process matrix corroborate that path, without reviewer execution.

Is this the best way to solve the issue?

Provider scoping belongs in the existing shared inference owner, and the diff updates both execution paths without adding durable state or a competing account selector.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Recorded inference-account enforcement changes intended behavior with a stated reason (d25a316: Preserve account identity and billing through default/order changes, and reject replaced or revoked authorization.)
  • Shared isolated and session-target inference policy keeps the original intent (3d2f7ca: Route scheduled conversation work through ordinary session admission without creating a second authority owner.)
  • Captured runtime selection keeps the original intent (f31b33f: Prevent copied session overrides from moving the job onto a runtime incompatible with its recorded account.)
  • Forwarded CLI account selection keeps the original intent (ad505b9: Use the existing CLI credential selector and forward exactly the recorded account for its provider.)
  • Automation-specific account recovery diagnostics keeps the original intent (9e9048e: Translate shared MCP authorization errors into actionable automation account errors.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Jason (Json): Raw commit d25a316 adds src/cron/inference-binding.ts:7 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: d25a316fc7c3; files: src/cron/inference-binding.ts)
  • Peter Steinberger: Raw commit 3d2f7ca adds src/cron/run-inference.ts:1 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 3d2f7ca06b26; files: src/cron/run-inference.ts)
  • Josh Lehman: Raw commit f31b33f adds src/cron/inference-binding.ts:16 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: f31b33fdeee7; files: src/cron/inference-binding.ts)
  • Ayaan Zaidi: Raw commit 9e9048e adds src/cron/inference-binding.runtime.ts:148 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 9e9048e0da47; files: src/cron/inference-binding.runtime.ts)

PR surface

Source +127, Tests +609, Docs +9, Other +2. Total +747 across 23 files. Added test files: 3.

View PR surface stats
Area Files Added Removed Net
Source 13 239 112 +127
Tests 7 649 40 +609
Docs 2 12 3 +9
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 23 902 155 +747

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: Affected-user reports establish failed scheduled workflows and missed delivery during primary-provider quota windows despite working configured fallbacks.
  • merge-risk: 🚨 auth-provider: The patch changes scheduled credential selection and failure handling; live fallback-account selection and possible API-key billing are explicitly accepted in the maintainer-authored direction.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • 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 execution lanes are retired.

History

Review history (12 earlier review cycles; latest 8 shown)
  • reviewed 2026-11-10T17:12:25.641Z sha b9efc5f :: needs changes before merge. :: [P2] Allow explicit reauthorization of the recorded fallback profile
  • reviewed 2026-11-10T17:35:54.175Z sha 6ef0f67 :: blocked before merge. :: [P1] Require a submitted fallback selection before replacing its account | [P2] Pass the target session selection into bound-job Doctor repair
  • reviewed 2026-11-10T18:24:13.004Z sha 79850fd :: needs maintainer review before merge. :: none
  • reviewed 2026-11-10T18:31:50.227Z sha 79850fd :: needs maintainer review before merge. :: none
  • reviewed 2026-11-11T03:49:28.293Z sha 7122ffe :: blocked before merge. :: [P1] Exclude the requested primary from fallback-account capture
  • reviewed 2026-11-11T05:10:37.375Z sha 91440f1 :: blocked before merge. :: none
  • reviewed 2026-11-11T05:19:27.040Z sha 91440f1 :: blocked before merge. :: none
  • reviewed 2026-11-11T07:28:12.721Z sha cd86d4f :: needs changes before merge. :: [P2] [P2] Clear the primary profile before resolving a fallback CLI account

Reviewed November 11, 2026, 3:18 AM ET / 08:18 UTC (Revision 13).

obviyus and others added 4 commits November 10, 2026 19:57
Doctor no longer picks a fallback account for an already-bound job when several are eligible;
it names them and the --fallbacks <model>@<profileId> command. An explicit @Profile in a job's
fallbacks is now honored and recorded as the owner's choice, and each fallback account records
whether the owner named it or it was recorded automatically.

Co-authored-by: obviyus <[email protected]>
OpenClaw-Publication: 3d755641-ea0d-4c1e-8339-42067c795291
Fallback account capture now uses the run's already-resolved fallback candidate, so the
primary's model allowlist no longer rejects a fallback the chain itself allows. Doctor lint
names the eligible accounts for an ambiguous fallback instead of suggesting a --fix that
won't record it, and its hints use the real job id.

Adds proof that extending an already-bound job's binding keeps valid standing approvals
usable while approvals revoked before or after the upgrade, stale operator sources and the
pre-migration revision stay unusable; and Gateway create proof for explicit
model@profile fallbacks and fallbacks outside the primary allowlist.

Co-authored-by: obviyus <[email protected]>
OpenClaw-Publication: d4ef207f-d0ff-4dd0-9971-435e9a4b42c4
@obviyus

obviyus commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 10, 2026
OpenClaw-Publication: 08875cc0-255a-4937-97a5-75f98bc8534d
@openclaw-barnacle openclaw-barnacle Bot added the agents Agent runtime and tooling label Nov 10, 2026
@obviyus

obviyus commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added the clawsweeper:intake:bug Preliminary submission classification; full source review pending. label Nov 10, 2026
@clawsweeper

clawsweeper Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Nov 11, 2026
OpenClaw-Publication: e46f34f4-657b-4235-bf6d-50491ae904e6
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: 849dfc2711e7494268a53a90e869835c5c2c7285
  • Maintainer: @obviyus
  • Repository role: admin

These security sensitive changes were made:

  • src/agents/embedded-agent-runner/run/auth-plan.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.

Carefully review these changes before merging.

@obviyus

obviyus commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

OpenClaw-Publication: 5e43e37e-7df4-4bcb-972f-d3965b130913
@obviyus

obviyus commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@fuller-stack-dev

Copy link
Copy Markdown
Member

Thanks for working on this fallback regression. I've updated the related #196775; the two changes overlap, but make different tradeoffs.

Your current approach keeps the recorded account pinned on its provider, selects credentials live on other providers, and lets those candidates continue when the recorded account is unavailable. It avoids new stored schema/grants and leaves legacy unbound-account adoption unchanged.

#196775 takes the broader admission/persistence path: existing jobs automatically snapshot eligible, already-authorized policy at run admission, without a review command, checkbox, or per-job save. It retains recorded account lifetimes and live revocation checks; losing recorded/admitted authority stops the run rather than continuing on another provider. Conversion itself is run-local and preserves job definitions.

Sharing the link so reviewers can compare the smaller provider-scoped fix with the broader automatic-admission change and its account-boundary tradeoffs.

@fuller-stack-dev

Copy link
Copy Markdown
Member

Merged via squash.

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

Labels

agents Agent runtime and tooling cli CLI command changes commands Command implementations docs Improvements or additions to documentation merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. security-sensitive-changed size: XL 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.

[Feature]: Explicitly authorize cross-provider cron fallback accounts

2 participants