Skip to content

refactor(llama-cpp): use one provider for managed and existing servers - #126434

Merged
steipete merged 3 commits into
mainfrom
steipete/strange-wu-c73591
Aug 19, 2026
Merged

steipete merged 3 commits into
mainfrom
steipete/strange-wu-c73591

Conversation

@steipete

@steipete steipete commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Related: #125781
Related: #116765

What Problem This Solves

The newly added external llama-server path represented managed and existing servers as two different LLM providers even though both use the same llama-server protocol, OpenAI-compatible transport, model discovery, tool-schema policy, and model semantics. Operators would have to change model namespaces when only process ownership changed, while the plugin maintained duplicate setup, discovery, catalog, auth, and documentation surfaces.

Why This Change Was Made

This change makes llama-cpp the single provider identity and treats server ownership as provisioning state. Interactive setup now offers Managed local server and Existing llama-server for the same llama-cpp/* model namespace; the presence of localService remains the canonical signal that OpenClaw owns the process.

The refactor also moves guarded /models plus llama.cpp /props discovery into the shared self-hosted owner, deletes the unshipped llama-server/* namespace and duplicate registration, and keeps endpoint credential isolation, explicit Authorization precedence, router metadata, dynamic models, structured output, managed embeddings, and custom OpenAI-compatible llama-server routes intact.

The removed provider namespace had not appeared in a release tag, so no compatibility alias or migration is retained.

Production LOC: +808/-954 (net -146) | Tests: +689/-846 (net -157) | Docs: +166/-378 (net -212)

AI-assisted. I reviewed the implementation, architecture, and proof directly.

User Impact

Operators can switch between an OpenClaw-managed llama-server and an already-running local, private, or remote llama-server without changing provider or model references. Both modes use llama-cpp/<model>.

Existing managed setup, GGUF downloads, local embeddings, and supervisor behavior remain unchanged. Existing-server setup still discovers models and capabilities automatically and prevents credentials from crossing endpoint changes.

Evidence

Focused source tests:

node scripts/run-vitest.mjs extensions/llama-cpp src/plugins/provider-self-hosted-discovery.test.ts src/plugins/provider-self-hosted-setup.test.ts extensions/lmstudio/src/setup.test.ts packages/ai/src/providers/openai-completions.test.ts
4 Vitest shards passed; 239 tests passed

Post-rebase exact-head sanity:

node scripts/run-vitest.mjs extensions/llama-cpp/src/external-server/auth.test.ts extensions/llama-cpp/src/external-server/discovery.test.ts extensions/llama-cpp/src/external-server/setup.test.ts src/plugins/provider-self-hosted-discovery.test.ts
4 files passed; 34 tests passed

node scripts/check-changed.mjs
passed after conflict resolution; final test-only follow-up also passed its scoped changed gate

Plugin and SDK contracts:

pnpm test:contracts:plugins
42 files passed; 1,033 tests passed

pnpm plugin-sdk:surface:check
passed; 146 public SDK entrypoints verified

Local changed gates and build:

node scripts/check-changed.mjs
passed: format, typecheck, lint, SDK, dead-export, boundary, database, and import-cycle gates

pnpm check:docs
passed: 0 lint issues, 6,524 links checked, 0 broken, 1,180 config examples validated

pnpm build
passed; Control UI and all package/plugin build stages completed

Real llama-server proof:

Runtime: LM Studio llama.cpp backend 2.27.1
Model: Gemma 4 E4B GGUF
Endpoint: isolated loopback llama-server with 32,768-token context

OPENCLAW_LIVE_TEST=1 LLAMA_SERVER_LIVE_TEST=1 \
LLAMA_SERVER_LIVE_URL=http://127.0.0.1:<isolated-port>/v1 \
LLAMA_SERVER_LIVE_MODEL_ID=openclaw-live-gemma4 \
pnpm test:live -- extensions/llama-cpp/src/external-server/llama-server.live.test.ts

3 passed: discovery/concurrent generation, schema-constrained JSON, cancellation
1 skipped: the selected model template did not advertise tool calling

Autoreview:

Codex autoreview: clean; no accepted/actionable findings

@clawsweeper

clawsweeper Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@steipete
steipete marked this pull request as ready for review August 19, 2026 20:10
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime extensions: lmstudio extensions: llama-cpp size: XL maintainer Maintainer-authored PR labels Aug 19, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 19, 2026
@clawsweeper

clawsweeper Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 19, 2026, 4:17 PM ET / 20:17 UTC.

ClawSweeper review

What this changes

This PR unifies managed and operator-run llama.cpp servers under the llama-cpp provider and removes the unshipped llama-server provider namespace.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

Keep open: the consolidation has strong live behavior evidence, but it removes a released Plugin SDK export and can break installed third-party plugins at import time.

Priority: P2
Reviewed head: 73770a339948a5e9529e5d63c7f0b79f5059d631

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The branch has credible validation and a narrow, repairable compatibility blocker.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is not subject to the external-contributor proof gate; its body nevertheless includes a credible isolated live llama-server result.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is not subject to the external-contributor proof gate; its body nevertheless includes a credible isolated live llama-server result.
Evidence reviewed 6 items Changed public SDK export: The branch replaces the released removeProviderAuthProfilesWithLock export with a different helper at the established provider-auth subpath.
Released contract: Release v2026.7.1-2 exported removeProviderAuthProfilesWithLock from openclaw/plugin-sdk/provider-auth; removing it is a source-incompatible SDK change.
Public subpath: The package exports ./plugin-sdk/provider-auth, establishing the module path used by third-party plugins.
Findings 1 actionable finding [P1] Preserve the released provider-auth export
Security None None.

Live Verification

Command: pnpm openclaw models auth login --provider llama-cpp --method existing-server --help

Result: FAIL (partial) — step 2 expect_output llama-server-api-key: expected terminal output was not visible within 30 seconds: "llama-server-api-key"

pnpm openclaw models auth login --provider llama-cpp --method existing-server --help
runner@runnervm76f27:/tmp/clawsweeper-live-proof-126434-LJn4JT/target$ pnpm openclaw models auth login --provider llama-cpp --method existing-server --help
$ node scripts/run-node.mjs models auth login --provider llama-cpp --method existing-server --help
pnpm openclaw models auth login --provider llama-cpp --method existing-server --help
[openclaw] Building TypeScript (dist is stale: missing_build_stamp - build stamp missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
[log] ‹DIR›/a2ui.bundle.js  chunk │ size: 399.96 kB
[log] ‹DIR›/a2ui-v0.9.bundle.js  chunk │ size: 615.66 kB
[log]
[success] rolldown v1.2.0 Finished in 103.38 ms
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
[tsdown-build] invocation 1/2 finished in 0.7s
node_modules/web-tree-sitter/web-tree-sitter.js (2343:30) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2343:31 ]
      │
 2343 │           ASM_CONSTS[start] = eval(func);
      │                               ──┬─
      │                                 ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2366:32) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2366:33 ]
      │
 2366 │           moduleExports[name] = eval(func);
      │                                 ──┬─
      │                                   ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/playwright-core/lib/coreBundle.js (65821:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65821:29 ]
       │
 65821 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/playwright-core/lib/coreBundle.js (65828:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65828:29 ]
       │
 65828 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

[tsdown-build] invocation 2/2 finished in 13.8s
[plugin-control-plane-loads] verified 36 built modules with native require and checked doctor closures
runtime-postbuild: 10 phases completed in 4340ms (slowest: built plugin control-plane loads 3592ms)
│
◇

OpenClaw 2026.8.1 (73770a3) — All your chats, one OpenClaw.

Usage: openclaw models auth login [options]

Run a provider plugin auth flow (OAuth/API key)

Options:
  --agent ‹id›       Agent id (default: configured default agen
… output truncated …

Assertions:

  • FAIL expect_output: llama-server-api-key

How this fits together

The llama.cpp plugin turns operator setup into a model-provider configuration used by OpenClaw’s agent runtime. It either supervises a local server or discovers models from an existing server before agent requests use that provider.

flowchart LR
  Setup[Operator setup] --> Mode[Managed or existing server]
  Mode --> Config[llama-cpp provider config]
  Config --> Discovery[Model discovery]
  Config --> Runtime[Agent model requests]
  Mode --> Supervisor[Managed server supervisor]
  Discovery --> Runtime
Loading

Before merge

  • Preserve the released provider-auth export (P1) - removeProviderAuthProfilesWithLock is exported from openclaw/plugin-sdk/provider-auth in release v2026.7.1-2; removing it makes installed third-party plugins importing that public subpath fail at module load. Keep the old export, or introduce a versioned deprecation and migration before removing it.
  • Resolve merge risk (P1) - Merging removes a stable Plugin SDK named export, so installed third-party providers importing it can fail before their setup code runs.
  • Resolve merge risk (P1) - The local review tree could not resolve the supplied current-main object for a full three-way behavior comparison.
  • Complete next step (P2) - This maintainer-authored, protected PR needs its normal branch update for the concrete SDK finding rather than a separate repair job.

Findings

  • [P1] Preserve the released provider-auth export — src/plugin-sdk/provider-auth.ts:67
Agent review details

Security

None.

PR surface

Source -147, Tests -165, Docs -212. Total -524 across 41 files.

View PR surface stats
Area Files Added Removed Net
Source 19 808 955 -147
Tests 13 681 846 -165
Docs 9 166 378 -212
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 41 1655 2179 -524

Review metrics

Metric Value Why it matters
Production versus test delta production net -147; tests net -165; docs net -212 The refactor is net-reductive, but it changes provider and SDK compatibility surfaces that need review beyond LOC.
Provider identity migration 2 provider IDs reduced to 1 Managed and existing-server setup now share one persisted provider identity, making upgrade behavior material.

Stored data model

Persistent data-model change detected: serialized state: extensions/llama-cpp/src/external-server/discovery.test.ts, serialized state: extensions/llama-cpp/src/setup.test.ts, serialized state: src/plugins/provider-self-hosted-discovery.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Restore the released SDK export (recommended)
    Re-export removeProviderAuthProfilesWithLock from provider-auth and add focused public-surface coverage before merge.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Restore the released provider-auth export and add focused SDK compatibility coverage.

Technical review

Best possible solution:

Keep the unified provider design, but retain the released provider-auth export with a documented deprecation path while bundled callers migrate to narrower internals.

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

Yes — a plugin importing removeProviderAuthProfilesWithLock from the released openclaw/plugin-sdk/provider-auth path has a direct import failure on this branch.

Is this the best way to solve the issue?

No — moving bundled callers does not require deleting the released SDK export; preserve it with a deprecation path.

Full review comments:

  • [P1] Preserve the released provider-auth export — src/plugin-sdk/provider-auth.ts:67
    removeProviderAuthProfilesWithLock is exported from openclaw/plugin-sdk/provider-auth in release v2026.7.1-2; removing it makes installed third-party plugins importing that public subpath fail at module load. Keep the old export, or introduce a versioned deprecation and migration before removing it.
    Confidence: 0.97

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: A concrete third-party Plugin SDK compatibility break needs repair before this provider refactor can merge.
  • add merge-risk: 🚨 compatibility: The branch removes a named export available from the released provider-auth SDK subpath.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This maintainer-authored PR is not subject to the external-contributor proof gate; its body nevertheless includes a credible isolated live llama-server result.

Label justifications:

  • P2: A concrete third-party Plugin SDK compatibility break needs repair before this provider refactor can merge.
  • merge-risk: 🚨 compatibility: The branch removes a named export available from the released provider-auth SDK subpath.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This maintainer-authored PR is not subject to the external-contributor proof gate; its body nevertheless includes a credible isolated live llama-server result.

Evidence

What I checked:

  • Changed public SDK export: The branch replaces the released removeProviderAuthProfilesWithLock export with a different helper at the established provider-auth subpath. (src/plugin-sdk/provider-auth.ts:67, 73770a339948)
  • Released contract: Release v2026.7.1-2 exported removeProviderAuthProfilesWithLock from openclaw/plugin-sdk/provider-auth; removing it is a source-incompatible SDK change. (src/plugin-sdk/provider-auth.ts:67, 0790d9f593ad)
  • Public subpath: The package exports ./plugin-sdk/provider-auth, establishing the module path used by third-party plugins. (package.json:1286, 73770a339948)
  • Provider ownership model: The updated documentation identifies localService as the managed-versus-existing ownership discriminator under one provider identity. Public docs: docs/plugins/llama-cpp.md. (docs/plugins/llama-cpp.md:28, 73770a339948)
  • After-fix runtime proof: The PR body records an isolated live llama-server run that passed discovery, concurrent generation, structured JSON, and cancellation. (73770a339948)
  • Current-main inspection gap: The shallow review checkout could not resolve the supplied current-main object, so a local three-way comparison was unavailable; the released-SDK break is independently established from the release tag and branch source.

Likely related people:

  • osolmaz: Merged prior work introduced the external llama-server support that this refactor consolidates. (role: introduced external-server behavior; confidence: high; commits: c2de3206d43a; files: extensions/llama-cpp/openclaw.plugin.json, extensions/llama-cpp/src/external-server/setup.ts)
  • Peter Steinberger: Local blame and current refactor history associate this provider and SDK surface with recent work by Peter Steinberger. (role: recent SDK and provider contributor; confidence: medium; commits: 73770a339948; files: src/plugin-sdk/provider-auth.ts, extensions/llama-cpp/src/managed-provider.ts)

Rank-up moves

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

  • Restore or formally deprecate the released provider-auth export and add a focused public-surface regression check.

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.

@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready proof for dd400f090127:

  • Exact-head affected sanity: 34 tests passed across llama.cpp auth, discovery, setup, and the shared self-hosted discovery owner.
  • ClawSweeper P1 repair: 71 tests passed across the public provider-auth SDK and managed llama.cpp setup; pnpm plugin-sdk:surface:check passed at the unchanged 4,335-public-export budget.
  • node scripts/check-changed.mjs passed after the rebase conflict resolution; the final SDK repair also passed its proportional core/extension changed gate, including format, typecheck, lint, SDK, dead-export, boundary, database, and import-cycle checks.
  • Exact-head CI is green: run 32300076656 is attached to dd400f0901277217ae996435abb4241e009b067f.
  • Real isolated llama-server proof passed discovery/concurrent generation, schema-constrained JSON, and cancellation. The tool-call case remains an explicit gap: the selected Gemma template did not advertise tool calling, so that case skipped rather than claiming unsupported proof.

ClawSweeper review: #126434 (comment)

The actionable P1 and its Rank-up move are addressed: the released removeProviderAuthProfilesWithLock export is restored on openclaw/plugin-sdk/provider-auth, bundled callers use the narrower runtime subpath, and a focused public-SDK regression test locks the export. The review checkout's current-main comparison gap is covered by the completed local rebase, exact-head CI, and the native prepare/test-merge guard still to run. The optional models auth login --help probe is skipped as a flag-surface assertion: that command intentionally prints generic login options; --llama-server-api-key belongs to plugin onboarding/non-interactive setup and is covered by the manifest, docs, and focused setup tests.

Production LOC: +808/-954 (net -146) | Tests: +689/-846 (net -157) | Docs: +166/-378 (net -212)

@steipete
steipete merged commit 0135046 into main Aug 19, 2026
227 of 229 checks passed
@steipete
steipete deleted the steipete/strange-wu-c73591 branch August 19, 2026 20:57
@steipete

steipete commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Follow-up: #126498 fixed endpoint-auth reproducibility for existing llama-server setup while deleting the remaining beta-only doctor migration and duplicate live-catalog scaffolding.

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

Labels

docs Improvements or additions to documentation extensions: llama-cpp extensions: lmstudio gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant