Repository navigation
fix: large agent rosters repeat Claude login checks during startup - #139757
Conversation
Avoid repeating Claude CLI availability probes for each workspace during prepared model runtime publication. Keep config, environment, and cancellation ownership explicit and use one discovery hook for runtime registration. Name the pending stage in publication timeout diagnostics while retaining actual-build serialization. Reported by @609NFT in #139583. Synthetic 632-workspace regression fails before the fix and passes with one native-login probe.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 6, 2026, 2:19 AM ET / 06:19 UTC. ClawSweeper reviewWhat this changesShares Claude login availability checks across agent workspaces and adds the pending preparation stage to startup timeout messages. Regression provenancePossible regression — probable (reviewed change; failure trace). No predecessor PR is attributed. Merge readiness✅ Ready for maintainer review This remains a useful, well-supported startup repair: current main still repeats the login check, and the installed-package evidence demonstrates recovery. No actionable correctness or security finding remains. Priority: P1 Review scores
Verification
How this fits togetherGateway startup prepares model availability for each configured agent workspace. The Anthropic plugin checks the host's Claude login, and those results feed model publication before the Gateway becomes ready. flowchart TD
A[Agent roster and environment] --> B[Workspace preparation]
B --> C[Shared Claude availability observation]
C --> D[Claude login status subprocess]
D --> E[Model runtime publication]
E --> F[Gateway ready]
B --> G[Stage-aware timeout]
E --> G
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource -3, Tests +127, Docs +17. Total +141 across 11 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Keep native-login observation sharing in the Anthropic owner while preserving fresh capture generations, cancellation isolation, and actual-build serialization. Do we have a high-confidence way to reproduce the issue? Yes: current source repeats the host login probe across sequential workspace preparation, and the supplied installed-release transcript demonstrates the resulting timeout. This read-only review did not execute a current-main reproduction. Is this the best way to solve the issue? Yes: provider-local sharing removes repeated host work without weakening generic workspace ownership, increasing deadlines, or adding configuration. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e19a7694cef6. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
|
Merged via squash.
|
…penclaw#139757) * fix: share native login discovery across agent workspaces Avoid repeating Claude CLI availability probes for each workspace during prepared model runtime publication. Keep config, environment, and cancellation ownership explicit and use one discovery hook for runtime registration. Name the pending stage in publication timeout diagnostics while retaining actual-build serialization. Reported by @609NFT in openclaw#139583. Synthetic 632-workspace regression fails before the fix and passes with one native-login probe. * test: satisfy native login regression lint checks
…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]>
Related: #139583. Reported by @609NFT.
What Problem This Solves
Fixes an issue where a Gateway with a large agent roster fails startup with a prepared model runtime publication timeout while the main process appears idle. The reproduction uses 632 distinct workspaces and a synthetic Claude CLI whose native-login status check takes 250 ms; no real accounts or credentials are involved.
Why This Change Was Made
The 9.2 asynchronous native-login change (#137071, 2640154) removed the Anthropic plugin's config-wide availability observation. The generic preparation cache correctly separates workspace generations, so static startup repeated the same native-login subprocess for each workspace, sequentially. The reproduced idle interval contains continuing subprocess probes, not a lost wake-up.
The Anthropic discovery owner now shares one observation for an exact config, environment, and capture signal. Runtime registration uses that same hook. A fresh capture rechecks native availability, and cancellation remains isolated. Generic workspace/plugin auth scopes and existing bounded catalog concurrency remain unchanged. Native-login work is constant per observation; iterating the roster remains linear.
Publication timeout diagnostics now name the pending stage and workspace agent. Completion still tracks the actual build after a deadline, preventing replacement work from overlapping a timed-out generation. The timeout helper removes unreachable abort-state handling while the publication wrapper removes an intermediate promise container.
User Impact
Large rosters no longer spend their startup budget repeating one host's Claude login check. A remaining publication stall identifies the pending preparation stage. The separate costs in plugin registration, schema preflight, and Control UI asset retention are outside this repair.
Evidence
Paired installed-package proof on Blacksmith Testbox
tbx_01m1th03eya2s4f285g624eh6p, run 34012614304, lease stopped. Both packages ran on Node 24.19.0 with 4 reported CPUs, the same isolated synthetic state, 632 distinct agents/workspaces, and the same 250 msclaude auth status --jsonfixture returningloggedIn: false. The expected first-boot plugin convergence barrier was completed before measuring. Candidate used the canonical build/package command and was installed through npm into a separate prefix.The candidate peak includes successful post-ready initialization, which the failing baseline never reached; ready RSS was 1,667.5 MiB. These measurements establish startup recovery, not a memory-reduction claim.
Live-proof transcript (synthetic data only):
The later commit
8cb178e88f6e25a3614285c99ffe850078a2a1abchanges only regression-test lint; all production bytes match the paired package proof. Final-head verification passed on Blacksmith Testboxtbx_01m1tj6k87c86sm6d6ewxs0hgm, run 34013469101, lease stopped. The exact-head build, canonical package check, npm installation, focused extension lint, and 632-agent startup all passed: publication 21.8909 s, one probe, ready at 90.786 s, HTTP 200, clean exit 0, sampled peak RSS 1,661.27 MiB. Materialized tree:03a19a90417b898f15bde5be054b901f0c85f4f6. Installed build-info commit:8cb178e88f6e25a3614285c99ffe850078a2a1ab. Candidate tarball SHA256:9fe3e87b3eee27fdfa3edc9c738ab86705a137d6463ff32eae8dc0fe3d8cad71. All three task-owned proof leases are stopped.Validation:
75ebc4a5b25a9842f94ea7a3ddc86192551dfe56) includes that repair; exact-head CI run 34015360518 and requiredopenclaw/ci-gatepassed on8cb178e88f6e25a3614285c99ffe850078a2a1ab.git diff --numstat: production 70 added / 73 removed (net -3); tests 133 added / 6 removed (net +127); docs 17 added / 0 removed.The reproduction uses synthetic state shaped like the reported roster, not the reporter's private state. It establishes repeated native-login discovery as a concrete 9.2 regression; it does not claim a permanently unresolved promise was observed. ClawSweeper's requested packaged timing and RSS evidence is supplied above; no source findings were raised.
NO-FOLLOW-UP: This repair already consolidates the duplicated Anthropic hooks; the remaining cache dimensions protect distinct ownership boundaries.