Repository navigation
fix: keep Claude CLI authentication native - #129052
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: found issues before merge. Reviewed August 25, 2026, 7:34 AM ET / 11:34 UTC. ClawSweeper reviewWhat this changesMoves Claude CLI authentication to the Anthropic plugin’s native login, removes copied legacy profiles through Doctor, and retires the core Claude credential reader. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readinessKeep open: Doctor can mutate unrelated global defaults while removing stale credentials, its login probe differs from the runtime environment, and a public SDK export now silently changes behavior. Priority: P1 Review scores
Verification
How this fits togetherSetup and Doctor assess Claude CLI login, while Agent SDK runs launch Claude with provider override variables removed so its native login is authoritative. Doctor persists repaired configuration before removing retired profile records from agent-owned stores. flowchart LR
A[Shell and CLI login] --> B[Setup and Doctor probes]
B --> C[Anthropic provider configuration]
C --> D[Persist repaired configuration]
D --> E[Remove retired profile records]
C --> F[Agent SDK CLI execution]
F --> G[Native Claude login]
Before merge
Findings
Agent review detailsSecurityNone. Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Restrict migration defaults to an active Claude selection, probe Doctor with the same sanitized environment as execution, and retain or explicitly version a documented SDK migration path. Do we have a high-confidence way to reproduce the issue? Yes, from source: an unreferenced persisted Is this the best way to solve the issue? No: native login ownership is the right direction, but its migration must not mutate unrelated defaults, Doctor must assess the runtime environment, and SDK consumers need a supported transition. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 1bfaa806db50. LabelsLabel changes:
Label justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (7 earlier review cycles)
|
dd9bdb4 to
3bbc1be
Compare
3bbc1be to
cac4cd1
Compare
cac4cd1 to
11742b8
Compare
3033338 to
c20daa2
Compare
279d11d to
85b0294
Compare
Upstream openclaw#129052 (750a64e) removed Claude CLI from the external CLI sync providers, so a tombstoned anthropic:claude-cli profile can no longer be re-seeded. The identity-less recovery case now covers MiniMax only. Fixes the exact-head failure in agents-support (external-cli-sync.tombstone.test.ts, re-seeds an identity-less dead claude-cli profile).
…e CLI sign-in unless sign-in seeded them (#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 #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 58ba7ed 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 (f8b06fb, #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` 58ba7ed: `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 (#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 repeated Claude CLI logouts after the Anthropic Agent SDK cutover.
OpenClaw copied Claude OAuth access and refresh tokens during setup. Claude refresh tokens are single-use. Refreshing the copy invalidated the token still owned by Claude CLI.
Fix
Claude CLI now owns its native login completely.
null.OpenClaw-managed Anthropic API keys and setup tokens keep their existing protected path.
User Impact
Run
claude auth loginonce as the Gateway user. Claude CLI handles later token refreshes itself.Evidence
pnpm tsgo,pnpm check:test-types, fullpnpm lint, andgit diff --checkpassed.agentRuntime.id = "claude-cli", and left zero copied credentials.OPENCLAW_FINAL_OKthroughclaude-cliand the official Agent SDK.