Skip to content

fix: keep Claude CLI authentication native - #129052

Merged
obviyus merged 1 commit into
mainfrom
t3code/fix-claude-native-auth
Aug 25, 2026
Merged

obviyus merged 1 commit into
mainfrom
t3code/fix-claude-native-auth

Conversation

@obviyus

@obviyus obviyus commented Aug 25, 2026 •

Copy link
Copy Markdown
Collaborator

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.

  • Setup checks the same Claude executable and environment used at runtime.
  • OpenClaw never reads, copies, forwards, or refreshes native Claude tokens.
  • Runtime uses the current Claude login through the official Agent SDK.
  • Doctor preserves Claude CLI routing before removing retired copied profiles.
  • Doctor removes copied profiles only after the repaired config saves successfully.
  • The released token-reader import remains temporarily, but always returns null.

OpenClaw-managed Anthropic API keys and setup tokens keep their existing protected path.

User Impact

Run claude auth login once as the Gateway user. Claude CLI handles later token refreshes itself.

Evidence

  • Pre-fix regressions failed for runtime probing, Doctor cleanup ordering, and the released import.
  • Final focused auth, Doctor, migration, runtime, and plugin suites passed 292 tests.
  • pnpm tsgo, pnpm check:test-types, full pnpm lint, and git diff --check passed.
  • Fresh live Doctor proof removed the copied reference, kept agentRuntime.id = "claude-cli", and left zero copied credentials.
  • A real local agent turn returned OPENCLAW_FINAL_OK through claude-cli and the official Agent SDK.
  • Production code: +505/-1122 lines, net -617. Tests: +873/-1837 lines, net -964. Other: +33/-24 lines, net +9.

@obviyus
obviyus requested a review from a team as a code owner August 25, 2026 06:31
@clawsweeper

clawsweeper Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling extensions: anthropic size: M maintainer Maintainer-authored PR labels Aug 25, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 25, 2026
@clawsweeper

clawsweeper Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 25, 2026, 7:34 AM ET / 11:34 UTC.

ClawSweeper review

What this changes

Moves Claude CLI authentication to the Anthropic plugin’s native login, removes copied legacy profiles through Doctor, and retires the core Claude credential reader.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 6 items remain

Keep 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
Reviewed head: 7ebca34bcd3af8c56b39d27a0a1068c1b38db353

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The native-login direction is coherent, but three source-backed compatibility and Doctor behavior defects need correction.
Proof confidence 🌊 off-meta tidepool Not applicable: This member-authored PR is exempt from the external-contributor real-behavior proof gate.
Patch quality 🦐 gold shrimp (3/6) 3 actionable review findings remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This member-authored PR is exempt from the external-contributor real-behavior proof gate.
Evidence reviewed 6 items Unrelated defaults mutation: The retirement flow applies broad provider defaults before deleting every confirmed retired profile. Anthropic defaults treat the retained retired profile as OAuth and add global context-pruning and heartbeat defaults, including when the profile is stale and unrelated to the selected model.
Anthropic default behavior: The provider derives OAuth from configured Anthropic/Claude profiles and then assigns cache-ttl pruning and a one-hour heartbeat when agent defaults exist.
Doctor/runtime environment mismatch: Doctor passes its raw environment to claude auth status, whereas the runtime removes Anthropic and Claude OAuth override variables and setup already mirrors that sanitized probe environment.
Findings 3 actionable findings [P1] Avoid applying Anthropic defaults for a stale retired profile
[P1] Probe Doctor authentication in the runtime environment
[P1] Do not silently retire the public credential-reader contract
Security None None.

How this fits together

Setup 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]
Loading

Before merge

  • Avoid applying Anthropic defaults for a stale retired profile (P1) - applyProviderConfigDefaultsForConfig runs for every retired profile before that profile is removed. For an unused stored anthropic:claude-cli profile, Anthropic’s defaults infer OAuth from the profile and add global cache pruning and a one-hour heartbeat, even when the default agent uses another provider. Only preserve provider routing when the retired profile actually participates in it; add a stale-unused-profile regression that asserts no default-model mutation.
  • Probe Doctor authentication in the runtime environment (P1) - Doctor resolves and probes claude auth status with the raw Gateway environment, but execution removes ANTHROPIC_* and CLAUDE_CODE_* auth overrides before launching Claude. This can tell an operator that native login works while the actual Agent SDK run has no usable login. Build the Doctor probe environment from the same backend clearEnv policy used by setup and execution, preserving CLAUDE_CONFIG_DIR.
  • Do not silently retire the public credential-reader contract (P1) - plugin-sdk/provider-auth is a published SDK subpath, yet this exported reader now returns null for every caller. Retaining the symbol and types does not preserve its runtime contract: external plugins can treat null as logout or select a fallback. Keep a supported replacement/deprecation path or obtain an explicit versioned, documented migration decision before changing this public behavior.
  • Resolve merge risk (P1) - Running openclaw doctor --fix can change heartbeat and context-pruning defaults for users whose stale Claude profile is not an active Anthropic route.
  • Resolve merge risk (P1) - Doctor can report a Claude login reachable through variables that execution deliberately removes, leaving the selected native runtime unauthenticated.
  • Resolve merge risk (P1) - External plugins importing the published credential reader may interpret its new unconditional null as logout or fall back unexpectedly.

