Repository navigation
fix(models): Claude CLI models stay Sign-in needed after signing in until a Gateway restart - #197075
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
…y restart Co-authored-by: obviyus <[email protected]>
1f54c4c to
8bd84bb
Compare
|
Codex review: needs maintainer review before merge. What this changesThis PR refreshes Claude CLI login availability after sign-in so model browsing and selection recover without restarting the Gateway. Example: Sign in to Claude Code after Gateway startup, wait past the one-minute recheck window, then select anthropic/claude-sonnet-5-5.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR repairs a current login-recovery failure using the existing catalog owner, with convincing Gateway traces and no actionable introduced defects found. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherGateway and channel model controls consume prepared catalog and authentication facts; the catalog owner probes native CLI readiness and publishes updated availability for browsing and selection. flowchart LR
A[Model browsing] --> C[Prepared catalog owner]
B[Model selection] --> C
C --> D[Detached login recheck]
D --> E[Claude auth status]
E --> F[Publish current auth facts]
F --> C
Technical reviewBest possible solution: Use the existing throttled catalog recheck independently of request lifetime, with background browsing and awaited selection recovery. Do we have a high-confidence way to reproduce the issue? The source exposes the inherited invocation-scope failure and missing caller hooks, corroborated by the author's base/candidate Gateway traces; this read-only review ran no target code. Is this the best way to solve the issue? This is a focused repair of the existing readiness owner: the closed request scope no longer owns background publication, and consumers request freshness without duplicating authentication policy. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 85e9a2f2071e. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +17, Tests +74, Docs +1, Other +2. Total +94 across 8 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 11, 2026, 1:46 AM ET / 06:46 UTC. |
|
Merged via squash.
|
…y restart (openclaw#197075) Co-authored-by: obviyus <[email protected]>
Closes #196694
Related: #186358
Closes #191831
What Problem This Solves
Fixes: Claude CLI models stay "Sign-in needed" in
/modelsand the Discord model picker, and/modelrejects them, after you sign in to Claude Code, if the Gateway started while Claude Code was not signed in (or its first login check failed). Real turns throughclaude-cliworked, but these chat surfaces did not recover until a Gateway restart. The Control UI recovered or not depending on timing.User Impact
User impact: signing in to Claude Code on the Gateway host now shows the Claude CLI models as available, and lets
/modeland the Discord picker select them, without restarting the Gateway. The first model list read after sign-in may still show the old state; the next read (or a direct/model) uses the new login.Why This Change Was Made
claude auth statusprobe finishes after that request has replied and closed its scope, so publishing the result threwPlugin invocation scope is closed. The error was swallowed, so the stale "signed out" state stayed until restart. The recheck now runs in a detached async context (the same pattern the prepared-model-runtime refresh uses), and an unexpected failure is logged instead of hidden.models.list(the Control UI) triggered that recheck./models, the/modelmenu and the Discord picker read the same prepared data and never triggered it, so channel-only users could not recover even with a working recheck. They now trigger the same throttled recheck./modelselection awaits it, so a direct/model anthropic/...after sign-in works on the first try.models.listrecheck published only if the probe finished before that request closed its scope. In mymodels.list-only base run it won that race and recovered. The failure shows up reliably when/modelsor/modeltriggers the recheck.claude auth statusper prepared catalog owner per minute, and only while pickers or selections are read.Not changed: #196694 also suggests passing config into
resolveCliRuntimeModelBackendBinding. On real Gateways the CLI backend binding was always present (instrumentedbinding={"provider":"anthropic","runtime":"claude-cli"}on every evaluation, including hot plugin enable andplugins.allowedits). That issue's failure is the same stale login state shown below, and it went away for the reporter after the Gateway restart. This PR leaves that binding call alone.Evidence
Isolated Gateways (
env -i, own state/config/profile/port), real Claude Code 2.1.322 with its real login. A PATH shim answers onlyclaude auth statuswithloggedIn:falseuntil a flag file is removed. Removing the flag stands in forclaude auth login. Every other Claude call, including inference, goes to the real CLI. Commands go through Gatewaychat.send(the auto-reply owner that channel commands use) and Gatewaymodels.list(the Control UI picker data).63db5996/models anthropic(1st read)Sign-in needed — Claude CLI · Claude Opus 5.5/models anthropic(2nd read)Sign-in needed, again after 3+ minanthropic/claude-opus-5-5 (Claude CLI · Claude Opus 5.5)/model anthropic/claude-sonnet-5-5A runtime is not available for anthropic/claude-sonnet-5-5: sign-in needed…Model set to anthropic/claude-sonnet-5-5 … Runtime set to claude-cli/model anthropic/claude-opus-5-5(no list read first)Model set … Runtime set to claude-clion the first trymodels.list(Control UI picker data),models.list-only runavailable:trueabout 2 min after sign-in (its recheck finished while the request was open)available:truefrom the second read onmodels.listafter the/modelsand/modelreads abovemissing-auth(the recheck failed with the error below)available:trueCC10-AFTER-OK/CC10-DIRECT-OKvia[agent/cli-backend] cli turn: provider=claude-cliError: Plugin invocation scope is closedatprepareModelCatalogThinkingPolicies(instrumented; swallowed in production)Base instrumentation also showed the recheck probe returning
status:"available"and computing{"claude-cli":{"source":"native","mode":"oauth"}}, then failing to publish. Readers keptauthModes: {}.Tests (red on base, green here):
src/agents/prepared-model-runtime.native-login.test.ts: a recheck whose plugin work finishes after the triggering read's invocation scope closes still publishes the login.src/auto-reply/reply/commands-models.catalog-recovery.test.ts:/modelsand the Discord picker data (getModelsRuntimeChoices) recheck a later sign-in. Before the recheck the picker getsundefinedchoices, which is the "Could not confirm how to run this model" state with Submit disabled. After it, the choices includeclaude-cli.src/agents/model-runtime-choice.test.ts:preparePublishedModelRuntimeChoice(/model, session model selection) rechecks before deciding.Also ran 92 suites covering prepared-model-runtime, model-runtime-choice,
/modelscommands, directive handling, gatewaymodels.*methods, plugin-sdk model surfaces and the Discord model picker: all passed.node scripts/check-changed.mjs: format, line-cap, boundary, typecheck and changed-file guards passed. Two steps failed:lint coreand the dead-export scan. Both report only files this PR does not touch. Runningoxlinton the 6 changed files reports 0 warnings and 0 errors. The samelint coreshard also exits 1 on an unmodified origin/main worktree at63db5996.Gaps: #186358 also reports that the Control UI composer's credential banner ignores the selected runtime choice. This PR does not change that check, so that issue stays open. Discord component clicks need a human Discord client, so I did not click through the picker. The picker's data owner (
buildPreparedModelsProviderData) and itsgetModelsRuntimeChoicesresult are covered above. Control UI proof is the Gatewaymodels.listresponse the picker renders. This is not a visual change.Production +21/-2, tests +74 net, docs +3/-2.