Repository navigation
fix(cron): let configured fallbacks on other providers run for account-bound automations - #196539
Conversation
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
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis 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.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Partial Regression provenancePossible 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 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherCron 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]
Technical reviewBest 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
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +127, Tests +609, Docs +9, Other +2. Total +747 across 23 files. Added test files: 3. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (12 earlier review cycles; latest 8 shown)
Reviewed November 11, 2026, 3:18 AM ET / 08:18 UTC (Revision 13). |
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
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
OpenClaw-Publication: 08875cc0-255a-4937-97a5-75f98bc8534d
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
🦞👀 Re-review progress:
|
OpenClaw-Publication: e46f34f4-657b-4235-bf6d-50491ae904e6
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
OpenClaw-Publication: 5e43e37e-7df4-4bcb-972f-d3965b130913
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
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. |
|
Merged via squash.
|
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.
--modelhelp 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.
prepareCronRunInferencereturns run parameters for a provider: the pinned recorded account for the binding's provider, orscheduledLiveProviderAuthfor 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:
@profileon a fallback entry isn't applied to scheduled runs yet (same as interactive runs today).Evidence
Real-process matrix (published npm builds and this branch on the same state, isolated
env -istate, loopback providers; the primary fails withinsufficient_quotaunless noted).Latest stable, 2026.11.2 → this branch, with no Doctor step or edit:
--model …@profilejob refuses its configured fallback ("incompatible").2026.10.9 → 2026.10.10 → this branch (the #192463 path):
--model …@profilerepair: refused as incompatible. This branch: fails over.Fresh jobs on this branch:
insufficient_quota,rate_limitand 503 on the primary all fail over to the backup provider.openclaw models auth logoutof the recorded account, the run still fails over (it sends nothing to the primary).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:src/cron/session-run.cross-provider-fallback.integration.test.ts: the same failover through thesession: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 toopenai:primaryfalls 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.