Skip to content

fix(auth): classify and explain model-route credential mismatches - #197737

Merged
tideclaw-bot merged 1 commit into
openclaw:mainfrom
DanCanadian:fix/185064-route-auth-diagnostics
Nov 20, 2026
Merged

tideclaw-bot merged 1 commit into
openclaw:mainfrom
DanCanadian:fix/185064-route-auth-diagnostics

Conversation

@DanCanadian

@DanCanadian DanCanadian commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Related: #185064

What Problem This Solves

Configured credentials can be rejected with a generic authentication error, while the availability check can misclassify profiles whose inference requirements differ from their stored credential type. For example, token-sharing OAuth serves an API-key route, but the incompatibility check previously treated it as subscription-only OAuth.

User Impact

Route-mismatch errors explain the required authentication class and API adapter, and the class supported by the configured profiles. Model availability correctly distinguishes an incompatible credential contract from a compatible account that is temporarily unavailable; identity-only sign-ins remain explicitly denied inference.

This addresses a bounded classification/diagnostic problem found while investigating #185064. Successful Terra execution on an unmodified current-main Gateway remains unverified, and this PR does not close that issue.

Why This Change Was Made

Use each profile's existing authRequirement when classifying route incompatibility, matching the actual selector. Treat null as an explicit inference denial. Reuse that classification to append a bounded explanation only when all configured profiles have known incompatible requirements. A configured route remains authoritative in the explanation.

The new suffix contains auth categories and API adapter names. It adds no credential values, profile identifiers or endpoint URLs. Physical route selection, profile ordering and native account ownership retain their existing algorithms; the corrected availability classification is intentionally consumed by model admission and Doctor. Native catalog transport metadata and static model lists are unchanged.

Evidence

Regression assertions were run against base b48d16bf6e98f0b9c1e110548fc46b3b35f2becd before applying the production fix: 4 expected selector failures, 3 availability-consumer failures, and 4 runtime auth-preparation failures. The same assertions pass with the fix.

Focused suite Final result
Provider model route auth 30/30
Model auth availability: existing session/account pins 49/49
Model auth availability: native accounts 17/17
Runtime auth preparation 40/40
Total 136/136

Scoped lint, formatting, git diff --check, the production core typecheck, and both relevant test typecheck leaves pass. The runtime tests exercise observed/authored Platform routes with automatic/explicit profile order, exact credential-safe errors, and successful selected-OAuth forwarding on the subscription route.

Self pr-simplify and an independent code review completed with no remaining actionable findings. The reviewed, tested, and published file contents match.

Validation environment: Node 24.22.1, pnpm 11.25.0, Vitest 5.0.5. Used the documented Node runner and serial projects after a parallel cold worker startup exited 137 before any tests; that setup failure is not counted as defect evidence. Lockfile unchanged.

Focused validation commands
OPENCLAW_VITEST_RUNTIME=node OPENCLAW_TEST_PROJECTS_SERIAL=1 pnpm test \
  src/agents/provider-model-route-auth.test.ts \
  src/agents/runtime-plan/prepare-auth.test.ts \
  src/agents/model-auth-availability.native.test.ts \
  src/agents/model-auth-availability.session-pin.test.ts \
  --maxWorkers=1

OPENCLAW_LINT_TOOL=oxlint node scripts/run-oxlint.mjs \
  --tsconfig config/tsconfig/oxlint.core.json \
  src/agents/provider-model-route-auth.ts \
  src/agents/provider-model-route-auth.test.ts \
  src/agents/runtime-plan/prepare-auth.test.ts \
  src/agents/model-auth-availability.native.test.ts

OPENCLAW_FORMAT_TOOL=oxfmt pnpm format:check \
  src/agents/provider-model-route-auth.ts \
  src/agents/provider-model-route-auth.test.ts \
  src/agents/runtime-plan/prepare-auth.test.ts \
  src/agents/model-auth-availability.native.test.ts

git diff --check
node scripts/run-tsgo.mjs -p tsconfig.core.json --incremental
node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.agents-root.json --incremental
node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.agents-other.json --incremental

Implementation and review were AI-assisted. Regression inputs are synthetic; these tests perform no provider inference or account sign-in. Upstream main CI, CodeQL security, and Critical Quality all succeeded on head 3321155e3853b5f87a26e207ad468e165ced9c8c.

The current-head security notice requires an upstream maintainer to review and post /allow-security-sensitive-change before merge. The aggregate merge gate is blocked on that approval, not on a test failure. Maintainer review remains pending.

Runtime behavior proof — November 12

Added the running CLI/Gateway evidence requested in the ClawSweeper review, at unchanged source and build commit 3321155e3853b5f87a26e207ad468e165ced9c8c.

The normal pnpm openclaw --help source build completed; the CLI reports OpenClaw 2026.11.3 and dist/build-info.json identifies the full commit above. These runs use the actual CLI, a running Gateway, the real bundled OpenAI provider, and the canonical SQLite credential writer. No provider-policy, selector, availability, authentication-preparation, or Gateway-dispatch functions were mocked.

Each case has separate disposable OPENCLAW_HOME, OPENCLAW_STATE_DIR, OPENCLAW_CONFIG_PATH, and workspace paths. Provider credentials were excluded from the inherited environment. The sole account in each case is synthetic, persisted with the packaged upsertAuthProfileWithLockOrThrow SDK function; models auth list verifies the stored OAuth account. plugins list --json reports the bundled OpenAI plugin as enabled and loaded. The fixtures use an authored openai/gpt-5.5 row, the OpenClaw runtime, and unpinned model selection.

Case Actual runtime result Meaning
Ordinary, unexpired OAuth; authored openai-responses route Local agent CLI exits 1 with the complete new mismatch diagnostic below. The user-visible error identifies the incompatible authentication classes.
chatgpt-token-sharing; expired at 1, no refresh token; canonical https://api.openai.com/v1 + openai-responses models list reports available: false; Gateway spawn returns accepted, modelApplied: true; agent.wait then reports the same run's ordinary auth failure. Compatible credential class with unavailable credentials passes model-choice preflight, while the later execution authentication boundary still refuses the run.
Unexpired chatgpt-identity; authored openai-chatgpt-responses route Gateway spawn returns a tool-level model-preflight error, with no accepted run ID. Identity-only authentication remains authoritatively denied on the subscription route.

The public Responses endpoint in the token-sharing case is intentional: OpenAI's actual token-sharing policy requires that canonical endpoint. An earlier loopback setup mixed endpoint incompatibility with expiry and is excluded from the evidence.

Actual commands and captured output

All setup/readback commands returned exit 0:

pnpm openclaw config validate --json
pnpm openclaw models auth list --provider openai --agent main --json
pnpm openclaw plugins list --json
pnpm openclaw models list --all --provider openai --json

The account fixtures are written through the packaged canonical API, with explicit disposable state and agent directories:

import { upsertAuthProfileWithLockOrThrow } from
  "./dist/plugin-sdk/provider-auth-api-key.js";

await upsertAuthProfileWithLockOrThrow({
  stateDir,
  agentDir,
  profileId: "openai:fixture",
  credential
});

Each credential uses OAuth storage, provider openai, and a synthetic access value. The ordinary and identity-only fixtures have future expiry; the latter specifies authFlow: "chatgpt-identity". The compatible-unavailable fixture specifies authFlow: "chatgpt-token-sharing", expires: 1, and an empty refresh field, which the canonical store normalizes away.

1. Actual local agent CLI — mismatch

pnpm openclaw agent --local --agent main \
  --message "Proof only; no inference should start." --json

Exit 1. Captured JSON:

{
  "ok": false,
  "error": {
    "type": "cli_error",
    "message": "No route-compatible authentication source is configured for openai. 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."
  }
}

2–3. Actual Gateway model-choice consumer

The disposable Gateway config explicitly includes the documented gateway.tools.allow: ["sessions_spawn"] exposure setting. Both cases run a real pnpm openclaw gateway run process and wait for its ready log.

pnpm openclaw gateway call tools.invoke \
  --params '{"name":"sessions_spawn","agentId":"main","args":{"task":"Proof only; no inference should start.","model":"openai/gpt-5.5","runtime":"subagent","context":"isolated","mode":"run","runTimeoutSeconds":10,"expectsCompletionMessage":false}}' \
  --json --timeout 20000

The RPC exits 0 in both cases. The significant result is the nested output.details, not merely the RPC envelope's ok: true.

Compatible but unavailable token-sharing profile, selected fields from the actual output.details:

{
  "status": "accepted",
  "runId": "<proof-run>",
  "resolvedModel": "openai/gpt-5.5",
  "resolvedProvider": "openai",
  "modelApplied": true
}

Then the public wait RPC, using that same returned run ID:

pnpm openclaw gateway call agent.wait \
  --params '{"runId":"<proof-run>","timeoutMs":15000}' \
  --json --timeout 20000

Exit 0; selected fields from the actual terminal result:

{
  "runId": "<proof-run>",
  "status": "error",
  "error": "No route-compatible authentication source is configured for openai."
}

The Gateway log independently records that same run's authentication failure. The run ID is redacted consistently above; matching of the original receipts was verified. This is observed terminal failure, not an assumption based on spawn acceptance.

Identity-only profile on the subscription route, actual output.details:

{
  "status": "error",
  "error": "sessions_spawn model \"openai/gpt-5.5\" is not usable: The selected account or native runtime is unavailable for openai/gpt-5.5. Restore that account before spawning this model."
}

No accepted child run ID was returned in the identity-only case.

Cleanup and scope

The two Gateway logs confirm intentional shutdown and clean completion (146 ms for canonical token sharing; 118 ms for identity-only). After shutdown, both Gateway ports were closed and the actual offline models auth list command succeeded, confirming release of state ownership. The pnpm wrapper's -15 status records the fixture owner's intentional SIGTERM cleanup.

The mismatch and identity-only cases use loopback sentinel endpoints, each recording zero requests. The canonical public endpoint in the compatible-unavailable case was not instrumented; its receipt demonstrates authentication-preparation failure and makes no measured zero-outbound-traffic claim. No valid account credential or successful inference is claimed.

These are real CLI/Gateway executions with controlled fixture inputs. The runtime captures are for the PR head only; the baseline comparison remains the red/green regression evidence above. They do not establish native Codex/Terra inference or resolve #185064.

The final captures and setup were independently reviewed, including the canonical token-sharing endpoint requirement. Repository source remains clean and unchanged. The second ClawSweeper review, completed November 12 at 9:48 a.m. ET, accepted this terminal proof as sufficient and reported no findings. GitHub now labels the PR proof: sufficient and status: ⏳ waiting on maintainer. The remaining before-merge requirement is upstream maintainer approval of the authentication change for this exact head.

Honor provider-declared auth requirements when deciding whether profiles are
incompatible with a model route. Preserve explicit identity-only inference
denials and distinguish unavailable compatible accounts from wrong-route
authentication.

Explain rejected route/account class combinations without exposing account
identifiers or credentials. Add focused selector, availability, and runtime
auth preparation regressions.

Related: openclaw#185064
@clawsweeper

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

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

✅ Maintainer security changes approved

A maintainer approved this revision with an explicit security approval comment.

A later push requires a fresh approval comment for an external contributor's PR.

@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. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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-repro Preliminary submission classification; full source review pending. labels Nov 12, 2026
@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

Classify credential compatibility using provider-declared requirements and explain known model-route authentication mismatches.

Example: A ChatGPT OAuth account is selected for an openai-responses API-key route.

  • Before: Authentication fails with a generic no-compatible-source error.
  • After: The error names api-key versus subscription authentication, identifies openai-responses, and suggests choosing a compatible route or account.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused repair is correct and demonstrated through shipped entry points; overall scope remains partial relative to the linked execution issue.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The unchanged-head CLI/Gateway captures exercise the real bundled provider and canonical credential store with isolated synthetic accounts: mismatch guidance appears, expired compatible token sharing passes model admission but fails execution authentication, and identity-only credentials fail preflight; this addresses the previous review's proof request.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Partial
User problem: Accounts can receive an incorrect authoritative incompatibility classification or an authentication error that does not explain the route/account mismatch.
Reason: Restoring provider-declared credential semantics has clear value; Related linkage appropriately leaves #185064 open.

Merge readiness

⛔ Blocked before merge - 1 item remains

This PR repairs a current auth-classification inconsistency without actionable correctness findings; the broader linked execution problem remains unresolved.

Priority: P2
Reviewed head: 3321155e3853b5f87a26e207ad468e165ced9c8c

Before merge

Findings

None.

Agent review details

How this fits together

Provider policy supplies credential requirements to the shared route/auth selector, whose decisions feed runtime preparation, model availability, admission, and Doctor.

flowchart TD
  A[Provider credential policy] --> C[Route and auth selector]
  B[Profiles and model routes] --> C
  C --> D[Runtime preparation and diagnostics]
  C --> E[Model availability]
  E --> F[Model admission and Doctor]