Findings

  • [P1] Avoid applying Anthropic defaults for a stale retired profile — src/commands/doctor-auth-legacy-oauth.ts:74-78
  • [P1] Probe Doctor authentication in the runtime environment — src/commands/doctor-claude-cli.ts:208-210
  • [P1] Do not silently retire the public credential-reader contract — src/plugin-sdk/provider-auth-claude-compat.ts:42-45
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Doctor migration slice production +97/-13; targeted tests +190/-6 The migration and flow plumbing materially change persisted configuration behavior, while the targeted test does not cover an unused retired-profile case.

Stored data model

Persistent data-model change detected: migration/backfill/repair: config/assertion-safety-baseline.txt, migration/backfill/repair: extensions/anthropic/cli-migration.ts, migration/backfill/repair: src/agents/auth-profiles/external-cli-sync.email-backfill.test.ts, migration/backfill/repair: src/agents/model-auth-provider.ts, migration/backfill/repair: src/commands/doctor-auth-legacy-oauth.ts, migration/backfill/repair: src/commands/doctor-auth.deprecated-cli-profiles.test.ts, and 41 more. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Correct the migration and probe before merge (recommended)
    Limit provider-default application to active Claude routing, use runtime-equivalent probe sanitization, and add regressions for stale profiles and stripped credential variables.
  2. Define the SDK retirement contract
    Obtain an explicit versioned and documented replacement or deprecation plan before shipping the public reader’s null-only behavior.

Technical review

Best 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 anthropic:claude-cli profile reaches provider-default application before removal, and Doctor passes raw environment variables to the login probe; neither path was executed in this read-only review.

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:

  • [P1] Avoid applying Anthropic defaults for a stale retired profile — src/commands/doctor-auth-legacy-oauth.ts:74-78
    applyProviderConfigDefaultsForConfig runs for every retired profile before that profile is removed. For an unused stored anthropic:claude-cli profile, Anthropic’s defaults infer OAuth from the profile and add global cache pruning and a one-hour heartbeat, even when the default agent uses another provider. Only preserve provider routing when the retired profile actually participates in it; add a stale-unused-profile regression that asserts no default-model mutation.
    Confidence: 0.96
  • [P1] Probe Doctor authentication in the runtime environment — src/commands/doctor-claude-cli.ts:208-210
    Doctor resolves and probes claude auth status with the raw Gateway environment, but execution removes ANTHROPIC_* and CLAUDE_CODE_* auth overrides before launching Claude. This can tell an operator that native login works while the actual Agent SDK run has no usable login. Build the Doctor probe environment from the same backend clearEnv policy used by setup and execution, preserving CLAUDE_CONFIG_DIR.
    Confidence: 0.92
  • [P1] Do not silently retire the public credential-reader contract — src/plugin-sdk/provider-auth-claude-compat.ts:42-45
    plugin-sdk/provider-auth is a published SDK subpath, yet this exported reader now returns null for every caller. Retaining the symbol and types does not preserve its runtime contract: external plugins can treat null as logout or select a fallback. Keep a supported replacement/deprecation path or obtain an explicit versioned, documented migration decision before changing this public behavior.
    Confidence: 0.91

Overall correctness: patch is incorrect
Overall confidence: 0.93

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 1bfaa806db50.

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.

Label justifications:

  • P1: Doctor can alter existing users’ global defaults and misstate whether the runtime’s native authentication is usable.
  • merge-risk: 🚨 compatibility: A published Plugin SDK function changes from credential retrieval to unconditional null without a documented compatibility transition.
  • merge-risk: 🚨 auth-provider: Doctor’s authentication health result is evaluated in a different credential environment from the Claude execution path.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This member-authored PR is exempt from the external-contributor real-behavior proof gate.

Evidence

Acceptance criteria:

  • [P1] Add a Doctor migration test for an unreferenced retired profile with an unrelated default provider.
  • [P1] Add a Doctor authentication test that proves sanitized probe variables match execution behavior.
  • [P1] Run the targeted Doctor, Anthropic CLI-auth, and Plugin SDK contract tests after the contract decision.

What I checked:

  • Unrelated defaults mutation: The retirement flow applies broad provider defaults before deleting every confirmed retired profile. Anthropic defaults treat the retained retired profile as OAuth and add global context-pruning and heartbeat defaults, including when the profile is stale and unrelated to the selected model. (src/commands/doctor-auth-legacy-oauth.ts:74, 7ebca34bcd3a)
  • Anthropic default behavior: The provider derives OAuth from configured Anthropic/Claude profiles and then assigns cache-ttl pruning and a one-hour heartbeat when agent defaults exist. (extensions/anthropic/config-defaults.ts:294, 7ebca34bcd3a)
  • Doctor/runtime environment mismatch: Doctor passes its raw environment to claude auth status, whereas the runtime removes Anthropic and Claude OAuth override variables and setup already mirrors that sanitized probe environment. (src/commands/doctor-claude-cli.ts:208, 7ebca34bcd3a)
  • Public SDK behavior change: plugin-sdk/provider-auth is a published package export and listed SDK subpath, but its Claude credential reader now always returns null without a documented replacement or versioned migration. (src/plugin-sdk/provider-auth-claude-compat.ts:42, 7ebca34bcd3a)
  • Existing test gap: The retirement test covers an active Anthropic model and profile reference; it does not cover an unreferenced stale profile or assert that global defaults remain unchanged. (src/commands/doctor-auth.deprecated-cli-profiles.test.ts:213, 7ebca34bcd3a)
  • History and main limitation: The grafted promisor checkout could not retrieve missing objects because github.com DNS resolution failed, so current-main, release inclusion, and feature-history provenance could not be verified.

Likely related people:

  • Ayaan Zaidi: Authored the sole local commit; the unavailable history prevents stronger ownership attribution. (role: reviewed-change author; confidence: low; commits: 7ebca34bcd3a; files: src/commands/doctor-auth-legacy-oauth.ts, src/commands/doctor-claude-cli.ts, src/plugin-sdk/provider-auth-claude-compat.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add an unused retired-profile regression proving Doctor leaves unrelated agent defaults unchanged.
  • Add a Doctor probe regression with a stripped Anthropic or Claude OAuth override present.
  • Document and version the public SDK credential-reader transition or provide its supported replacement.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (7 earlier review cycles)
  • reviewed 2026-08-25T06:38:06.320Z sha dd9bdb427fb619153c3a72be0144e5320523ced1 :: found issues before merge. :: [P1] Migrate legacy Claude CLI credentials out of the auth store
  • reviewed 2026-08-25T06:51:48.347Z sha 3bbc1bef004d8aa0160a99623ec353cd832a3e4d :: found issues before merge. :: [P1] Purge legacy Claude CLI credentials during migration | [P2] Describe the runtime-only credential overlay accurately
  • reviewed 2026-08-25T08:00:03.037Z sha 11742b88fba2e4a789081f110ca759b83d50aa15 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-25T08:43:11.358Z sha c20daa2 :: found issues before merge. :: [P1] Ignore the retired profile by ID
  • reviewed 2026-08-25T09:12:37.625Z sha c20daa2 :: needs changes before merge. :: [P1] Ignore the retired profile by ID
  • reviewed 2026-08-25T09:48:11.528Z sha 279d11d381b68058ccb6be54847087aa53c2901c :: found issues before merge. :: [P1] Match the retired profile by its declared identity
  • reviewed 2026-08-25T10:56:33.383Z sha 0055830 :: found issues before merge. :: [P1] Probe the executable the backend actually runs | [P1] Defer profile deletion until the config repair is durable

@obviyus
obviyus force-pushed the t3code/fix-claude-native-auth branch from dd9bdb4 to 3bbc1be Compare August 25, 2026 06:45
@openclaw-barnacle openclaw-barnacle Bot added the gateway Gateway runtime label Aug 25, 2026
@obviyus
obviyus force-pushed the t3code/fix-claude-native-auth branch from 3bbc1be to cac4cd1 Compare August 25, 2026 07:40
@openclaw-barnacle openclaw-barnacle Bot added the commands Command implementations label Aug 25, 2026
@obviyus
obviyus force-pushed the t3code/fix-claude-native-auth branch from cac4cd1 to 11742b8 Compare August 25, 2026 07:52
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 25, 2026
@obviyus
obviyus force-pushed the t3code/fix-claude-native-auth branch 2 times, most recently from 3033338 to c20daa2 Compare August 25, 2026 08:37
@clawsweeper clawsweeper Bot added merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 25, 2026
@obviyus
obviyus force-pushed the t3code/fix-claude-native-auth branch 2 times, most recently from 279d11d to 85b0294 Compare August 25, 2026 09:59
amittell added a commit to amittell/openclaw that referenced this pull request Sep 18, 2026
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).
obviyus added a commit that referenced this pull request Oct 9, 2026
…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]>
obviyus added a commit that referenced this pull request Oct 10, 2026
…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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 10, 2026
…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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 10, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling commands Command implementations docs Improvements or additions to documentation extensions: anthropic gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant