Skip to content

Add OpenClaw local models and unified model selection - #232

Merged
Angnuo (angnuoli) merged 2 commits into
mainfrom
angnuoli-local-model-support
Oct 13, 2026
Merged

Angnuo (angnuoli) merged 2 commits into
mainfrom
angnuoli-local-model-support

Conversation

@angnuoli

@angnuoli Angnuo (angnuoli) commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Add experimental local-model support using OpenClaw's official llama.cpp provider, with explicit Qwen3.5 4B/9B downloads and a unified cloud/local model-selection experience. Keep provider configuration, global defaults, and per-conversation overrides separate. Model selection does not send an inference or tool-use test, and switching an existing cloud default no longer unconditionally restarts the Gateway.

This includes the complete integration and the follow-up Windows preparation, selection feedback, popover stability, and safe session-selection recovery fixes exercised in the desktop.

Related Issue

N/A — user-requested feature and UX iteration.

Changes

  • Add typed, narrow local-model and session-model IPC services with operation recovery, cancellation, revision checks, explicit Agent ownership, and existing sandbox/configuration guards.
  • Offer Qwen3.5 4B Q4_K_M and 9B Q4_K_M managed presets. Require explicit first-use download consent, reuse verified cached weights, and retain advanced loopback-server connections. The installer prepares the pinned provider but does not download weights or the inference runtime.
  • Separate provider management from default/session selection. Preserve other providers, credentials, fallbacks, model policy, and Agent/session overrides; keep multi-Agent ownership explicit before the first chat message.
  • Share collapsible, searchable provider groups between chat and Settings. Show inline switching feedback for ready models, reserve dialogs for preparation/errors/recovery, and publish complete catalogue snapshots to avoid popover jumps.
  • Use revision-guarded config.patch plus applied-revision confirmation for cloud default changes instead of a cold Gateway restart. Read prepared Copilot catalogue metadata rather than triggering full discovery.
  • Fix the reviewed unknown-selection latch: completed RPCs can reconcile the actual saved model, while genuinely ambiguous writes remain fenced until the original owned Gateway process is proven stopped. Chat and Settings expose explicit recovery; a restart requires confirmation, verifies owned-process shutdown, and never replays the patch or rolls back the saved choice. A WebSocket reconnect or matching model value alone cannot unlock a potentially late write. Normal model switches still do not restart the Gateway.
  • Add source-hash-pinned, in-memory Windows compatibility adapters for fs-safe copy/cleanup and exact-model setup/runtime publication. Preserve identity/hash checks, bounded transient-lock retries, and upstream pre/post-install validation; do not edit installed OpenClaw/provider source files.
  • Update English/Chinese documentation, installer disclosure, packaging resources, and third-party notices; add unit and opt-in real-Gateway integration coverage.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • CI/CD or build configuration change
  • Refactoring (no functional changes)

Testing

  • Tests pass locally (cd desktop && npm run test)
  • Renderer tests pass locally (cd desktop/renderer && npm run test)
  • Build succeeds (cd desktop && npm run build)
  • Manual testing performed (describe below)

Commands below use PowerShell path syntax. The complete build includes npm run build in the desktop package. Full Node suites and the full build were rerun for recovery follow-up commit a2622ef.

Command Result
Set-Location .\desktop; npm run test 1,356 passed, 11 skipped, 1 pre-existing failure in startup-order.test.ts. The unchanged test searches for startGateway().catch; base commit 6f080a0 already uses startApplicationServices().catch. The same string check fails against the base source.
Set-Location .\desktop\renderer; npm run test 471 passed.
.\.venv\Scripts\python.exe -m unittest discover -s tests -v 290 passed before the recovery follow-up; Python files were not changed by that follow-up.
Set-Location .\desktop; npm test -- src\session-model-service.test.ts src\session-model-ipc.test.ts src\session-model-preload.test.ts src\gateway-lifecycle.test.ts src\default-model-selection.test.ts src\local-model-service.test.ts 171 passed, including unknown-outcome recovery, definitive failures, stopped-process proof, changed profiles, stale consent, active/concurrent operations and existing local selection.
Set-Location .\desktop; npm test -- src\session-model-gateway.integration.test.ts 3 passed with MICROCLAW_TEST_OPENCLAW_ENTRY set: single-Agent and explicit multi-Agent session/default switching, safe legacy-ownership rejection, and real managed-Gateway replacement after simulated loss before delivery and after commit. No replay, rollback, configuration change or inference during recovery.
Set-Location .\desktop; npm test -- src\local-model-preparation.integration.test.ts Passed with the documented opt-in provider/cache environment variables: exact 4B preparation using private copies of cached weights, official runtime installation, and no inference or default-model change.
powershell -NoProfile -ExecutionPolicy Bypass -File .\build.ps1 Passed: desktop, portable ZIP, installer ZIP and setup EXE. Local artifacts are unsigned because Trusted Signing is not configured. Outputs: MicroClawSetup.exe 231.9 MiB; MicroClawInstaller.zip 234.9 MiB; microclaw-portable.zip 213.3 MiB; MicroClawInstaller.exe 5.0 MiB.
npm run lint --prefix desktop\renderer Passed with warnings, no errors, before the recovery follow-up; targeted recovery/UI lint also passed afterward.
npm run lint Blocked by two pre-existing main-process lint errors: chat-attachments.ts control-character regex and unused readJsonObject in openclaw-upgrade-recovery.ts. These offending constructs are unchanged.
npm run format:check Blocked by 33 pre-existing files, all confirmed unchanged from the base commit, including vendored Windows Node source.
python -m ruff check . Blocked by existing findings in test_rednote_publisher_skill.py and vendored Windows Node scripts.
python -m ruff format --check . Blocked by 10 existing formatting files. Changed Python files pass targeted Ruff lint/format checks.
git diff --cached --check Passed before both commits.

Installed Windows desktop and isolated Electron/Gateway checks:

  • Confirmed first-use consent, retained cached 4B/embedding weights, and runtime completion; exercised a native Windows sharing lock and verified bounded runtime-publication recovery.
  • Verified ready-model selection creates zero preparation overlays, while failures and first-use consent remain visible/actionable. Checked modal hit-testing at 1600×1000 and 960×720.
  • Verified first-open/reopen model-popover geometry remains stable with staggered catalogue responses and without model mutations or inference.
  • Real isolated hot default switches completed without reconnecting or calling the inference endpoint; the installed same-default GPT-6 Sol confirmation completed in 658 ms with an unchanged config hash and Gateway PID. This is configuration-application timing, not model response latency.
  • Visible isolated Electron verified recovery cancellation performs no action, confirmed recovery submits once, and both cloud/local controls become usable again with refreshed capabilities; no model-selection/configuration/inference call was made by that UI check.
  • Installed updates verify package hashes and protected configuration/model/credential/transcript/database files. No user data, model binaries, logs, credentials or installer artifacts are included in this PR.

CPU inference can still be slow, especially for long Agent/tool contexts and the 9B preset. The compatibility adapters intentionally fail closed if the pinned upstream source changes.

Checklist

  • My code follows the coding guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code where necessary
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or my feature works
  • New and existing unit tests pass locally with my changes

Unchecked validation items are explained above; unrelated baseline cleanup is intentionally excluded.

Angnuo (angnuoli) and others added 2 commits October 12, 2026 17:15
Integrate the official llama.cpp provider with explicit Qwen 4B/9B preparation, scoped model selection, stable provider pickers, and revision-checked hot default switching. Preserve cloud configuration and sandbox boundaries, with pinned Windows runtime compatibility fixes and regression coverage.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Distinguish completed replies from writes that may still be running. Add explicit, generation-bound recovery that verifies managed Gateway shutdown when necessary, reads saved state without retry or rollback, and restores chat/settings controls.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@angnuoli
Angnuo (angnuoli) merged commit 6de7bbf into main Oct 13, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant