Repository navigation
fix(anthropic): Claude models fail with a missing API key after Claude CLI sign-in unless sign-in seeded them - #167963
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 changesClaude CLI sign-in adds a provider-wide routing rule so unseeded Claude models run through Claude Code, while model pickers preserve explicit API-account choices. Example: After Claude CLI sign-in, a user selects anthropic/claude-haiku-4-5.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR remains necessary on current main. The previous selected-account finding and upgrade-compatibility blocker are resolved, and no actionable code defect remains. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherOpenClaw uses saved model routing rules and account credentials to choose between provider APIs and local command-line applications. Prepared authentication decisions also determine model availability in UI and channel pickers. flowchart TD
A[Claude CLI sign-in] --> B[Saved model routing rules]
B --> C[Model and selected account]
C --> D[Prepared authentication decision]
D --> E[Claude CLI catalog filter]
E --> F[UI and channel model pickers]
C --> G[Provider API or Claude Code turn]
Technical reviewBest possible solution: Keep native Claude authentication authoritative and use the existing routing contract without weakening explicit account or runtime choices. Do we have a high-confidence way to reproduce the issue? Yes: current-main sign-in leaves unseeded Anthropic IDs without a CLI runtime policy or native-auth profile alias, matching the contributor's recorded missing-provider-auth Gateway failure. This read-only review did not execute target code. Is this the best way to solve the issue? Yes: adding the existing wildcard at sign-in fixes routing at its producer, and the catalog restriction now preserves availability supplied by explicit API accounts. No new configuration key or parallel execution path is introduced. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 427f926e7c2d. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +76, Tests +94, Docs 0. Total +170 across 6 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (3 earlier review cycles)
Reviewed October 9, 2026, 7:13 PM ET / 23:13 UTC (Revision 4). |
|
Maintainer decision: accepted. Users with both a Claude CLI sign-in and an Anthropic API key now run anthropic/* models that were not known at sign-in through Claude Code, matching how sign-in-seeded models already route; an exact agents.defaults.models entry can still pin a model to the API. A follow-up PR adds a Doctor migration for existing Claude CLI sign-ins and stops seeding deprecated catalog rows. |
|
The requested data-model compatibility proof is in the PR body under Evidence → "Upgrade cell": published v2026.9.9 state (Claude CLI-style agents.defaults.models, an Anthropic API-key profile, and a session pinned to that account and runtime) updated to 41f26e5; update ok, doctor and config validate clean, saved models and session selection identical after update and after two Claude CLI sign-ins (wildcard present exactly once). @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Landed in 9c241fe. After Claude CLI sign-in, any anthropic/ Claude model runs through Claude Code (sign-in writes the documented anthropic/* → claude-cli rule), and the picker only shows models the Claude CLI catalog lists unless a selected API account supplies them. Proof: real Claude Max sign-in (typed and catalog-added models run via Claude Code, API-only models stay out), API-key control, and a published 2026.9.9 upgrade with saved selections intact. |
…rlier Claude CLI sign-in (#168074) Related: #167963 ## What Problem This Solves Fixes: Claude models that Claude CLI sign-in did not add fail with "No API key found for provider anthropic" for anyone who signed in to Claude CLI on a release since native Claude CLI login (#129052), because those configs predate the `anthropic/*` runtime entry that #167963 now writes at sign-in. Sign-in also still added deprecated catalog models such as `claude-opus-4-8` to fresh configs. ## User Impact User impact: after `openclaw update` (or `openclaw doctor --fix`), an earlier Claude CLI sign-in routes every Claude model through Claude Code, the same as a fresh sign-in. Fresh sign-ins no longer add deprecated catalog models; an existing entry for one, such as `claude-opus-4-8`, is kept. Configs with an Anthropic credential, an API default model with a Claude CLI fallback, a provider-level Anthropic runtime, or an existing `anthropic/*` entry are left unchanged. ## Why This Change Was Made The Anthropic plugin now owns a Doctor config repair (`doctorContract.configRepair`). It adds `agents.defaults.models["anthropic/*"] = { agentRuntime: { id: "claude-cli" } }` only when all of these hold: - the default model is an `anthropic/...` ref whose entry pins `claude-cli` (what sign-in writes); - no `anthropic/*` entry exists, whatever runtime it names; - no `models.providers.anthropic.agentRuntime` (the wildcard would outrank it); - no Anthropic credential is visible to config repair: an `anthropic` auth profile, a provider `apiKey` other than the retired `anthropic:claude-cli` marker, or `ANTHROPIC_API_KEY`/`ANTHROPIC_OAUTH_TOKEN` in the environment or config `env`. Specific model entries keep winning over the wildcard, so entries that name a runtime are unaffected. Runtime reads only the canonical entry; there is no new compatibility reader. The change is reported as a Doctor change (`openclaw doctor` lists it, `--fix` writes it). Sign-in seeding filters catalog rows with `status: "deprecated"`. Route probing and the setup picker still see every row. ## Update Behavior The installed updater cannot be patched, so the repair keys only on config that shipped Claude CLI sign-ins already wrote. During `openclaw update`, the candidate's own Doctor runs twice: once as `doctor --fix` in the candidate rehearsal on a private state snapshot (`candidate-doctor`), then as `doctor --repair --non-interactive` in a fresh process after the package swap (`openclaw doctor`). The second run writes the repair through Doctor's normal backed-up config write (`openclaw.json.bak` ring plus `openclaw.json.pre-update`), so update rollback restores the earlier config. The update result lists the change under the Doctor migration notes. Gateway startup does not apply it to a valid config. After a manual package replacement, run `openclaw doctor --fix`. ## Evidence - Regression tests fail at the parent commit and pass here: - `extensions/anthropic/cli-migration.test.ts`: `registered cli sign-in seeds no deprecated Claude CLI catalog rows` fails at the parent (`expected { …(12) } to not have property "anthropic/claude-opus-4-8"`). Its second case shows an existing `claude-opus-4-8` default and entry survive sign-in. Three existing seeding expectations drop `claude-opus-4-8`. - `extensions/anthropic/doctor-contract-api.test.ts`: covers the repair, idempotency, both kinds of existing wildcard, an API default with a Claude CLI fallback, a non-Anthropic default, auth profile, provider API key, config env key, process env key, provider-level runtime, and the retired provider marker. At the parent the module does not exist. - Published-driver × candidate cells: Docker `bare` image, published `[email protected]` from npm, sign-in through the published `openclaw onboard --non-interactive --auth-choice anthropic-cli` with a stub `claude` that only answers `claude auth status`. Then `openclaw update --tag file:<candidate tgz> --no-restart --yes --json` to a package built by `scripts/package-openclaw-for-docker.mjs` from this head: | Cell | Config before update | `update` | `anthropic/*` after | Other model entries | Post-update `doctor` / `config validate` | | --- | --- | --- | --- | --- | --- | | A | 2026.9.9 sign-in: 11 seeded rows pinned `claude-cli`, default `anthropic/claude-opus-5-5`, no wildcard | `status: ok`, `2026.9.9 (bcfc888)` → `(587456f)`; result notes `Doctor migration: agents.defaults.models["anthropic/*"]: added the claude-cli runtime …` | `{ agentRuntime: { id: "claude-cli" } }` | unchanged (only `anthropic/*` differs); `.bak`, `.bak.1` and `.pre-update` have no wildcard | exit 0, no further Anthropic finding / `Config valid` | | B | A plus `"anthropic/*": { agentRuntime: { id: "openclaw" } }` | `status: ok` | still `openclaw` | unchanged | exit 0 / `Config valid` | | C | A plus an `anthropic:default` API-key auth profile | `status: ok` | absent | unchanged | exit 0 / `Config valid` | Replaying the candidate Doctor on a copy of cell A's pre-update config: `openclaw doctor --non-interactive` lists the `agents.defaults.models["anthropic/*"]` change and leaves the file unchanged. `openclaw doctor --fix --non-interactive` writes `{ agentRuntime: { id: "claude-cli" } }` and rotates `openclaw.json.bak`. The same replays leave cells B and C unchanged. - `pnpm exec oxlint --type-aware` on the changed files: clean. `node scripts/check-changed.mjs` passed every lane, including the doctor contract declaration and closure guard tests and the extension typechecks, except the dead-export scan. That scan flags only untouched files (`extensions/telegram/src/sequential-key.ts`, `src/auto-reply/reply/model-selection.ts`). With `OPENCLAW_CHECK_CHANGED_SKIP_DEADCODE=1` it exits 0. ## Merge Danger One-way door: `openclaw update` and `doctor --fix` write `anthropic/*` into existing configs. A revert stops new writes but does not remove entries already written; the pre-update backup still has the earlier config. Blast radius: Claude CLI users with no Anthropic credential visible to config repair. Claude IDs without a specific runtime-pinned entry move from a failing API route to Claude Code. A user whose only Anthropic API key lives in the auth store, with no config auth profile or env var, and who sets a Claude CLI-pinned default model, would also see unpinned Claude IDs move to Claude Code. That is the routing a fresh Claude CLI sign-in now produces. Co-authored-by: Ayaan Zaidi <[email protected]>
…e CLI sign-in unless sign-in seeded them (openclaw#167963) ## What Problem This Solves Fixes: after Claude CLI sign-in (`openclaw models auth login --provider anthropic --method cli`), any `anthropic/<id>` that sign-in did not seed fails with `No API key found for provider "anthropic" … missing-provider-auth`. This affects Claude models published after sign-in and IDs typed with `--model`, `/model` or `models set`, such as `anthropic/claude-haiku-4-5`. ## User Impact User impact: Claude-CLI-only users can type or pick any Claude model and it runs through Claude Code. The model picker still lists only models the Claude CLI catalog serves, so `claude-mythos-5` (direct API only) stays hidden. Users with an Anthropic API key and no Claude CLI sign-in keep the API route. Exact model entries that name another runtime still win. A session pinned to an Anthropic API-key account keeps that account's models, including `claude-mythos-5`, in its picker. Existing installs that signed in on an affected build get the new routing only after they rerun `openclaw models auth login --provider anthropic --method cli`. This PR adds no Doctor migration. User-authored `provider/*` wildcards for other CLI backends behave exactly as on `main`. For example, `google/*` → `google-gemini-cli` keeps the same picker rows, and its typed IDs run as before. The picker gate is keyed on the `anthropic/*` → `claude-cli` entry that sign-in writes. ## Why This Change Was Made Since openclaw#129052, Claude CLI sign-in persists no OpenClaw auth profile. At run time, `resolveCliRuntimeExecutionProvider` (src/agents/model-runtime-aliases.ts) found no runtime policy for unseeded IDs and no `claude-cli` profile it could alias. The turn then fell to the embedded Anthropic API path. An instrumented isolated Gateway on 35a9f60 showed `policy=undefined … viaAuthProfile=undefined` and then `useCliExecution=false`. - Sign-in (`extensions/anthropic/cli-migration.ts`) now also writes the existing, documented provider wildcard `agents.defaults.models["anthropic/*"] = { agentRuntime: { id: "claude-cli" } }`. It does not overwrite a wildcard that already names another runtime. - Catalog decisions (`src/agents/model-catalog-cli-wildcard.ts`, used by `model-catalog-decisions.ts`) mark a row unavailable, with no "sign in" reason, when all of these hold: native Claude CLI credentials supplied the availability (`evidence: "runtime"`), the row reaches `claude-cli` only through that sign-in wildcard, the Claude CLI catalog does not list it (bundled manifest plus published catalog), and it is not a configured row. Availability from a selected or pinned API account is never narrowed. Run-time routing is unchanged, so typed IDs still run. Production change: 3 lines in cli-migration.ts, 15 net lines in model-catalog-decisions.ts and a new 58-line module (about 45 code lines). No config keys, schema or SDK surface change. Provenance (f81245d, openclaw#166037): prepared catalog decisions keep saved account, model and runtime choices and their provenance. `createCliRuntimeModelAuthEvaluator` returns a pinned non-native account's own provider-auth result, and `evaluateNative` keeps host results for selected accounts. The wildcard gate now only narrows availability that came from native Claude CLI credentials, so a saved account choice keeps the models that account can use. ## Evidence Real proofs used the machine's existing native `claude` login, OpenClaw's real sign-in flow, isolated profiles and a loopback Gateway: - Before, on `main` 35a9f60: `models set anthropic/claude-haiku-4-5` plus one turn failed with `missing-provider-auth`, and the instrumentation showed no CLI route. - After, on b35cc8e: the picker lists `available` rows that exactly match the 11 Claude CLI catalog IDs. `claude-mythos-5` and `claude-haiku-4-5` are not listed. - After: a turn typed with `--model anthropic/claude-haiku-4-5` returned `OK` with `runner=cli` and `winnerProvider=claude-cli`. - After: `models set anthropic/claude-haiku-4-5` plus a turn returned `OK` through `claude-cli`. - API-key control: on a profile with `paste-api-key` (key piped on stdin) and no Claude CLI sign-in, an `anthropic/claude-haiku-4-5` turn returned `OK` with `runner=embedded` and `winnerProvider=anthropic`. Mythos stays listed for API users, as on `main`. - Regressions: - `extensions/anthropic/cli-migration.test.ts`, including the registered non-interactive sign-in entry: 4 failures without the fix, 40/40 pass with it. - `src/agents/model-catalog-decisions.test.ts`: the Claude CLI wildcard test fails without the gate (`expected true to be false`). With the gate, it covers a listed row, an API-only row (unavailable, no reason), an exact pinned row, a configured typed row, an exact override to `openclaw`, and an unchanged `google/*` → `google-gemini-cli` row even when that backend lists its own rows. - Same test, selected-account case (added on 41f26e5): with the wildcard and a session pinned to an Anthropic API-key profile, `claude-mythos-5` is available with `selectedProfileId: "anthropic:work"` in both `evaluateEntry` and `evaluateNative`. With only native Claude CLI credentials it stays unavailable. On 651801e this fails (`expected { availability: false … } to match object { availability: true … }`). With the fix, 24/24 pass in the file, and `model-auth-availability.test.ts` plus `cli-migration.test.ts` pass. - New-model simulation on 651801e, in a throwaway worktree with `claude-fable-5` removed from local knowledge: both bundled manifest rows (`anthropic`, `claude-cli`), the `fable-5` alias, the model-catalog-core alias and the Claude CLI context alias. `models.catalogRefresh.url` pointed at a loopback copy of `catalog.openclaw.ai/models/v2/catalog.json`, served at first without `anthropic/claude-fable-5` and `claude-cli/claude-fable-5`. - Before: `models.list {view:"configured", refresh:true}` (the Control UI view) returned 10 Claude rows and no Fable 5 row. - I added both rows back only in the served copy, with a newer `generatedAt`, then ran `openclaw models refresh` and `models.list {refresh:true}`. The Gateway PID did not change. The first response was unchanged because adoption starts after that response. The next read listed `claude-cli/claude-fable-5` as available, but not `anthropic/claude-fable-5`. A Gateway restart gave the same rows, so the refresh lifecycle is not the cause. - Turns: `--model anthropic/claude-fable-5` returned `OK` on the same Gateway PID with `runner=cli`, `winnerProvider=claude-cli` and `winnerModel=claude-fable-5`. `--model claude-cli/claude-fable-5`, the row the picker shows, also returned `OK` through `claude-cli`. - Gates on 41f26e5: `node scripts/check-changed.mjs` exited 0. It ran the tsgo lanes, oxlint on core and the changed extension files, the full dead-export scan, format checks, ratchets and the import-cycle check. `pnpm exec oxlint --type-aware` on the changed files exited 0. Upgrade cell (published v2026.9.9 → this PR, disposable Docker container from the `scripts/e2e/Dockerfile` `bare` stage, candidate packed with `scripts/package-openclaw-for-docker.mjs` from 41f26e5, build `2026.9.9-41f26e5206fc`). `api.anthropic.com` resolved to loopback in the container, so the fake key never left it. npm `latest` is still 2026.9.9. - Existing state was written by the published CLI. It had a Claude CLI-style `agents.defaults.models` with three `anthropic/*` IDs on `claude-cli` and no wildcard, primary `anthropic/claude-opus-5-5`, and an `anthropic:work` API-key profile from `paste-api-key` with a fake key. Through the v2026.9.9 Gateway, `sessions.create` and then `sessions.patch {model:"anthropic/claude-sonnet-5@anthropic:work"}` saved this session selection: `providerOverride=anthropic, modelOverride=claude-sonnet-5, authProfileOverride=anthropic:work (user), agentRuntimeOverride=claude-cli`. - `openclaw update --tag file:<tgz> --no-restart --yes --json` exited 0 with `status: ok` and all steps at 0. The CLI now reports `OpenClaw 2026.9.9 (41f26e5)`. The updater's doctor, `openclaw doctor --non-interactive` and `config validate` passed (`valid: true`, no warnings). Doctor warnings matched the baseline: a plaintext gateway token in the fixture, loopback bind and no service manager. The saved session selection and `agents.defaults.models` read back identical to the pre-update values. - Claude CLI sign-in again, with the real `openclaw models auth login --provider anthropic --method cli --set-default` under a pty. It needs a TTY. Without a `claude` binary it stops with `Claude CLI is not authenticated on this host`. With a stub `claude` on `PATH` that only answers `auth status --json` with `{"loggedIn":true,"authMethod":"claude.ai"}` and `--version`, and never runs a model, it exited 0. That was the only stubbed part; the sign-in, config write and Gateway are the shipped code. After the first sign-in, `"anthropic/*": {agentRuntime:{id:"claude-cli"}}` was present once. A second sign-in left it present once. The three existing entries and the primary were unchanged, the session selection was identical after each sign-in, and `config validate` and doctor passed. - Candidate Gateway with the wildcard present: `models.list {sessionKey, view:"all", provider:"anthropic"}` for the session pinned to `anthropic:work` listed `claude-mythos-5` as `available: true`. `models.list {agentId:"main"}`, with no selected account, listed it as `available: false`, which is the accepted Claude CLI-first behavior. - Not covered: no real Claude Code turn ran in the cell. Real turns are in the evidence above. The update's package swap took 23 min on a loaded host; an earlier v2026.9.9 cell on the same host took 7–11 min for the whole update. No Telegram Test Server run. Gap: a Claude model that the published catalog adds later appears in the picker without a restart, but only as `claude-cli/<id>`, not `anthropic/<id>`. `anthropic` is a `refreshable` catalog provider, so its published rows appear only when live `/v1/models` discovery returns them, and that discovery needs an API key. The `src/agents/model-catalog.ts` guard says "Only live registry or refreshed rows may publish those provider models". `claude-cli` is `static`, so its published row appears. The sign-in wildcard gate only marks existing `anthropic` rows unavailable and never adds rows, so the `claude-cli` row has no `anthropic` twin to fold into. Both refs run through Claude Code. Showing `anthropic/<id>` would need a separate change to the refreshable-provider guard in `model-catalog.ts` or to the CLI twin collapse in `model-runtime-aliases.ts`. ## Merge danger Medium-low. The run-time change is config written only by Claude CLI sign-in. The picker change sits in shared catalog decisions, but it applies only when an agent's `anthropic/*` entry names `claude-cli` and the row is neither configured nor listed by the Claude CLI catalog. Co-authored-by: Ayaan Zaidi <[email protected]>
…rlier Claude CLI sign-in (openclaw#168074) Related: openclaw#167963 ## What Problem This Solves Fixes: Claude models that Claude CLI sign-in did not add fail with "No API key found for provider anthropic" for anyone who signed in to Claude CLI on a release since native Claude CLI login (openclaw#129052), because those configs predate the `anthropic/*` runtime entry that openclaw#167963 now writes at sign-in. Sign-in also still added deprecated catalog models such as `claude-opus-4-8` to fresh configs. ## User Impact User impact: after `openclaw update` (or `openclaw doctor --fix`), an earlier Claude CLI sign-in routes every Claude model through Claude Code, the same as a fresh sign-in. Fresh sign-ins no longer add deprecated catalog models; an existing entry for one, such as `claude-opus-4-8`, is kept. Configs with an Anthropic credential, an API default model with a Claude CLI fallback, a provider-level Anthropic runtime, or an existing `anthropic/*` entry are left unchanged. ## Why This Change Was Made The Anthropic plugin now owns a Doctor config repair (`doctorContract.configRepair`). It adds `agents.defaults.models["anthropic/*"] = { agentRuntime: { id: "claude-cli" } }` only when all of these hold: - the default model is an `anthropic/...` ref whose entry pins `claude-cli` (what sign-in writes); - no `anthropic/*` entry exists, whatever runtime it names; - no `models.providers.anthropic.agentRuntime` (the wildcard would outrank it); - no Anthropic credential is visible to config repair: an `anthropic` auth profile, a provider `apiKey` other than the retired `anthropic:claude-cli` marker, or `ANTHROPIC_API_KEY`/`ANTHROPIC_OAUTH_TOKEN` in the environment or config `env`. Specific model entries keep winning over the wildcard, so entries that name a runtime are unaffected. Runtime reads only the canonical entry; there is no new compatibility reader. The change is reported as a Doctor change (`openclaw doctor` lists it, `--fix` writes it). Sign-in seeding filters catalog rows with `status: "deprecated"`. Route probing and the setup picker still see every row. ## Update Behavior The installed updater cannot be patched, so the repair keys only on config that shipped Claude CLI sign-ins already wrote. During `openclaw update`, the candidate's own Doctor runs twice: once as `doctor --fix` in the candidate rehearsal on a private state snapshot (`candidate-doctor`), then as `doctor --repair --non-interactive` in a fresh process after the package swap (`openclaw doctor`). The second run writes the repair through Doctor's normal backed-up config write (`openclaw.json.bak` ring plus `openclaw.json.pre-update`), so update rollback restores the earlier config. The update result lists the change under the Doctor migration notes. Gateway startup does not apply it to a valid config. After a manual package replacement, run `openclaw doctor --fix`. ## Evidence - Regression tests fail at the parent commit and pass here: - `extensions/anthropic/cli-migration.test.ts`: `registered cli sign-in seeds no deprecated Claude CLI catalog rows` fails at the parent (`expected { …(12) } to not have property "anthropic/claude-opus-4-8"`). Its second case shows an existing `claude-opus-4-8` default and entry survive sign-in. Three existing seeding expectations drop `claude-opus-4-8`. - `extensions/anthropic/doctor-contract-api.test.ts`: covers the repair, idempotency, both kinds of existing wildcard, an API default with a Claude CLI fallback, a non-Anthropic default, auth profile, provider API key, config env key, process env key, provider-level runtime, and the retired provider marker. At the parent the module does not exist. - Published-driver × candidate cells: Docker `bare` image, published `[email protected]` from npm, sign-in through the published `openclaw onboard --non-interactive --auth-choice anthropic-cli` with a stub `claude` that only answers `claude auth status`. Then `openclaw update --tag file:<candidate tgz> --no-restart --yes --json` to a package built by `scripts/package-openclaw-for-docker.mjs` from this head: | Cell | Config before update | `update` | `anthropic/*` after | Other model entries | Post-update `doctor` / `config validate` | | --- | --- | --- | --- | --- | --- | | A | 2026.9.9 sign-in: 11 seeded rows pinned `claude-cli`, default `anthropic/claude-opus-5-5`, no wildcard | `status: ok`, `2026.9.9 (bcfc888)` → `(587456f)`; result notes `Doctor migration: agents.defaults.models["anthropic/*"]: added the claude-cli runtime …` | `{ agentRuntime: { id: "claude-cli" } }` | unchanged (only `anthropic/*` differs); `.bak`, `.bak.1` and `.pre-update` have no wildcard | exit 0, no further Anthropic finding / `Config valid` | | B | A plus `"anthropic/*": { agentRuntime: { id: "openclaw" } }` | `status: ok` | still `openclaw` | unchanged | exit 0 / `Config valid` | | C | A plus an `anthropic:default` API-key auth profile | `status: ok` | absent | unchanged | exit 0 / `Config valid` | Replaying the candidate Doctor on a copy of cell A's pre-update config: `openclaw doctor --non-interactive` lists the `agents.defaults.models["anthropic/*"]` change and leaves the file unchanged. `openclaw doctor --fix --non-interactive` writes `{ agentRuntime: { id: "claude-cli" } }` and rotates `openclaw.json.bak`. The same replays leave cells B and C unchanged. - `pnpm exec oxlint --type-aware` on the changed files: clean. `node scripts/check-changed.mjs` passed every lane, including the doctor contract declaration and closure guard tests and the extension typechecks, except the dead-export scan. That scan flags only untouched files (`extensions/telegram/src/sequential-key.ts`, `src/auto-reply/reply/model-selection.ts`). With `OPENCLAW_CHECK_CHANGED_SKIP_DEADCODE=1` it exits 0. ## Merge Danger One-way door: `openclaw update` and `doctor --fix` write `anthropic/*` into existing configs. A revert stops new writes but does not remove entries already written; the pre-update backup still has the earlier config. Blast radius: Claude CLI users with no Anthropic credential visible to config repair. Claude IDs without a specific runtime-pinned entry move from a failing API route to Claude Code. A user whose only Anthropic API key lives in the auth store, with no config auth profile or env var, and who sets a Claude CLI-pinned default model, would also see unpinned Claude IDs move to Claude Code. That is the routing a fresh Claude CLI sign-in now produces. Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
Fixes: after Claude CLI sign-in (
openclaw models auth login --provider anthropic --method cli), anyanthropic/<id>that sign-in did not seed fails withNo API key found for provider "anthropic" … missing-provider-auth. This affects Claude models published after sign-in and IDs typed with--model,/modelormodels set, such asanthropic/claude-haiku-4-5.User Impact
User impact: Claude-CLI-only users can type or pick any Claude model and it runs through Claude Code. The model picker still lists only models the Claude CLI catalog serves, so
claude-mythos-5(direct API only) stays hidden. Users with an Anthropic API key and no Claude CLI sign-in keep the API route. Exact model entries that name another runtime still win. A session pinned to an Anthropic API-key account keeps that account's models, includingclaude-mythos-5, in its picker.Existing installs that signed in on an affected build get the new routing only after they rerun
openclaw models auth login --provider anthropic --method cli. This PR adds no Doctor migration.User-authored
provider/*wildcards for other CLI backends behave exactly as onmain. For example,google/*→google-gemini-clikeeps the same picker rows, and its typed IDs run as before. The picker gate is keyed on theanthropic/*→claude-clientry that sign-in writes.Why This Change Was Made
Since #129052, Claude CLI sign-in persists no OpenClaw auth profile. At run time,
resolveCliRuntimeExecutionProvider(src/agents/model-runtime-aliases.ts) found no runtime policy for unseeded IDs and noclaude-cliprofile it could alias. The turn then fell to the embedded Anthropic API path. An instrumented isolated Gateway on 58ba7ed showedpolicy=undefined … viaAuthProfile=undefinedand thenuseCliExecution=false.extensions/anthropic/cli-migration.ts) now also writes the existing, documented provider wildcardagents.defaults.models["anthropic/*"] = { agentRuntime: { id: "claude-cli" } }. It does not overwrite a wildcard that already names another runtime.src/agents/model-catalog-cli-wildcard.ts, used bymodel-catalog-decisions.ts) mark a row unavailable, with no "sign in" reason, when all of these hold: native Claude CLI credentials supplied the availability (evidence: "runtime"), the row reachesclaude-clionly through that sign-in wildcard, the Claude CLI catalog does not list it (bundled manifest plus published catalog), and it is not a configured row. Availability from a selected or pinned API account is never narrowed. Run-time routing is unchanged, so typed IDs still run.Production change: 3 lines in cli-migration.ts, 15 net lines in model-catalog-decisions.ts and a new 58-line module (about 45 code lines). No config keys, schema or SDK surface change.
Provenance (f8b06fb, #166037): prepared catalog decisions keep saved account, model and runtime choices and their provenance.
createCliRuntimeModelAuthEvaluatorreturns a pinned non-native account's own provider-auth result, andevaluateNativekeeps host results for selected accounts. The wildcard gate now only narrows availability that came from native Claude CLI credentials, so a saved account choice keeps the models that account can use.Evidence
Real proofs used the machine's existing native
claudelogin, OpenClaw's real sign-in flow, isolated profiles and a loopback Gateway:Before, on
main58ba7ed:models set anthropic/claude-haiku-4-5plus one turn failed withmissing-provider-auth, and the instrumentation showed no CLI route.After, on b35cc8e: the picker lists
availablerows that exactly match the 11 Claude CLI catalog IDs.claude-mythos-5andclaude-haiku-4-5are not listed.After: a turn typed with
--model anthropic/claude-haiku-4-5returnedOKwithrunner=cliandwinnerProvider=claude-cli.After:
models set anthropic/claude-haiku-4-5plus a turn returnedOKthroughclaude-cli.API-key control: on a profile with
paste-api-key(key piped on stdin) and no Claude CLI sign-in, ananthropic/claude-haiku-4-5turn returnedOKwithrunner=embeddedandwinnerProvider=anthropic. Mythos stays listed for API users, as onmain.Regressions:
extensions/anthropic/cli-migration.test.ts, including the registered non-interactive sign-in entry: 4 failures without the fix, 40/40 pass with it.src/agents/model-catalog-decisions.test.ts: the Claude CLI wildcard test fails without the gate (expected true to be false). With the gate, it covers a listed row, an API-only row (unavailable, no reason), an exact pinned row, a configured typed row, an exact override toopenclaw, and an unchangedgoogle/*→google-gemini-clirow even when that backend lists its own rows.claude-mythos-5is available withselectedProfileId: "anthropic:work"in bothevaluateEntryandevaluateNative. With only native Claude CLI credentials it stays unavailable. On 651801e this fails (expected { availability: false … } to match object { availability: true … }). With the fix, 24/24 pass in the file, andmodel-auth-availability.test.tspluscli-migration.test.tspass.New-model simulation on 651801e, in a throwaway worktree with
claude-fable-5removed from local knowledge: both bundled manifest rows (anthropic,claude-cli), thefable-5alias, the model-catalog-core alias and the Claude CLI context alias.models.catalogRefresh.urlpointed at a loopback copy ofcatalog.openclaw.ai/models/v2/catalog.json, served at first withoutanthropic/claude-fable-5andclaude-cli/claude-fable-5.models.list {view:"configured", refresh:true}(the Control UI view) returned 10 Claude rows and no Fable 5 row.generatedAt, then ranopenclaw models refreshandmodels.list {refresh:true}. The Gateway PID did not change. The first response was unchanged because adoption starts after that response. The next read listedclaude-cli/claude-fable-5as available, but notanthropic/claude-fable-5. A Gateway restart gave the same rows, so the refresh lifecycle is not the cause.--model anthropic/claude-fable-5returnedOKon the same Gateway PID withrunner=cli,winnerProvider=claude-cliandwinnerModel=claude-fable-5.--model claude-cli/claude-fable-5, the row the picker shows, also returnedOKthroughclaude-cli.Gates on 41f26e5:
node scripts/check-changed.mjsexited 0. It ran the tsgo lanes, oxlint on core and the changed extension files, the full dead-export scan, format checks, ratchets and the import-cycle check.pnpm exec oxlint --type-awareon the changed files exited 0.Upgrade cell (published v2026.9.9 → this PR, disposable Docker container from the
scripts/e2e/Dockerfilebarestage, candidate packed withscripts/package-openclaw-for-docker.mjsfrom 41f26e5, build2026.9.9-41f26e5206fc).api.anthropic.comresolved to loopback in the container, so the fake key never left it. npmlatestis still 2026.9.9.agents.defaults.modelswith threeanthropic/*IDs onclaude-cliand no wildcard, primaryanthropic/claude-opus-5-5, and ananthropic:workAPI-key profile frompaste-api-keywith a fake key. Through the v2026.9.9 Gateway,sessions.createand thensessions.patch {model:"anthropic/claude-sonnet-5@anthropic:work"}saved this session selection:providerOverride=anthropic, modelOverride=claude-sonnet-5, authProfileOverride=anthropic:work (user), agentRuntimeOverride=claude-cli.openclaw update --tag file:<tgz> --no-restart --yes --jsonexited 0 withstatus: okand all steps at 0. The CLI now reportsOpenClaw 2026.9.9 (41f26e5). The updater's doctor,openclaw doctor --non-interactiveandconfig validatepassed (valid: true, no warnings). Doctor warnings matched the baseline: a plaintext gateway token in the fixture, loopback bind and no service manager. The saved session selection andagents.defaults.modelsread back identical to the pre-update values.openclaw models auth login --provider anthropic --method cli --set-defaultunder a pty. It needs a TTY. Without aclaudebinary it stops withClaude CLI is not authenticated on this host. With a stubclaudeonPATHthat only answersauth status --jsonwith{"loggedIn":true,"authMethod":"claude.ai"}and--version, and never runs a model, it exited 0. That was the only stubbed part; the sign-in, config write and Gateway are the shipped code. After the first sign-in,"anthropic/*": {agentRuntime:{id:"claude-cli"}}was present once. A second sign-in left it present once. The three existing entries and the primary were unchanged, the session selection was identical after each sign-in, andconfig validateand doctor passed.models.list {sessionKey, view:"all", provider:"anthropic"}for the session pinned toanthropic:worklistedclaude-mythos-5asavailable: true.models.list {agentId:"main"}, with no selected account, listed it asavailable: false, which is the accepted Claude CLI-first behavior.Gap: a Claude model that the published catalog adds later appears in the picker without a restart, but only as
claude-cli/<id>, notanthropic/<id>.anthropicis arefreshablecatalog provider, so its published rows appear only when live/v1/modelsdiscovery returns them, and that discovery needs an API key. Thesrc/agents/model-catalog.tsguard says "Only live registry or refreshed rows may publish those provider models".claude-cliisstatic, so its published row appears. The sign-in wildcard gate only marks existinganthropicrows unavailable and never adds rows, so theclaude-clirow has noanthropictwin to fold into. Both refs run through Claude Code. Showinganthropic/<id>would need a separate change to the refreshable-provider guard inmodel-catalog.tsor to the CLI twin collapse inmodel-runtime-aliases.ts.Merge danger
Medium-low. The run-time change is config written only by Claude CLI sign-in. The picker change sits in shared catalog decisions, but it applies only when an agent's
anthropic/*entry namesclaude-cliand the row is neither configured nor listed by the Claude CLI catalog.