Skip to content

fix: show why AI provider setup failed and let it be run again - #2393

Open
Fly-onlyone wants to merge 1 commit into
openclaw:mainfrom
Fly-onlyone:fix/ai-setup-settled-error-recovery
Open

Fly-onlyone wants to merge 1 commit into
openclaw:mainfrom
Fly-onlyone:fix/ai-setup-settled-error-recovery

Conversation

@Fly-onlyone

@Fly-onlyone Fly-onlyone commented Nov 28, 2026 •

Copy link
Copy Markdown

Related: #2112

What Problem This Solves

When an AI provider step fails inside the Gateway during Companion setup, three things go wrong today:

  1. Companion shows only "The setup outcome is not confirmed... Setup ended without an authoritative activation outcome." The Gateway's actual reason (for example "Claude CLI (claude) was not found on PATH") is only in the Gateway log.
  2. The dialog then cannot be left. Cancel answers "wizard not found" and "Restart Gateway" is refused with "The provider operation must settle before restarting setup", so the Gateway's own advice to fix the cause and "re-run this setup" cannot be followed.
  3. When the Gateway does detect Claude Code and the user picks that detected choice, Companion rejects the successful activation with "The gateway activated a different model than the selected route."

User Impact

User impact: a failed provider step now says why it failed, and "Check again" or "Cancel" returns to the provider choices on a first-run setup so the step can be tried again. The detected "Claude Code" choice now completes instead of ending in "a different model".

Scope limits to keep visible:

Why This Change Was Made

All three are in GatewayAiSetupClient.

  • Cause text. A settled result with status: "error" and no accepted activationRejection keeps Phase = Uncertain, because the Gateway schema says such an error can follow committed writes and that "the top-level error retains their detail". The client now raises that error text instead of a fixed sentence. The page already sanitizes the detail and caps it at 2048 characters.
  • Release. The Gateway returns a done: true result only after its runner has settled, and purges the wizard session before it responds (wizard.next in src/gateway/server-methods/wizard.ts). wizard.next and wizard.cancel for that session can therefore only answer "wizard not found". For that one case, Refresh and Cancel now read openclaw.setup.detect instead. If setup was incomplete before the attempt and still is, no route was promoted and the attempt becomes Rejected. Anything else stays Uncertain and is never replayed. Lost replies, non-terminal sessions, status: "done" without a receipt, and an unknown rejection disposition all keep today's behavior.
  • Canonical Claude CLI receipt. The Gateway offers its Claude CLI runtime as candidate kind claude-cli with model claude-cli/<model> and saves it as anthropic/<model> (setup-inference-activate.ts, case claude-cli). The Gateway's web client adopts the receipt's model; the Windows client compared strings. Exactly that one mapping is now accepted. Every other route must still match exactly.

The earlier review on #2112 recommended restoring diagnostics first and treating retry separately. The cause text is that part. The release is the part that needs maintainer judgment: it relies on the settled-session ordering above plus an authoritative read, not on the absence of a receipt. I am happy to split it into its own PR if that is easier to review.

Evidence

Real behavior proof. Clean Hyper-V guest restored from a checkpoint for each pass, Windows 11 Pro 26H2 build 26300.9974, Gateway OpenClawFoundation.OpenClawGateway_2026.11.11081.0 installed by Companion setup from the Store (isolated session). Unsigned local installers from scripts\build-inno-local.ps1 -Arch x64 -Fast with RequireSignedCleanupHost=false.

The "after" screenshots come from one build that contains this PR and #2394 (feat: use your existing Claude Code sign-in with an isolated native Gateway) together (installer sha256 986A70A7...2E21BE22, base 8d31176d). The detected "Claude Code" choice only appears when Claude Code exists in the Gateway's agent account, which that other change provides.

Before After
Cause before Base build 8d31176d: generic sentence only. after The Gateway's text is shown, still "not confirmed".
Leaving the dialog before Cancel ends in "wizard not found" and the dialog stays (build with only the cause change). after "Check again" returns to the choices: "The provider could not activate this model. Refresh to choose again."
Detected Claude Code before "The gateway activated a different model than the selected route." (earlier revision without this fix). after Detected choice selected, activation accepted. The Gateway then reports configured

Regression tests. Each new behavior test was seen failing without the product change.

  • SettledErrorWithoutRejection_ReportsGatewayCauseWithoutReleasingTheAttempt: failed with Expected: "Claude CLI was not found on PATH..." Actual: "Setup ended without an authoritative acti...".
  • SettledErrorWithUnchangedSavedSetup_IsReleasedWithoutReachingThePurgedSession (Refresh and Cancel): released to Rejected, no wizard.cancel, no further wizard.next, and a second start is allowed.
  • Stays Uncertain: saved setup changed, a route was already configured (same model name), the read-back fails, status: "done" without receipt, unknown rejection disposition.
  • CliRuntimeCandidate_AcceptsItsCanonicalProviderReceiptAndVerifiesThatRoute, plus four receipts that must still be refused (other model, other provider for claude-cli, a kind-named provider that is not Claude CLI, anthropic/ for a non Claude kind).
  • Mounted page: SettledErrorWithoutRejection_ShowsGatewayCauseWithoutCompletionOrAutomaticRetry and SettledErrorWithoutRejection_CheckAgainReleasesTheAttemptForAnExplicitRetry.

Validation at head 7e5a6a31 (this branch alone, clean tree, Windows 11 x64):

Command Result
./build.ps1 exit 0
dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore 6180 passed, 0 failed, 28 skipped
dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restore 7081 passed, 0 failed, 0 skipped
dotnet test ./tests/OpenClaw.SetupEngine.Tests/OpenClaw.SetupEngine.Tests.csproj --no-restore 2692 passed, 0 failed, 4 skipped
dotnet test ./tests/OpenClaw.Tray.UITests/OpenClaw.Tray.UITests.csproj -r win-x64 --no-restore --filter "(FullyQualifiedName~OnboardingAiPageTests|FullyQualifiedName~NativeSharedFlowTests)&<CI lane category exclusions>" 145 passed, 0 failed, 0 skipped

Independent review. A separate review agent read the diff and its owners twice. Its findings led to two narrowings now in this PR: the receipt mapping is limited to claude-cli to anthropic, and the release applies only while setup is incomplete.

Not verified / blocked

  • Native proof (NativeOnboardingProof) and accessibility test categories were not run.
  • The proof build contained both PRs. This branch alone was validated by tests, not by a separate guest run.
  • No Gateway log excerpt was kept for the final guest run.
  • In the guest, Companion's existing finalization step (openclaw config set gateway.nodes.commands.allow ...) was sometimes refused by the Gateway CLI with "Gateway lock owner identity could not be verified. No local mutation was attempted." A direct test showed the same refusal 2 times out of 10 in the first minute after a Gateway restart, with none of this PR's code involved. It is not addressed here.
  • Restart, sleep, uninstall, SmartScreen, a real GPU, ARM64, and signed or Store Companion builds were not exercised.

Required proof pools

  • windows-winui-interactive: the AI setup dialog's error detail and its recovery behavior changed. Current-head screenshots from a clean Windows 11 guest are under Evidence.

When the Gateway settles a provider wizard with an error and no activation
rejection, Companion showed only "The setup outcome is not confirmed" and
then could not leave that state: wizard.cancel and wizard.next answer
"wizard not found" because the Gateway purges a settled session.

- Raise the Gateway's own error text for a settled error, so the dialog
  shows the cause (for example "Claude CLI was not found on PATH").
- On Check again or Cancel, read the saved setup back instead of calling
  the purged session. When setup was incomplete before the attempt and
  still is, no route was promoted and the attempt is released as rejected.
  An attempt made while a route was already configured stays uncertain.
- Accept the Gateway's canonical receipt for its Claude CLI runtime: the
  candidate is offered as "claude-cli/<model>" and saved as
  "anthropic/<model>". Every other route must still match exactly.

Related: openclaw#2112
Copilot AI balanced review requested due to automatic review settings November 28, 2026 14:41
@clawsweeper

clawsweeper Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. impact:auth-provider This issue is about auth, provider routing, model choice, or SecretRef resolution. impact:ux-friction User-facing flow adds avoidable confusion or support burden without fully blocking progress. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 28, 2026
@clawsweeper clawsweeper Bot added proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 28, 2026
@clawsweeper

clawsweeper Bot commented Nov 28, 2026

Copy link
Copy Markdown

Codex review: needs real behavior proof before merge.

What this changes

This PR exposes provider setup errors, permits retry after selected first-run failures, and recognizes Claude CLI’s canonical activation receipt.

Example: Claude CLI is missing during first-run provider setup.

  • Before: Companion hides the cause, and Cancel reaches a purged wizard session.
  • After: Companion displays the missing-CLI explanation, and Check again returns to provider choices when saved setup remains incomplete.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) Focused implementation and useful regressions support the repair, with a minor diagnostic defect, unresolved recovery direction, and incomplete runtime attribution.
Proof confidence 🦪 silver shellfish (2/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🐚 platinum hermit (4/6) 1 actionable review finding remain.

Product

Kind: Bug fix · Worth it: Needs a maintainer decision · Fix scope: Partial
User problem: Provider setup hides actionable failures, leaves users trapped in recovery, and rejects Claude CLI’s canonical model receipt.
Reason: Diagnostics and receipt recognition have clear value, but retry classification changes an intentional owner-built contract; the isolated-account limitation remains outside this PR.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open: this PR addresses failures still present on main, but its read-back-based retry policy needs an owner decision.

Reviewed head: 7e5a6a31823fd44c5c509c6cc3d1f0deda483682
Owner decision: Required. See Decision needed.

Decision needed

  • Question: May an unchanged, incomplete setup read release a settled generic provider error without the Gateway’s activationRejection receipt?
  • Recommendation: Separate recovery from the diagnostic repair: Land error visibility and canonical receipt recognition separately, retaining the existing recovery guard until the Gateway owner agrees on the release contract.
  • Why: The PR explains its narrower first-run inference, but the authoritative schema explicitly reserves recovery release for finalized rejection and no maintainer has approved this alternative.

Before merge

  • Add real behavior proof - The inspected Windows guest screenshots demonstrate cause visibility, return to choices, and a configured canonical model, but their build combines this PR with the paired credential-sharing proposal on an earlier base; branch-only runtime attribution and an existing-profile upgrade run are absent, so the contributor should supply suitable screenshots or redacted transport logs without IPs, keys, or non-public endpoints. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.

Findings

  • [P3] Describe unconfirmed setup without claiming its saved state changed — src/OpenClaw.SetupEngine/GatewayAiSetupClient.cs:324-325

Tests

  • Missing end-to-end proof: Provide attributable proof for the pinned branch’s recovery and canonical-receipt paths, plus a latest-stable upgrade run showing an existing configured profile remains intact and cannot be released by this recovery rule.
Agent review details

How this fits together

GatewayAiSetupClient translates authenticated Gateway discovery and wizard responses into setup-page state, recovery actions, and exact-model verification.

flowchart LR
  A[Provider setup page] --> B[GatewayAiSetupClient]
  B --> C[Authenticated Gateway transport]
  C --> D[Gateway wizard runner]
  D --> E[Provider and saved configuration]
  C --> F[Setup discovery and verification]
  F --> B
Loading

Technical review

Best possible solution:

Keep diagnostics and Claude receipt normalization in the existing client, with recovery release governed by an agreed Gateway contract.

Do we have a high-confidence way to reproduce the issue?

Main retains the generic terminal-error exception and exact-string receipt comparison; the report and inspected before screenshots corroborate both failures.

Is this the best way to solve the issue?

The diagnostic and receipt fixes use the right owner, while treating saved-state absence as rejection changes the existing recovery contract.

Full review comments:

  • [P3] Describe unconfirmed setup without claiming its saved state changed — src/OpenClaw.SetupEngine/GatewayAiSetupClient.cs:324-325
    When setup already had demo/model and the read-back returns exactly the same configured state, TryReleaseSettledErrorAsync deliberately returns false because the initial setup was complete. Refresh and Cancel then display SavedSetupChanged, incorrectly telling the user that saved setup changed. The new already-configured-route test exercises this input. Use wording that describes the unconfirmed outcome without asserting drift, or distinguish the rejection reasons.
    Confidence: 0.99

Overall correctness: patch is correct
Overall confidence: 0.87

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 1cd641de9195.

Provenance checked

  • Provider diagnostics keeps the original intent (7357834: Preserve Gateway verification failures as bounded, sanitized diagnostic details using the existing setup presentation.)
  • Uncertain terminal outcomes and recovery release changes intended behavior with a stated reason (3eed1f1: Keep uncertain writes blocked from replay and require authoritative activation outcomes; the PR explains replacing that requirement for settled first-run errors with saved-state reconciliation.)
  • Exact selected-model verification keeps the original intent (3eed1f1: Prevent another model or utility route from completing main-assistant setup; the new exception preserves model identity while accepting Claude’s canonical provider prefix.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Pinned change and current main: GitHub main remains at the pinned base; the introduced diff adds terminal-error diagnostics, saved-state recovery, and narrowly scoped Claude receipt normalization. (src/OpenClaw.SetupEngine/GatewayAiSetupClient.cs:261, 7e5a6a31823f)
  • Existing diagnostic presentation: ReportFailure displays the exception message; ShowError sanitizes appended detail and limits it to 2048 characters, so raising the retained Gateway cause uses the existing presentation owner. (src/OpenClaw.SetupEngine.UI/Pages/AiSetupPage.xaml.cs:1376, 7e5a6a31823f)
  • Authoritative dependency contract: The client invokes Gateway-owned wizard methods, and the PR explicitly relies on their semantics, establishing this dependency’s applicability; its root policy was read, and its wizard schema expressly reserves recovery release for a finalized activation rejection because generic errors can follow committed writes. (packages/gateway-protocol/src/schema/wizard.ts:148, 239a05edbf1e)
  • Terminal-session ordering is supported: wizard.next awaits admitted-runner settlement and purges the session before returning a terminal result; this supports avoiding subsequent calls to that purged session but does not itself establish the proposed rejection classification. (src/gateway/server-methods/wizard.ts, 239a05edbf1e)
  • Claude receipt normalization: The claude-cli staging branch resolves its runtime’s canonical provider and returns that provider-qualified model reference, supporting the distinction between candidate identity and activation identity. (src/system-agent/setup-inference-activate.ts:175, 239a05edbf1e)
  • Recovery boundaries and diagnostic counterexample: Added tests distinguish unchanged incomplete setup, changed setup, an already-configured route, failed read-back, and unrelated receipts; the already-configured test also demonstrates the input that now produces an inaccurate changed-setup message. (tests/OpenClaw.SetupEngine.Tests/GatewayAiSetupClientTests.cs:268, 7e5a6a31823f)

Likely related people:

  • Joel: Raw commit 7357834 adds src/OpenClaw.SetupEngine/GatewayAiSetupClient.cs:35 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 735783459efa; files: src/OpenClaw.SetupEngine/GatewayAiSetupClient.cs)

Preflight source

Source 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

Metric Value Why it matters
Production and regression scope Production +69/-2 lines; tests +222/-2 lines Growth stays within the existing client and test fixtures, covering distinct recovery states, receipt identities, and mounted presentation.

Labels

Label changes:

  • add proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Label justifications:

  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.

Rank-up moves

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

  • Tie shipped-path recovery and receipt evidence to the reviewed branch and verify existing-profile upgrade behavior.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 28, 2026, 10:13 AM ET / 15:13 UTC.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

impact:auth-provider This issue is about auth, provider routing, model choice, or SecretRef resolution. impact:ux-friction User-facing flow adds avoidable confusion or support burden without fully blocking progress. P2 Normal priority bug or improvement with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants