Skip to content

fix: explain route and account mismatches instead of asking to sign in again - #206797

Merged
obviyus merged 1 commit into
mainfrom
bugloop-206727
Nov 27, 2026
Merged

obviyus merged 1 commit into
mainfrom
bugloop-206727

Conversation

@obviyus

@obviyus obviyus commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

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.

… 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
@clawsweeper

clawsweeper Bot commented Nov 27, 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.

@obviyus

obviyus commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator Author

Proof (#206727): built Gateway (pnpm build) in a secretless node:24.22.1 container; one inbound Signal DM through a signal-cli JSON-RPC stand-in; local Responses API stand-in; synthetic auth profiles only. Base 7d93619b4132 (origin/main), candidate d90d896b9d3a.

#206727 proof: built Gateway in secretless node:24.22.1 Docker, Signal channel stand-in (signal-cli JSON-RPC stub), local Responses API stand-in, synthetic auth profiles only.
base=7d93619b413259d82898179d7acfa76b984fa8bd (origin/main) cand=d90d896b9d3a59e564e40dbec2e7a8d97f0d04d5

== base-compatible-20261127-203321/
   label=base scenario=compatible version=OpenClaw 2026.11.10 node=v24.22.1 config=/w/state/openclaw.json state=/w/state profile=openai:p206727-platform(api_key)
   stored api_key profile openai:p206727-platform
   signal replies (1):
     > P206727 compatible route reply
   provider requests: 1

== base-invalid-20261127-203226/
   label=base scenario=invalid version=OpenClaw 2026.11.10 node=v24.22.1 config=/w/state/openclaw.json state=/w/state profile=openai:p206727-platform(api_key)
   stored api_key profile openai:p206727-platform
   signal replies (1):
     > ⚠️ Couldn't sign in to the AI service. Sign in again under Models in the OpenClaw app or run openclaw configure.
   provider requests: 1
   2026-11-27T15:03:11.670+00:00 [agent/embedded] embedded run failover decision: runId=<id> stage=assistant decision=surface_error reason=auth attempt=1 retry=0 rotations=0 from=openai/gpt-p206727 profile=sha256:e7470fa4a073
   2026-11-27T15:03:11.677+00:00 [model-fallback/decision] model fallback decision: decision=candidate_failed requested=openai/gpt-p206727 candidate=openai/gpt-p206727 reason=auth next=none

== base-mismatch1-20261127-203111/
   label=base scenario=mismatch version=OpenClaw 2026.11.10 node=v24.22.1 config=/w/state/openclaw.json state=/w/state profile=openai:p206727-subscription(oauth)
   stored oauth profile openai:p206727-subscription
   signal replies (1):
     > ⚠️ Couldn't sign in to the AI service. Sign in again under Models in the OpenClaw app or run openclaw configure.
   provider requests: 0
   2026-11-27T15:01:38.769+00:00 [diagnostic] lane task error: lane=main durationMs=28 error="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." errorName=Error taskKind=tu
   2026-11-27T15:01:38.786+00:00 [model-fallback/decision] model fallback decision: decision=candidate_failed requested=openai/gpt-p206727 candidate=openai/gpt-p206727 reason=auth next=none

== base-mismatch2-20261127-203151/
   label=base scenario=mismatch version=OpenClaw 2026.11.10 node=v24.22.1 config=/w/state/openclaw.json state=/w/state profile=openai:p206727-subscription(oauth)
   stored oauth profile openai:p206727-subscription
   signal replies (1):
     > ⚠️ Couldn't sign in to the AI service. Sign in again under Models in the OpenClaw app or run openclaw configure.
   provider requests: 0
   2026-11-27T15:02:19.349+00:00 [diagnostic] lane task error: lane=main durationMs=30 error="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." errorName=Error taskKind=tu
   2026-11-27T15:02:19.364+00:00 [model-fallback/decision] model fallback decision: decision=candidate_failed requested=openai/gpt-p206727 candidate=openai/gpt-p206727 reason=auth next=none

== cand-compatible-20261127-204556/
   label=cand scenario=compatible version=OpenClaw 2026.11.10 node=v24.22.1 config=/w/state/openclaw.json state=/w/state profile=openai:p206727-platform(api_key)
   stored api_key profile openai:p206727-platform
   signal replies (1):
     > P206727 compatible route reply
   provider requests: 1

== cand-invalid-20261127-204524/
   label=cand scenario=invalid version=OpenClaw 2026.11.10 node=v24.22.1 config=/w/state/openclaw.json state=/w/state profile=openai:p206727-platform(api_key)
   stored api_key profile openai:p206727-platform
   signal replies (1):
     > ⚠️ Couldn't sign in to the AI service. Sign in again under Models in the OpenClaw app or run openclaw configure.
   provider requests: 1
   2026-11-27T15:15:49.598+00:00 [agent/embedded] embedded run failover decision: runId=<id> stage=assistant decision=surface_error reason=auth attempt=1 retry=0 rotations=0 from=openai/gpt-p206727 profile=sha256:e7470fa4a073
   2026-11-27T15:15:49.605+00:00 [model-fallback/decision] model fallback decision: decision=candidate_failed requested=openai/gpt-p206727 candidate=openai/gpt-p206727 reason=auth next=none

== cand-mismatch1-20261127-204421/
   label=cand scenario=mismatch version=OpenClaw 2026.11.10 node=v24.22.1 config=/w/state/openclaw.json state=/w/state profile=openai:p206727-subscription(oauth)
   stored oauth profile openai:p206727-subscription
   signal replies (1):
     > 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.
   provider requests: 0
   2026-11-27T15:14:48.404+00:00 [model-fallback/decision] model fallback decision: decision=candidate_failed requested=openai/gpt-p206727 candidate=openai/gpt-p206727 reason=auth next=none

== cand-mismatch2-20261127-204454/
   label=cand scenario=mismatch version=OpenClaw 2026.11.10 node=v24.22.1 config=/w/state/openclaw.json state=/w/state profile=openai:p206727-subscription(oauth)
   stored oauth profile openai:p206727-subscription
   signal replies (1):
     > 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.
   provider requests: 0
   2026-11-27T15:15:18.489+00:00 [model-fallback/decision] model fallback decision: decision=candidate_failed requested=openai/gpt-p206727 candidate=openai/gpt-p206727 reason=auth next=none

== red-on-base unit (candidate test vs base source, Docker base volume):
   �[41m�[1m FAIL �[22m�[49m �[30m�[45m agents-support �[49m�[39m src/agents/runtime-plan/prepare-auth.test.ts�[2m > �[22mexplains incompatible Codex auth for observed route (explicit order=true)
   �[41m�[1m FAIL �[22m�[49m �[30m�[45m agents-support �[49m�[39m src/agents/runtime-plan/prepare-auth.test.ts�[2m > �[22mexplains incompatible Codex auth for authored route (explicit order=true)
   �[2m      Tests �[22m �[1m�[31m4 failed�[39m�[22m�[2m | �[22m�[33m36 skipped�[39m�[90m (40)�[39m

@github-actions

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: d90d896b9d3a59e564e40dbec2e7a8d97f0d04d5
  • Maintainer: @obviyus
  • Repository role: admin

These security sensitive changes were made:

  • src/agents/runtime-plan/prepare-auth.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.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. impact:ux-friction User-facing flow adds avoidable confusion or support burden without fully blocking progress. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 27, 2026
@obviyus
obviyus merged commit 6a6431b into main Nov 27, 2026
136 of 137 checks passed
@obviyus
obviyus deleted the bugloop-206727 branch November 27, 2026 16:14
@obviyus

obviyus commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator Author

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.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 28, 2026
…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]>
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
…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]>
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. impact:ux-friction User-facing flow adds avoidable confusion or support burden without fully blocking progress. P2 Normal backlog priority with limited blast radius. security-sensitive-changed size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Model-route auth mismatch is rendered as a failed sign-in, hiding the correct recovery guidance

1 participant