Repository navigation
fix: explain route and account mismatches instead of asking to sign in again - #206797
Conversation
… advice Model-route credential mismatches left prepare-auth as plain Errors. Their explanatory text contains "authentication", so failover classified them as a generic auth failure and chat replies told the user to sign in again. Carry the selector's existing credential-safe diagnostic as the FailoverError userMessage, keeping reason auth and status 401 so failover policy is unchanged. Required-profile text names the profile and stays diagnostic only. Fixes #206727
|
🦞👀 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. |
|
Proof (#206727): built Gateway ( |
|
|
Landed in 6a6431b. When the selected model route needs a different kind of account than the one configured (for example an API-key route with only a subscription sign-in), the chat now shows the existing explanation of the mismatch and how to fix it, instead of "Couldn't sign in to the AI service". A real rejected credential still shows the sign-in message. Thanks @alexph-dev for the careful report and the production timeline in #206727. Why that turn picked an API-key route is a separate question and is not changed here. |
…n again (openclaw#206797) Root cause: src/agents/runtime-plan/prepare-auth.ts:610 turned the route selector's credential-class rejection into a plain `Error`, so its explanatory text ("...requires api-key authentication...") was classified by the generic `authentication` pattern and rendered as "Couldn't sign in to the AI service". Fixes openclaw#206727 ## What Problem This Solves When the selected model route needs a different kind of credential than the configured account (for example an API-key route with only a ChatGPT subscription sign-in), OpenClaw already knows exactly what is wrong and writes a clear, credential-safe explanation. Chat users never saw it: they got "Couldn't sign in to the AI service. Sign in again...", and signing in again with the same subscription cannot fix a route/credential mismatch. Thanks @alexph-dev for the detailed report, production timeline and installed-bundle fixture. ## User Impact A chat reply for this failure now shows the selector's existing guidance, for example: > Explicit auth order for openai has no usable profiles. Selected model route requires api-key authentication (openai-responses); configured profiles support subscription authentication. Select a model route compatible with the configured account, or select a compatible account. Real sign-in failures (rejected or expired credentials) keep the sign-in advice. No new wording: the text is the diagnostic added in openclaw#197737. ## Why This Change Was Made `prepare-auth` now throws the incompatibility as a `FailoverError` carrying that diagnostic as `userMessage`, the field chat replies already show for owner-authored copy and that the exhausted-fallback wrapper already forwards. The failover facts stay exactly as before (`reason=auth`, status 401, same provider/model), so fallback, retries and route or credential selection are unchanged. The `required-profile` rejection names the profile id, which chat replies only show in direct chats, so it stays diagnostic-only as before. History: the sign-in copy (openclaw#163381) and the `authentication` text pattern predate this diagnostic. openclaw#197737 added the explanatory suffix; its word "authentication" made the classifier map the previously unclassified message to `auth`. Nothing deliberately folded route mismatches into sign-in advice. Out of scope: why the reporter's native-Codex turn picked a Platform route in the first place (not isolated in the report; related openclaw#162811, openclaw#185064). ## Evidence Built Gateway (`pnpm build`) in a secretless `node:24.22.1` container, one inbound Signal DM through a signal-cli stand-in, local Responses API stand-in, synthetic profiles only. Proof comment: openclaw#206797 (comment) | scenario | base 5d9c855 | this PR | |---|---|---| | subscription OAuth profile, explicit order, model on api-key route (run 1) |⚠️ Couldn't sign in to the AI service... | Explicit auth order for openai has no usable profiles. Selected model route requires api-key authentication... | | same (run 2) |⚠️ Couldn't sign in to the AI service... | same diagnostic | | control: API key rejected by provider (401 invalid_api_key) |⚠️ Couldn't sign in to the AI service... |⚠️ Couldn't sign in to the AI service... | | control: compatible API-key profile on the same route | model reply | model reply | Fallback decision log is `reason=auth next=none` on both sides. Regression: `prepare-auth.test.ts` "explains incompatible Codex auth" now asserts the typed failure; it fails on base (4 cases) and passes here. Delta: the console `lane task error` line for this case is now quiet, as for every other `FailoverError` fallback candidate; the user sees the text directly. Merge danger: two-way door. No stored state, config or contract change; a revert restores the previous reply text. Blast radius: chat replies for route/credential-class mismatches in OpenAI route auth preparation. Co-authored-by: Ayaan Zaidi <[email protected]>
…n again (#206797) Root cause: src/agents/runtime-plan/prepare-auth.ts:610 turned the route selector's credential-class rejection into a plain `Error`, so its explanatory text ("...requires api-key authentication...") was classified by the generic `authentication` pattern and rendered as "Couldn't sign in to the AI service". Fixes #206727 ## What Problem This Solves When the selected model route needs a different kind of credential than the configured account (for example an API-key route with only a ChatGPT subscription sign-in), OpenClaw already knows exactly what is wrong and writes a clear, credential-safe explanation. Chat users never saw it: they got "Couldn't sign in to the AI service. Sign in again...", and signing in again with the same subscription cannot fix a route/credential mismatch. Thanks @alexph-dev for the detailed report, production timeline and installed-bundle fixture. ## User Impact A chat reply for this failure now shows the selector's existing guidance, for example: > Explicit auth order for openai has no usable profiles. Selected model route requires api-key authentication (openai-responses); configured profiles support subscription authentication. Select a model route compatible with the configured account, or select a compatible account. Real sign-in failures (rejected or expired credentials) keep the sign-in advice. No new wording: the text is the diagnostic added in #197737. ## Why This Change Was Made `prepare-auth` now throws the incompatibility as a `FailoverError` carrying that diagnostic as `userMessage`, the field chat replies already show for owner-authored copy and that the exhausted-fallback wrapper already forwards. The failover facts stay exactly as before (`reason=auth`, status 401, same provider/model), so fallback, retries and route or credential selection are unchanged. The `required-profile` rejection names the profile id, which chat replies only show in direct chats, so it stays diagnostic-only as before. History: the sign-in copy (#163381) and the `authentication` text pattern predate this diagnostic. #197737 added the explanatory suffix; its word "authentication" made the classifier map the previously unclassified message to `auth`. Nothing deliberately folded route mismatches into sign-in advice. Out of scope: why the reporter's native-Codex turn picked a Platform route in the first place (not isolated in the report; related #162811, #185064). ## Evidence Built Gateway (`pnpm build`) in a secretless `node:24.22.1` container, one inbound Signal DM through a signal-cli stand-in, local Responses API stand-in, synthetic profiles only. Proof comment: #206797 (comment) | scenario | base 7d93619 | this PR | |---|---|---| | subscription OAuth profile, explicit order, model on api-key route (run 1) |⚠️ Couldn't sign in to the AI service... | Explicit auth order for openai has no usable profiles. Selected model route requires api-key authentication... | | same (run 2) |⚠️ Couldn't sign in to the AI service... | same diagnostic | | control: API key rejected by provider (401 invalid_api_key) |⚠️ Couldn't sign in to the AI service... |⚠️ Couldn't sign in to the AI service... | | control: compatible API-key profile on the same route | model reply | model reply | Fallback decision log is `reason=auth next=none` on both sides. Regression: `prepare-auth.test.ts` "explains incompatible Codex auth" now asserts the typed failure; it fails on base (4 cases) and passes here. Delta: the console `lane task error` line for this case is now quiet, as for every other `FailoverError` fallback candidate; the user sees the text directly. Merge danger: two-way door. No stored state, config or contract change; a revert restores the previous reply text. Blast radius: chat replies for route/credential-class mismatches in OpenAI route auth preparation. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 6a6431b) Companion audit: 86ca412 concerns saved quota-reset guidance for a route skipped at admission and is separate from account mismatch. Release adaptation: Stable FailoverError does not carry arbitrary userMessage: use its existing code and fixed reply-copy contract for non-required-profile route/account mismatches, preserving the detailed local diagnostic and auth classification. No credential or Codex behavior changed. Co-authored-by: RomneyDa <[email protected]>
…n again (#206797) Root cause: src/agents/runtime-plan/prepare-auth.ts:610 turned the route selector's credential-class rejection into a plain `Error`, so its explanatory text ("...requires api-key authentication...") was classified by the generic `authentication` pattern and rendered as "Couldn't sign in to the AI service". Fixes #206727 ## What Problem This Solves When the selected model route needs a different kind of credential than the configured account (for example an API-key route with only a ChatGPT subscription sign-in), OpenClaw already knows exactly what is wrong and writes a clear, credential-safe explanation. Chat users never saw it: they got "Couldn't sign in to the AI service. Sign in again...", and signing in again with the same subscription cannot fix a route/credential mismatch. Thanks @alexph-dev for the detailed report, production timeline and installed-bundle fixture. ## User Impact A chat reply for this failure now shows the selector's existing guidance, for example: > Explicit auth order for openai has no usable profiles. Selected model route requires api-key authentication (openai-responses); configured profiles support subscription authentication. Select a model route compatible with the configured account, or select a compatible account. Real sign-in failures (rejected or expired credentials) keep the sign-in advice. No new wording: the text is the diagnostic added in #197737. ## Why This Change Was Made `prepare-auth` now throws the incompatibility as a `FailoverError` carrying that diagnostic as `userMessage`, the field chat replies already show for owner-authored copy and that the exhausted-fallback wrapper already forwards. The failover facts stay exactly as before (`reason=auth`, status 401, same provider/model), so fallback, retries and route or credential selection are unchanged. The `required-profile` rejection names the profile id, which chat replies only show in direct chats, so it stays diagnostic-only as before. History: the sign-in copy (#163381) and the `authentication` text pattern predate this diagnostic. #197737 added the explanatory suffix; its word "authentication" made the classifier map the previously unclassified message to `auth`. Nothing deliberately folded route mismatches into sign-in advice. Out of scope: why the reporter's native-Codex turn picked a Platform route in the first place (not isolated in the report; related #162811, #185064). ## Evidence Built Gateway (`pnpm build`) in a secretless `node:24.22.1` container, one inbound Signal DM through a signal-cli stand-in, local Responses API stand-in, synthetic profiles only. Proof comment: #206797 (comment) | scenario | base 7d93619 | this PR | |---|---|---| | subscription OAuth profile, explicit order, model on api-key route (run 1) |⚠️ Couldn't sign in to the AI service... | Explicit auth order for openai has no usable profiles. Selected model route requires api-key authentication... | | same (run 2) |⚠️ Couldn't sign in to the AI service... | same diagnostic | | control: API key rejected by provider (401 invalid_api_key) |⚠️ Couldn't sign in to the AI service... |⚠️ Couldn't sign in to the AI service... | | control: compatible API-key profile on the same route | model reply | model reply | Fallback decision log is `reason=auth next=none` on both sides. Regression: `prepare-auth.test.ts` "explains incompatible Codex auth" now asserts the typed failure; it fails on base (4 cases) and passes here. Delta: the console `lane task error` line for this case is now quiet, as for every other `FailoverError` fallback candidate; the user sees the text directly. Merge danger: two-way door. No stored state, config or contract change; a revert restores the previous reply text. Blast radius: chat replies for route/credential-class mismatches in OpenAI route auth preparation. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 6a6431b) Release adaptation: Use the existing structured failover code and fixed public-copy renderer, preserving fallback without importing the main-only plugin-authored error feature or exposing diagnostic profile details. Co-authored-by: RomneyDa <[email protected]>
Root cause: src/agents/runtime-plan/prepare-auth.ts:610 turned the route selector's credential-class rejection into a plain
Error, so its explanatory text ("...requires api-key authentication...") was classified by the genericauthenticationpattern and rendered as "Couldn't sign in to the AI service".Fixes #206727
What Problem This Solves
When the selected model route needs a different kind of credential than the configured account (for example an API-key route with only a ChatGPT subscription sign-in), OpenClaw already knows exactly what is wrong and writes a clear, credential-safe explanation. Chat users never saw it: they got "Couldn't sign in to the AI service. Sign in again...", and signing in again with the same subscription cannot fix a route/credential mismatch. Thanks @alexph-dev for the detailed report, production timeline and installed-bundle fixture.
User Impact
A chat reply for this failure now shows the selector's existing guidance, for example:
Real sign-in failures (rejected or expired credentials) keep the sign-in advice. No new wording: the text is the diagnostic added in #197737.
Why This Change Was Made
prepare-authnow throws the incompatibility as aFailoverErrorcarrying that diagnostic asuserMessage, the field chat replies already show for owner-authored copy and that the exhausted-fallback wrapper already forwards. The failover facts stay exactly as before (reason=auth, status 401, same provider/model), so fallback, retries and route or credential selection are unchanged. Therequired-profilerejection names the profile id, which chat replies only show in direct chats, so it stays diagnostic-only as before.History: the sign-in copy (#163381) and the
authenticationtext pattern predate this diagnostic. #197737 added the explanatory suffix; its word "authentication" made the classifier map the previously unclassified message toauth. Nothing deliberately folded route mismatches into sign-in advice.Out of scope: why the reporter's native-Codex turn picked a Platform route in the first place (not isolated in the report; related #162811, #185064).
Evidence
Built Gateway (
pnpm build) in a secretlessnode:24.22.1container, one inbound Signal DM through a signal-cli stand-in, local Responses API stand-in, synthetic profiles only. Proof comment: #206797 (comment)Fallback decision log is
reason=auth next=noneon both sides. Regression:prepare-auth.test.ts"explains incompatible Codex auth" now asserts the typed failure; it fails on base (4 cases) and passes here.Delta: the console
lane task errorline for this case is now quiet, as for every otherFailoverErrorfallback candidate; the user sees the text directly.Merge danger: two-way door. No stored state, config or contract change; a revert restores the previous reply text. Blast radius: chat replies for route/credential-class mismatches in OpenAI route auth preparation.