Repository navigation
fix(anthropic): native Claude models show incorrect availability - #129346
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
Keep the released Claude CLI credential reader source-compatible through its documented v2026.10 retirement window and explicitly account for both retained type exports in the public SDK budget. Co-authored-by: Tak Hoffman <[email protected]>
|
@clawsweeper review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
f5f1f36 to
e42bfd7
Compare
|
@roboclaw-bot @Takhoffman Thanks for checking the Claude compatibility boundary. I preserved your commit and co-author attribution in the branch history, then verified both stable |
e7fa5e1 to
5c96c47
Compare
…nthropic-availability-main # Conflicts: # src/agents/embedded-agent-runner/compaction-runtime-context.test.ts
…nthropic-availability-main # Conflicts: # src/plugins/provider-runtime.ts
…nthropic-availability-main # Conflicts: # src/auto-reply/reply/commands-learn.test.ts
…pair-native-anthropic-availability-main # Conflicts: # extensions/anthropic/cli-constants.ts # extensions/anthropic/config-defaults.ts # extensions/anthropic/provider-policy-api.ts # test/vitest/vitest.extension-codex-app-server-attempt-support.config.ts
|
Merged via squash.
|
…nclaw#129346) * fix(anthropic): verify native Claude login before publishing runtime auth * fix(status): preserve native Claude CLI authentication labels * refactor(gateway): remove retired native Claude auth projection * fix(plugin-sdk): retain Claude compatibility types Keep the released Claude CLI credential reader source-compatible through its documented v2026.10 retirement window and explicitly account for both retained type exports in the public SDK budget. Co-authored-by: Tak Hoffman <[email protected]> * fix(plugin-sdk): preserve only shipped Claude compatibility exports * fix(ci): align Claude native-auth contracts Retire Doctor fixtures for credentials now owned by Claude CLI and remove the two never-shipped compatibility type exports while retaining the shipped reader through its documented v2026.10 window. Co-authored-by: Tak Hoffman <[email protected]> * test(onboard): remove retired Claude credential file fixture * fix(auth): skip incompatible profiles before plugin discovery * fix(auth): avoid cold plugin activation for retired profiles * test: repair upstream doctor and learning regressions * fix(onboard): validate authored aliases without plugin discovery * fix(agents): resolve compaction aliases without plugin discovery * test(ui): register pairing sidebar before lifecycle teardown * fix(anthropic): keep provider policy imports runtime-free * test(vitest): cover codex startup retry test family * fix(agents): avoid plugin discovery for internal sessions --------- Co-authored-by: roboclaw-bot <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
…tartup (#166305) ## What Problem This Solves Fixes: Claude CLI models stay hidden or disabled in the Control UI model picker and `openclaw models list` when Claude Code was logged out at Gateway start and the user logs in afterwards; only a Gateway restart or `models.list {refresh: true}` fixed it. A logout after startup was never reflected either. ## User Impact User impact: after `claude auth login` (or a logout), the picker shows the right Claude CLI models within about a minute, without restarting the Gateway or reloading the page. How a logged-out Claude is displayed is unchanged. ## Why This Change Was Made - The picker's availability filter already counts Claude Code's own login: `evaluateCliRuntimeModelAuthAvailability` reads the `claude-cli` auth mode from the `claude auth status --json` probe in `extensions/anthropic/provider-discovery.ts`. - #129346 (fee4e77) made that probe run once per config generation so that "repeated model-list requests do not repeatedly launch the Claude CLI". #139757 (d40d26a) shared it across agent workspaces after 632-agent rosters timed out at startup, and documented that "explicit catalog/auth captures recheck availability". - Nothing on the ordinary-read path rechecked it: `refreshExpiredModelCatalog` only renews providers with an inventory `expiresAt`, and the static `claude-cli` provider never gets one. So the startup result stayed for the whole generation. The existing ordinary-read renewal hook now also rechecks CLI-backend native logins (CLI backends whose manifest declares `syntheticAuthRefs`, which today means `claude-cli`). The recheck runs in the background, deduplicates through the worker's existing `loadAuth`, and publishes a new catalog through the existing native-publication path only when the login state changed. The explicit `loadAuth` refresh and the recheck share one scoped-auth merge in `prepared-model-runtime.catalog-auth.ts`; `loadAuth` still returns only `{ authStore, authModes }`. Startup still probes once per shared generation, so both earlier PRs' cost limits hold. ## Bounded cost - At most one `claude auth status --json` (existing 3 s timeout, process-tree kill) per prepared catalog owner per 60 s, and only while model lists are being read. An idle Gateway spawns nothing. - Picker opens inside the window spawn nothing; concurrent reads share one in-flight probe. - Nothing is published, and no catalog event is emitted, when the login state is unchanged. - Measured on an isolated Gateway (below): 40 picker opens in 59 s started 1 probe; 14 opens during a 60 s login wait started 1 probe; probes were always at least 60 s apart. ## Evidence **Regression test.** `src/gateway/server.chat-cli-auth.test.ts` adds "publishes Claude login changes after Gateway startup". It runs the real in-process Gateway, the real Anthropic plugin and `models.list`; only the `claude` executable is a fixture, and it records each `auth status` probe. It checks that the model is unavailable at startup, that a login inside the recheck window spawns no probe, that the model becomes available after the window with exactly one more probe, and that a logout makes it unavailable again with exactly one more probe. Each transition awaits the catalog publication rather than polling. With origin/main's catalog code the login publication never arrives and the test times out at 90 s; on this branch it passes in about 5 s. The full file (7 tests), the prepared-runtime suites that share its test harness, and `node scripts/check-changed.mjs` pass on this branch. **Live Control UI, before and after.** Two isolated Gateways on one Mac, origin/main and this branch. State, config, `HOME` and `CLAUDE_CONFIG_DIR` were under /tmp, there was no Anthropic API key, and the config was shaped like our setup. Each used the real `claude` binary behind a wrapper that only counts `auth status` calls. Both started logged out. The login happened afterwards, by placing a Claude credentials file in each isolated `CLAUDE_CONFIG_DIR`. The picker was reopened in place and the page was never reloaded. | | origin/main | this branch | |---|---|---| | Before login |  |  | | After login |  |  | - origin/main: 6 minutes and 27 picker opens after login, `claude auth status` in the same `CLAUDE_CONFIG_DIR` reported `loggedIn: true`, but the picker still showed 2 Anthropic rows and all 11 Claude rows disabled. One probe in total, at startup. - This branch: all 15 Claude rows (6 configured `anthropic/*` and 9 `claude-cli/*`) were enabled on the first open after the window. After a logout they were disabled again on the next window. A re-login right after a recheck showed up after 60 s, with 14 picker opens and exactly 1 probe. LOC vs origin/main: production +104/-25, tests +51/-3, docs +3/-1. Co-authored-by: Ayaan Zaidi <[email protected]>
…tartup (openclaw#166305) ## What Problem This Solves Fixes: Claude CLI models stay hidden or disabled in the Control UI model picker and `openclaw models list` when Claude Code was logged out at Gateway start and the user logs in afterwards; only a Gateway restart or `models.list {refresh: true}` fixed it. A logout after startup was never reflected either. ## User Impact User impact: after `claude auth login` (or a logout), the picker shows the right Claude CLI models within about a minute, without restarting the Gateway or reloading the page. How a logged-out Claude is displayed is unchanged. ## Why This Change Was Made - The picker's availability filter already counts Claude Code's own login: `evaluateCliRuntimeModelAuthAvailability` reads the `claude-cli` auth mode from the `claude auth status --json` probe in `extensions/anthropic/provider-discovery.ts`. - openclaw#129346 (f4ade71) made that probe run once per config generation so that "repeated model-list requests do not repeatedly launch the Claude CLI". openclaw#139757 (13a4405) shared it across agent workspaces after 632-agent rosters timed out at startup, and documented that "explicit catalog/auth captures recheck availability". - Nothing on the ordinary-read path rechecked it: `refreshExpiredModelCatalog` only renews providers with an inventory `expiresAt`, and the static `claude-cli` provider never gets one. So the startup result stayed for the whole generation. The existing ordinary-read renewal hook now also rechecks CLI-backend native logins (CLI backends whose manifest declares `syntheticAuthRefs`, which today means `claude-cli`). The recheck runs in the background, deduplicates through the worker's existing `loadAuth`, and publishes a new catalog through the existing native-publication path only when the login state changed. The explicit `loadAuth` refresh and the recheck share one scoped-auth merge in `prepared-model-runtime.catalog-auth.ts`; `loadAuth` still returns only `{ authStore, authModes }`. Startup still probes once per shared generation, so both earlier PRs' cost limits hold. ## Bounded cost - At most one `claude auth status --json` (existing 3 s timeout, process-tree kill) per prepared catalog owner per 60 s, and only while model lists are being read. An idle Gateway spawns nothing. - Picker opens inside the window spawn nothing; concurrent reads share one in-flight probe. - Nothing is published, and no catalog event is emitted, when the login state is unchanged. - Measured on an isolated Gateway (below): 40 picker opens in 59 s started 1 probe; 14 opens during a 60 s login wait started 1 probe; probes were always at least 60 s apart. ## Evidence **Regression test.** `src/gateway/server.chat-cli-auth.test.ts` adds "publishes Claude login changes after Gateway startup". It runs the real in-process Gateway, the real Anthropic plugin and `models.list`; only the `claude` executable is a fixture, and it records each `auth status` probe. It checks that the model is unavailable at startup, that a login inside the recheck window spawns no probe, that the model becomes available after the window with exactly one more probe, and that a logout makes it unavailable again with exactly one more probe. Each transition awaits the catalog publication rather than polling. With origin/main's catalog code the login publication never arrives and the test times out at 90 s; on this branch it passes in about 5 s. The full file (7 tests), the prepared-runtime suites that share its test harness, and `node scripts/check-changed.mjs` pass on this branch. **Live Control UI, before and after.** Two isolated Gateways on one Mac, origin/main and this branch. State, config, `HOME` and `CLAUDE_CONFIG_DIR` were under /tmp, there was no Anthropic API key, and the config was shaped like our setup. Each used the real `claude` binary behind a wrapper that only counts `auth status` calls. Both started logged out. The login happened afterwards, by placing a Claude credentials file in each isolated `CLAUDE_CONFIG_DIR`. The picker was reopened in place and the page was never reloaded. | | origin/main | this branch | |---|---|---| | Before login |  |  | | After login |  |  | - origin/main: 6 minutes and 27 picker opens after login, `claude auth status` in the same `CLAUDE_CONFIG_DIR` reported `loggedIn: true`, but the picker still showed 2 Anthropic rows and all 11 Claude rows disabled. One probe in total, at startup. - This branch: all 15 Claude rows (6 configured `anthropic/*` and 9 `claude-cli/*`) were enabled on the first open after the window. After a logout they were disabled again on the next window. A re-login right after a recheck showed up after 60 s, with 14 picker opens and exactly 1 probe. LOC vs origin/main: production +104/-25, tests +51/-3, docs +3/-1. Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
Fixes an issue where users selecting a locally authenticated Claude CLI runtime saw Claude models reported unavailable, while logged-out Claude installations could still receive a misleading native-auth readiness marker. The same regression broke native authentication in status and doctor flows, left stale tests copying Claude credentials, and pushed the public plugin SDK over its export budget.
Why This Change Was Made
Claude owns its login and credentials. Its lightweight provider now verifies
claude auth status --jsonwith the same sanitized environment as actual execution, memoizes the secret-free result once per exact configuration generation, and shares that fact between discovery and runtime without subprocesses on repeated requests. Gateway model discovery now reads enabled bundled manifests rather than the installed-plugin index, and generic auth availability checks preserve the exact native runtime owner before considering provider aliases.The obsolete copied-credential fixtures are replaced by truthful prepared runtime facts and an actually registered CLI backend. Status now displays the active native runtime, doctor no longer expects retired copied Claude OAuth profiles, and onboarding preserves its real bounded native-login probe while removing an obsolete Claude credential-file fixture. A concurrently landed Gateway fallback that treated plugin-manifest presence as proof of login, including its later extracted resolver in #129374, is removed after reproducing its logged-out false positive; authentication remains exclusively owned by the verified prepared native runtime.
The same original migration also eagerly loaded provider retirement policy for every stored credential before rejecting transport-incompatible credentials, then activated cold provider runtime again for compatible credentials. OpenAI OAuth profiles consequently triggered unnecessary full-plugin discovery during both API-key-only audio requests and ordinary OAuth refresh, repeatedly hanging hosted tests for more than 292 seconds. Generic auth resolution now rejects incompatible credentials before consulting retirement policy. Concurrent upstream #129387 supplies the canonical plugin-owned lightweight policy surface for bundled providers and preserves retirement declarations from already-loaded external providers; its production implementation and bundled regression are integrated wholesale, while this change retains additional active-external and unloaded-external lifecycle coverage. Refresh failures remain terminal, and retired Claude credentials still fail closed at their credential owner before any read or refresh. Custom-provider onboarding validates authored aliases directly against configuration-owned identities rather than discovering manifests merely to detect duplicates. Embedded compaction likewise looks up actual configured aliases directly instead of invoking provider normalization for literal model overrides whose parsed result was always discarded. Selected-agent and inherited aliases, real configured compaction aliases, credential boundaries, and existing runtime-specific dynamic model normalization remain intact. The redundant retirement wrapper is removed. Two unshipped, unused type reexports are removed while the shipped compatibility reader stays intact. No token files are read, no credentials are persisted, disabled plugins remain unavailable, and native Claude authentication never authorizes direct Anthropic API requests.
The original migration also imported the entire provider-authentication SDK into supposedly lightweight Anthropic configuration defaults solely to read a plugin-owned retired-profile identifier. The newer policy artifact repeated that import and loaded the full CLI execution/approval runtime solely for an immutable thinking-profile constant. Synchronous policy materialization consequently reentered authentication, configuration, provider loading, and ESM-only dependencies, producing 120-second test stalls across configuration, cron, permissions, onboarding, and worktree flows. Both immutable facts now live in the existing dependency-free Anthropic constants owner; configuration defaults and public policy read them directly while the existing CLI re-export, public SDK identifier, retired-profile value, Mythos/Fable behavior, and external-provider hooks remain unchanged.
An inherited Control UI pairing-test teardown race is also repaired at its test-fixture owner: the suite explicitly registers the sidebar component, following its existing sibling fixture, instead of polling asynchronous custom-element registration after teardown. Production lazy loading and every operator-access and actual lazy-dialog assertion remain unchanged.
A concurrently merged Codex startup-retry regression test was excluded by the generic app-server fallback but missing from its dedicated startup-support shard. The existing startup owner now covers its bounded startup test family, preserving the upstream contributor's actual retry implementation and test unchanged while preventing the full-suite ownership audit from silently dropping new startup siblings.
The final remaining agent-tools timeout came from message-tool session inference asking bundled-plugin discovery for WebChat itself, even though WebChat is an internal channel that can never have an external channel plugin and the inferred result was subsequently discarded. The canonical session-delivery owner now infers external delivery only when the current source is internal and rejects internal session routes before plugin-specific target formatting. Automatic WebChat final replies, Discord and Teams user-prefixed direct targets, Telegram-native targets, account-scoped secrets, and cross-channel capabilities remain unchanged.
User Impact
Authenticated Claude CLI models appear available, work through their native runtime, and display the correct native authentication status. Logged-out, unreadable, or disabled Claude integrations remain unavailable with no accidental credential forwarding, repeated model-list requests do not repeatedly launch the Claude CLI, and doctor no longer treats obsolete copied credentials as required state.
Evidence
webchatplugin, then passed after that lookup was removed. The genuine canonical agent-tools runner now passes the original real source-reply integration and the complete message-tool security/routing suite: 240 tests across two files. The refreshed protected provider/native/Gateway owner suite separately passes 494 tests across 17 files.CLAUDE_CONFIG_DIRare covered.git diff --checkpass.174012ceeafa1659ef0e12d49886899f2d0bc03a.