Repository navigation
fix(agents): skip profile rotation for missing-model errors - #138943
teddytennant wants to merge 6 commits into
Conversation
|
🦞👀 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 skips auth-profile rotation for affirmative provider-wide missing-model errors while retaining rotation for ambiguous and account-scoped failures. Example: Two authorized profiles request primary-missing, which returns 404 The model primary-missing does not exist, with fallback-ok configured.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: current main still rotates credentials for affirmative missing-model failures, and this focused patch resolves the prior account, ambiguous-response, and plan-denial findings without introducing a new actionable defect. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe embedded agent's assistant-failure handler sends classified provider errors and terminal state to the shared failover policy, which chooses credential rotation, configured model fallback, or a surfaced error. flowchart TD
A[Provider response] --> B[Assistant failure handler]
B --> C[Model error classifier]
C --> D[Failover policy]
D --> E[Authorized profile rotation]
D --> F[Configured model fallback]
D --> G[Surfaced error]
Technical reviewBest possible solution: Land the narrow assistant failover distinction while preserving authorized account rotation and the existing configured fallback owner. Do we have a high-confidence way to reproduce the issue? Current-main source selects profile rotation for affirmative missing-model assistant failures, and the contributor's pre-patch CLI trace independently demonstrates that route; no target code was executed during this review. Is this the best way to solve the issue? The patch changes the existing shared failover owner, uses current failure text, preserves replay and cancellation checks, and conservatively retains credential rotation for the reported ambiguous and account-scoped cases. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against ea0e2099e059. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +77, Tests +200. Total +277 across 6 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes: No label 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 (18 earlier review cycles; latest 8 shown)
Reviewed October 12, 2026, 12:20 PM ET / 16:20 UTC (Revision 19). |
51a2c72 to
c12539f
Compare
c12539f to
c0d17bb
Compare
|
Issue #137910 is now fixed on This PR's current production change instead concerns |
|
dropped the Closes #137910 line. |
e2dfbba to
451e10b
Compare
|
dropped it from the commit too, so merge will not auto-close 137910. |
451e10b to
895535f
Compare
|
rebased onto main. missing-model errors skip profile rotation now; idle timeout still rotates, and I dropped the old same-model retry tests that don't match current failover. |
895535f to
ec2e878
Compare
|
rebased onto main for the reef delivery-scan fixture fix |
|
Working the ClawSweeper P1 next: the unconditional Plan:
Leaving this open until that lands (or a clean replacement PR if rebase fights get ugly). |
c97d10a to
cd16057
Compare
Assistant model_not_found failures skip auth-profile rotation only when the missing-model classifier proves the id is gone for the provider. Account-scoped copy such as "does not exist or you do not have access" still rotates to the next authorized profile before model fallback.
Co-authored-by: Teddy Tennant <[email protected]>
Skip profile rotation only when the error text says the model does not exist, was retired, or was deprecated. Generic 404 pages and bare not_found_error stay on rotate_profile. Co-authored-by: Teddy Tennant <[email protected]>
cd16057 to
822a45f
Compare
Co-authored-by: Teddy Tennant <[email protected]>
|
dropped the duplicated failover-policy cases. added a local stub-provider run to the pr body: a provider-wide missing model skips rotation and hits the fallback, and the access denial still rotates onto the second profile. the pre-patch policy rotates first on that same stub. head 60bd04e. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Keep main's model retirement and deprecation classifier and the run-budget timeout fallback. Preserve the provider-wide missing-model rotation skip. Co-authored-by: Teddy Tennant <[email protected]>
Plan, tier, subscription, and similar account-scoped denials such as Z.AI's "model not found for this plan" stay on profile rotation. Provider-wide missing models, including Ollama retirement notices, still skip rotation. Co-authored-by: Teddy Tennant <[email protected]>
|
kept rotation for plan-scoped model denials like z.ai's 'model not found for this plan' and added it to the boundary table. merged main and kept its retirement/deprecation and timeout handling. head e30623e. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Thanks @teddytennant for this fix and the careful distinction between missing models and account-access errors. A smaller, credited replacement has landed in #189716 (f4c0984), so I am closing this as superseded. |
What Problem This Solves
Assistant
model_not_foundfailures were rotating same-provider auth profiles before model fallback. A model the provider no longer serves cannot be fixed by another credential, so those runs spent a profile rotation and could surface idle-timeout copy for a failure that was never a credential fault.model_not_foundis also used for account-scoped denials and for ambiguous transport text.isModelNotFoundErrorMessageinsrc/agents/live-model-errors.tsmatches a plain missing id, copy such as "The model does not exist or you do not have access", generic404 page not found, and barenot_found_error. With two authorized profiles where only the second can use the selected model, skipping rotation on everymodel_not_foundwould switch models or fail despite a usable credential.Rotation is now skipped only when
isProviderWideModelNotFoundErrorMessageaffirmatively matches text that says the selected model does not exist, was retired, or was deprecated (for example, the model named as not found, or no longer available). It is a positive allowlist, not a broad missing-model match with denial phrases removed. Generic404 page not found, barenot_found_error, empty or unknown messages, and anything with access, permission, or account wording stay onrotate_profileand calladvanceAuthProfile. After authorized profiles are exhausted, configured model fallback still runs. TLS certificate failures and replay-safe idle timeouts are unchanged.Evidence
Rebased onto current
openclaw/openclawmain(e2dc6ad93f8aa03dcfde61cf37eb8948e75d27cc). Head822a45f2f8b8e64215cdc2c8f13740b4ade2f26f.isProviderWideModelNotFoundErrorMessagereturns true only for affirmative model-absence copy: the model named as not found, does not exist, retired, deprecated, or no longer available. Generic404 page not found, barenot_found_error, empty or unknown messages, and access, permission, or account wording return false and remain on profile rotation.The vitest and tsgo commands below were run on that same failover patch (previous head
cd160579392e1c3b5047dfb99d0554396ac6621d). A later conflict-free rebase ontoe2dc6ad93f8aa03dcfde61cf37eb8948e75d27ccdid not change the six failover files. That rebase picks up the workboard control-ui asset hash already on main so the bundled-plugin asset check is comparing current main bytes.node scripts/run-vitest.mjs run --config test/vitest/vitest.config.ts src/agents/live-model-errors.test.ts src/agents/embedded-agent-runner/run/failover-policy.test.ts src/agents/embedded-agent-runner/run/assistant-failure.test.tsThat run covers both paths: a provider-wide
404 model not foundgoes to model fallback withoutadvanceAuthProfile, and "The model does not exist or you do not have access" rotates to the next authorized profile. Amodel_not_foundreason with no proving message also keeps profile rotation. The same assistant-failure cases now assert that generic404 page not foundand barenot_found_errorstill calladvanceAuthProfileand recordrotate_profile.The cross-provider scenarios live in
src/agents/embedded-agent-runner/run.cross-provider-fallback-error-context.test-support.ts, imported by the shared integration entry:node scripts/run-vitest.mjs run --config test/vitest/vitest.config.ts src/agents/embedded-agent-runner/run.shared-integration.test.ts -t "cross-provider fallback"The compaction-removed case still expects two failover classifications. Its message is "current candidate model unavailable", which is not affirmative provider-wide absence, so same-provider rotation remains.
Typecheck:
node scripts/run-tsgo.mjs -p tsconfig.core.jsonpassed (exit 0).Those suites ran on this failover patch. No live vendor client was run for that head. A later local stub run is recorded below.
Local stub run
Follow-up head
60bd04e7281b794248d5a0d0a39bb4bea3d7c587drops the provider-wide fallback, account-scoped access denial, and ambiguous not-found cases fromsrc/agents/embedded-agent-runner/run/failover-policy.test.ts. The assistant-failure boundary table already covers those routes. The distinct no-fallback and absent-message policy cases stay.pnpm test -- src/agents/embedded-agent-runner/run/failover-policy.test.tsoxlintandoxfmt --checkon that file passed.The upstream was a local OpenAI-compatible stub on loopback, not a vendor. It served
/v1/chat/completions, returned ordinaryinvalid_request_error/model_not_foundJSON for failures, and SSE chat chunks for success. Two fake API keys were saved withopenclaw models auth paste-api-keyasstubproof:athenstubproof:b, andopenclaw models auth order setpinned that order. The fallback model wasstubproof/fallback-ok. Keys, the loopback address, and local config paths are redacted. Profile ids in the agent log are already hashed.The run was
openclaw agent execfrom this branch's built CLI, which is the embedded agent that owns the failover decision, with an explicit--model,--fallback,--code-mode direct, and--thinking off. It was not a long-lived gateway process. The embedded-run lines below are the same decision logs a gateway turn emits.Provider-wide missing model (this head)
The stub saw one
primary-missingrequest on profile-a, thenfallback-okon profile-a. Profile-b was not called.Agent stderr, with the repeated tools-policy warning omitted:
openclaw agent exec --jsonendedstatus=ok,final=PROOF_FALLBACK_OK,model=fallback-ok,provider=stubproof.Account-scoped access denial (this head)
The same stub returns
The model does not exist or you do not have accessfor profile-a ongated-model, and a normal completion for profile-b. The fallback model was not called.openclaw agent exec --jsonendedstatus=ok,final=PROOF_PROFILE_B,model=gated-model,provider=stubproof.Same stub before this patch
failover-policy.tswas restored toe2dc6ad93f8(the commit this branch was rebased onto, before the rotation skip) and the CLI dist was rebuilt. Source was restored and dist rebuilt from this head afterward. The CLI version line still printed822a45fbecause git HEAD did not move during that rebuild. The request trace is the difference.On the pre-patch policy that affirmative missing-model error rotated to the second profile before fallback. On this head it does not.