Loading

Technical review

Best possible solution:

Keep compatibility classification and actionable mismatch guidance in the existing selector while preserving credential selection and inference denials.

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

Current-main source establishes the mismatch between storage-mode classification and provider-declared requirements; the author reports base-failing and head-passing regressions, which were inspected but not executed during this read-only review.

Is this the best way to solve the issue?

The patch restores the existing provider contract at its shared owner, and its reused diagnostic helper covers three rejection paths without adding state or a competing selector.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Orion: Raw commit 62580c1 adds src/agents/provider-model-route-auth.ts:346 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 62580c13d1ff; files: src/agents/provider-model-route-auth.ts)

PR surface

Source +28, Tests +98. Total +126 across 4 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 36 8 +28
Tests 3 98 0 +98
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 134 8 +126

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:

No label changes.

Label justifications:

  • P2: A bounded classification and diagnostic defect affects model admission and recovery decisions without evidence of a widespread urgent outage.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: ⏳ waiting on maintainer: Only explicit maintainer approvals or decisions remain; merge is still blocked.
  • 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 (1 earlier review cycle)
  • reviewed 2026-11-12T13:15:52.637Z sha 3321155 :: needs real behavior proof before merge. :: none

Reviewed November 12, 2026, 9:48 AM ET / 14:48 UTC (Revision 2).

Copy link
Copy Markdown
Contributor Author

Added the requested real CLI/Gateway behavior evidence to the PR description at unchanged head 3321155e3853b5f87a26e207ad468e165ced9c8c.

The captures show the actual local CLI mismatch error, unpinned Gateway spawn admission for an expired token-sharing account on the canonical public Responses route followed by the same run's ordinary authentication failure, and identity-only denial during subscription-route model preflight. They use the actual bundled OpenAI provider and canonical credential store, with synthetic profiles and no mocked policy/dispatch functions.

Commands, redacted output, setup, cleanup, and the network-observation limits are in the PR body. The source and prior successful CI head are unchanged; #185064 remains open.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

Maintainer security review requested for head 3321155e3853b5f87a26e207ad468e165ced9c8c.

The second ClawSweeper review accepted the real CLI/Gateway evidence and reported no actionable findings. Main CI, CodeQL security, and Critical Quality passed on this unchanged head; the PR body contains the receipts and runtime captures.

The change honors provider-declared authentication requirements in the existing compatibility selector and improves mismatch diagnostics. Identity-only inference denial and account selection are preserved. This remains a bounded contribution related to #185064, which stays open.

Could an upstream maintainer review this revision and provide the approval required by the current-head security notice, if satisfied? Maintainer edits are enabled. Thank you.

@tideclaw-bot

Copy link
Copy Markdown
Collaborator

/allow-security-sensitive-change

@tideclaw-bot
tideclaw-bot enabled auto-merge (squash) November 20, 2026 19:44
@tideclaw-bot
tideclaw-bot merged commit fe9694b into openclaw:main Nov 20, 2026
179 of 180 checks passed
tideclaw-bot pushed a commit that referenced this pull request Nov 20, 2026
Honor provider-declared credential contracts, preserving identity-only
denial and distinguishing incompatibility from temporary unreadiness.
Report credential classes without disclosing account identity or tokens.

Original regression has 7 failures; all 83 focused tests pass after repair.
Targeted types/lint/format pass.

(cherry picked from commit fe9694b)

Co-authored-by: RomneyDa <[email protected]>
Co-authored-by: vincentkoc <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 20, 2026
Backport fe9694b. Honor provider-declared authentication contracts, keep identity-only inference denial explicit, and distinguish route incompatibility from unavailable compatible credentials without exposing account identifiers.

Co-authored-by: RomneyDa <[email protected]>
Co-authored-by: vincentkoc <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 21, 2026
…enclaw#197737)

Honor provider-declared auth requirements when deciding whether profiles are
incompatible with a model route. Preserve explicit identity-only inference
denials and distinguish unavailable compatible accounts from wrong-route
authentication.

Explain rejected route/account class combinations without exposing account
identifiers or credentials. Add focused selector, availability, and runtime
auth preparation regressions.

Related: openclaw#185064
obviyus added a commit that referenced this pull request Nov 27, 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]>
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 P2 Normal backlog priority with limited blast radius. 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: S status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: GPT-6.1 Terra available in native Codex catalog but fails route/auth preparation while Astra works

2 participants