Skip to content

fix(setup): activate the exact prepared local model - #119050

Merged
vincentkoc merged 9 commits into
mainfrom
fix/ollama-setup-handoff-20260804
Aug 4, 2026
Merged

vincentkoc merged 9 commits into
mainfrom
fix/ollama-setup-handoff-20260804

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Aug 4, 2026 •

Copy link
Copy Markdown
Member

Closes #119049

What Problem This Solves

Fixes an issue where users completing guided local-model setup could see a misleading provider-not-ready failure when the prepared model was installed but idle, or could activate a different model when multiple local models were available.

Why This Change Was Made

Provider-owned setup already knows the exact model it prepared. This change preserves that model reference through the additive terminal wizard result and activates that exact route before showing success.

Ollama keeps resident-only ambient discovery, so passive detection still cannot wake an idle model and cause surprise memory allocation. Explicit setup completion may activate only the model that setup configured or a model that is still resident.

User Impact

Ollama, LM Studio, and llama.cpp setup now hand the exact prepared model into live verification instead of re-detecting and guessing. Users see the existing verified-success dialog only after that model returns a real response.

Evidence

  • Ollama provider/setup: 143 tests passed.
  • Gateway protocol, wizard session, and setup RPC: 54 tests passed.
  • Generated protocol gate: Swift/Kotlin generation, since guard, and bundled protocol suite passed (202 tests).
  • Model Setup UI state/orchestration: 19 tests passed.
  • macOS onboarding exact-model, restart, fallback, and provider-kind coverage: 91 tests passed.
  • Focused Chromium E2E: Ollama recovery flow passed; 4 unrelated scenarios skipped.
  • Real Ollama 0.32.5 run: ollama/qwen3:0.6b returned exactly pong through openclaw infer model run.
  • Memory cleanup: /api/ps was empty before the run and empty after ollama stop qwen3:0.6b.
  • Real LM Studio 0.4.20 run: with only qwen3-0.6b loaded at 32K context, guided setup returned the exact lmstudio/qwen3-0.6b route and a direct completion returned Pong!; the model was unloaded and the server stopped afterward.
  • Formatting and git diff --check: clean.
  • Review findings resolved: macOS now consumes preparedModelRef without a second detection pass, older gateways retain the detection fallback, and provider choice IDs use the canonical percent-encoded kind on web and macOS.
  • Autoreview after the review fixes: clean, 0.99 overall.
  • Blacksmith Testbox changed gate: passed against exact head 03ba86544e8f3051a1275a4b4a4646e10078a9f9 in 30m38s (run).
  • Blacksmith Testbox exact test typecheck passed against 3e96bdc1573b6c96d55929afdce76e0110647f5c (run).
  • Current exact head: 8a682521136, including a signed merge from current main.
  • Current-head macOS proof: 91 focused onboarding tests passed; SwiftLint, SwiftFormat, native i18n verification, and git diff --check passed.
  • Fresh CI and ClawSweeper re-review run on the current exact head.

Screenshots

This patch changes the setup handoff rather than layout. The current Models capture is byte-identical to the hosted asset below; the setup and verified-success dialogs render the same current UI states.

Local providers on the Models surface

Ollama, llama.cpp, and LM Studio on the Models surface

Ollama setup mode

Ollama local setup mode selection

Exact model verified

Ollama connection verified with a start chatting action

Repair Notes

  • Root cause: openclaw.setup.prepare.start persisted provider setup but discarded agentModelOverride; the UI then reconstructed the outcome through ambient detection.
  • Architectural owner: the generic wizard terminal handoff carries the producer-owned prepared model; the provider remains responsible for validating that exact model during activation.
  • Canonical fix: one exact prepared-model path, with re-detection retained only as compatibility fallback for older gateways/providers.
  • Removed failure mode: setup no longer depends on Ollama /api/ps rediscovery after preparing an idle model.
  • Removed duplicate policy: web and macOS now derive provider-auto kinds through one canonical encoder per client instead of raw interpolation.
  • Sibling coverage: the generic handoff removes LM Studio and llama.cpp model-identity drift across web and macOS.
  • Production LOC: +396/-170, net +226. Tests are +331/-47; generated protocol/i18n inventory is +19/-7. The production increase is the additive protocol/owner-boundary contract, exact macOS handoff and restart reconciliation, and Ollama's explicit configured-or-resident activation validation.

Disclosure

AI-assisted implementation. I reviewed the full diff, provider contracts, test coverage, and live behavior.

@vincentkoc vincentkoc self-assigned this Aug 4, 2026
@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui gateway Gateway runtime extensions: ollama size: M maintainer Maintainer-authored PR labels Aug 4, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review August 4, 2026 01:46
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 4, 2026, 2:34 AM ET / 06:34 UTC.

ClawSweeper review

What this changes

The PR carries a provider-prepared local model through the Gateway wizard so web and macOS activate that exact model instead of rediscovering a local candidate.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep this maintainer-owned PR open for final merge review: the exact-model handoff addresses the current setup failure without a new actionable finding, while macos-swift is still running on the head.

Priority: P1
Reviewed head: 70d75c6fa3d022fb0de55640c4aca11baecd8175
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch has coherent owner-boundary coverage and credible direct-provider evidence, with only the active native check remaining before merge.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: The author is a repository member, so the external-contributor proof gate does not apply; the PR body nevertheless reports direct Ollama and LM Studio runs.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The author is a repository member, so the external-contributor proof gate does not apply; the PR body nevertheless reports direct Ollama and LM Studio runs.
Evidence reviewed 6 items Current-main failure path: The current path writes the prepared provider configuration but drops the returned model override; the web client then runs fresh detection and requires a detected candidate before activation.
Ollama preserves passive-discovery safety: At the PR head, explicit activation accepts an exact model only when setup configured it or it remains resident; ambient discovery remains limited to resident models.
Additive protocol contract: The proposed optional terminal wizard field carries the prepared model without changing existing result fields; older clients can ignore it and newer clients retain their detection fallback when it is absent.
Findings None None.
Security None None.

How this fits together

Guided local-model setup runs provider-owned preparation through the Gateway wizard, then web or macOS verifies a model before showing a ready state. This change preserves the provider-selected route across that handoff.

flowchart LR
  A[Guided local setup] --> B[Provider prepares exact model]
  B --> C[Gateway wizard terminal result]
  C --> D[Web or macOS client]
  D --> E[Exact model activation]
  E --> F[Verified ready state]
Loading

Decision needed

Question Recommendation
Should this maintainer-owned setup/protocol change merge after macos-swift succeeds on the exact head and mergeability is refreshed? Approve after exact-head macOS validation: Merge once macos-swift succeeds for the current head and GitHub still reports a clean merge.

Why: The patch crosses provider setup, Gateway protocol, and native-client activation; its protected maintainer status requires an explicit human merge decision despite no code finding.

Before merge

  • Resolve merge risk (P1) - This changes the client/Gateway/provider setup handoff; merge only after the in-progress exact-head macOS check completes and GitHub refreshes mergeability against current main.
Agent review details

Security

None.

PR surface

Source +144, Tests +187, Other +190. Total +521 across 27 files.

View PR surface stats
Area Files Added Removed Net
Source 10 199 55 +144
Tests 12 218 31 +187
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 5 329 139 +190
Total 27 746 225 +521

Review metrics

Metric Value Why it matters
Wizard protocol surface 1 optional terminal-result field added The new prepared-model value crosses Gateway, web, and macOS clients, so old/new client fallback behavior matters before merge.
Production versus tests production +396/-170; tests +331/-47 The production growth implements the provider-to-client ownership handoff and is accompanied by focused regression coverage.

Stored data model

Persistent data-model change detected: serialized state: src/wizard/session.test.ts, serialized state: src/wizard/session.ts, serialized state: ui/src/pages/model-setup/state.test.ts, serialized state: ui/src/pages/model-setup/state.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Land after native validation (recommended)
    Accept the additive client/Gateway compatibility path once the exact-head macOS check succeeds and mergeability is refreshed.
  2. Pause on a contract failure
    If native validation exposes a generated-model or fallback incompatibility, pause this PR and repair that exact contract before merge.

Technical review

Best possible solution:

Keep the optional wizard handoff and old-Gateway detection fallback, then land after exact-head macOS validation confirms the generated client contract.

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

Yes—source reproduction is high confidence: current main discards the prepared model at the Gateway terminal handoff, then the client re-detects a candidate; an installed but idle Ollama model is intentionally absent from that ambient discovery.

Is this the best way to solve the issue?

Yes—the provider records the authoritative selected model at its producer boundary, and clients activate that route directly while retaining the older-Gateway fallback instead of guessing from rediscovery.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 52c9448cb505.

Labels

Label justifications:

  • P1: Guided local-model setup can currently fail after preparing an idle model or select a different available model.
  • merge-risk: 🚨 compatibility: The PR changes a Gateway wizard result consumed by web and macOS clients and alters provider setup activation routing.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The author is a repository member, so the external-contributor proof gate does not apply; the PR body nevertheless reports direct Ollama and LM Studio runs.

Evidence

What I checked:

  • Current-main failure path: The current path writes the prepared provider configuration but drops the returned model override; the web client then runs fresh detection and requires a detected candidate before activation. (src/gateway/server-methods/system-agent.ts:417, 52c9448cb505)
  • Ollama preserves passive-discovery safety: At the PR head, explicit activation accepts an exact model only when setup configured it or it remains resident; ambient discovery remains limited to resident models. (extensions/ollama/index.ts:247, 70d75c6fa3d0)
  • Additive protocol contract: The proposed optional terminal wizard field carries the prepared model without changing existing result fields; older clients can ignore it and newer clients retain their detection fallback when it is absent. (packages/gateway-protocol/src/schema/wizard.ts:105, 70d75c6fa3d0)
  • Exact-head continuity: The only commit after the prior reviewed head is a merge from main; its changed paths do not overlap this PR's setup, protocol, UI, macOS, or Ollama files. (extensions/ollama/index.ts:247, 70d75c6fa3d0)
  • Feature provenance: The base prepare-wizard path is attributed to the recent local-onboarding work, making Peter Steinberger a relevant routing contact rather than an inferred regression source. (src/gateway/server-methods/system-agent.ts:383, a78f2c40bf6f)
  • Submitted behavior evidence: The PR body reports direct Ollama and LM Studio completion runs, plus focused web, Gateway, protocol, and macOS coverage; the remaining visible exact-head check is macos-swift. (70d75c6fa3d0)

Likely related people:

  • Vincent Koc: Introduced the merged local-model onboarding feature and authored the focused setup-handoff commits. (role: local-setup feature owner and recent contributor; confidence: high; commits: 94b85cba5fd8, dea04651b9c2, 8a6825211366; files: src/gateway/server-methods/system-agent.ts, extensions/ollama/index.ts, apps/macos/Sources/OpenClaw/OnboardingAISetup.swift)
  • Peter Steinberger: Git blame attributes the baseline Gateway and web prepare-flow lines to recent local-onboarding work. (role: recent setup-path contributor; confidence: high; commits: a78f2c40bf6f; files: src/gateway/server-methods/system-agent.ts, ui/src/pages/model-setup/model-setup-page.ts)
  • Michael Christenson II: Recently maintained Ollama onboarding reachability, which shares the provider-discovery boundary affected here. (role: adjacent Ollama onboarding contributor; confidence: medium; commits: 7f7a709b1d0e; files: extensions/ollama/index.ts)

Rank-up moves

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

  • Wait for macos-swift to complete successfully on the current head, then refresh mergeability against current main.

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 (2 earlier review cycles)
  • reviewed 2026-08-04T04:13:33.283Z sha 8a68252 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-04T04:22:39.483Z sha 8a68252 :: needs maintainer review before merge. :: none

* origin/main:
  test(qa): prove agent tool approval controls (#119029)
  docs(agents): require exact-head ClawSweeper re-review after post-review pushes (#119069)
  fix(qa): provision ffmpeg for Playwright scenarios (#119064)
  test(qa): repair scenario catalog baselines (#119062)
  test(qa): prove agent session scope continuity (#119032)
  test(qa): prove workspace mutation tools (#119021)
  fix(cli): honor local port in gateway call (#119046)
  test(xai): cover playback mark overflow
  fix(xai): bound realtime playback marks
@openclaw-barnacle openclaw-barnacle Bot added app: macos App: macos size: L and removed size: M labels Aug 4, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

* origin/main:
  test(qa): cover packaged browser profiles (#119043)
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Aug 4, 2026
* origin/main:
  fix: preserve live updater failure diagnostics (#119096)
  fix: recover new-session models through Gateway startup (#119120)
  test(qa): cover instruction profile artifacts (#119078)
  fix(telegram): record automatic delivery message ids
  test(qa): cover memory promotion safety (#119093)
  test(qa): prove overflow compaction pruning (#119033)
  fix(tool-search): preserve deferred MCP failures (#118363)
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@vincentkoc
vincentkoc merged commit 6ce6dd3 into main Aug 4, 2026
194 of 196 checks passed
@vincentkoc
vincentkoc deleted the fix/ollama-setup-handoff-20260804 branch August 4, 2026 06:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: macos App: macos app: web-ui App: web-ui extensions: ollama gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Local model setup loses the exact prepared model before activation

1 participant