Skip to content

fix(llama-cpp): stop recommending failed models during setup - #130136

Merged
steipete merged 1 commit into
mainfrom
codex/llama-cpp-skip-failed-setup-models
Aug 26, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/llama-cpp-skip-failed-setup-models

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where users connecting an existing llama.cpp server through guided or noninteractive setup could be offered a model that has already failed to start when every advertised model is failed.

Why This Change Was Made

The upstream llama.cpp router marks a model as failed when it is unloaded and its last process exited unsuccessfully. OpenClaw's implicit selector filtered failed models but then fell back to those same failed models when none were healthy. Keep failed models out of automatic selection, while preserving an operator's explicitly requested model. Consolidate duplicated read-only guided discovery, managed-server exclusion, credential resolution, cancellation, and failure handling into their existing provider owner.

User Impact

Guided setup no longer recommends a broken existing-server model, and implicit noninteractive setup fails before changing authentication profiles. Operators who explicitly request a model retain their existing selection behavior. Managed llama.cpp setup, configured authorization headers, API keys, cancellation, discovery request counts, and existing diagnostic messages are unchanged.

Evidence

  • The upstream router defines failure as status == UNLOADED && exit_code != 0 and exposes it as status.failed in the model catalog.
  • Before the fix, the existing provider setup suite reproduced both failures: 2 failed, 27 passed. Guided setup returned a failed model instead of no candidate, and implicit noninteractive validation incorrectly succeeded.
  • After the fix, provider setup, discovery, model mapping, and authentication suites passed: 53 tests across four files. The real generic system-agent setup inference ingress passed another 9 tests: 62 tests passed across five files.
  • Scoped formatting and type-aware plugin lint passed. Two independent reviews and a fresh structured autoreview reported no actionable findings.
  • Production delta: 25 lines removed; regression coverage: 22 lines added. No configuration, persistence, schema, plugin API, dependency, or changelog changes.

@clawsweeper

clawsweeper Bot commented Aug 26, 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 26, 2026 13:34
@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: 🐚 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. labels Aug 26, 2026
@clawsweeper

clawsweeper Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 26, 2026, 9:40 AM ET / 13:40 UTC.

ClawSweeper review

What this changes

The PR prevents automatic llama.cpp setup from selecting models the server reports as failed, while retaining explicitly requested models.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

No blocking patch defect found. This focused provider-setup repair should remain open for normal maintainer review; direct upstream llama.cpp contract verification and exact-head CI remain outstanding.

Priority: P2
Reviewed head: 88af65dd4e4ee8467620420c3de83661a727bd76

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch and focused regression coverage are solid, with upstream-contract and exact-head verification still needed before landing.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is outside the external-contributor proof gate; its focused tests remain supplemental rather than real-server evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is outside the external-contributor proof gate; its focused tests remain supplemental rather than real-server evidence.
Evidence reviewed 7 items Current-main failure path: Current main keeps failed models only when at least one healthy model exists; an all-failed catalog falls back to every discovered model and becomes selectable.
Changed owner boundary: The PR filters failed entries before readiness and preference selection, so all automatic setup paths sharing this selector return no candidate when every row failed.
Explicit selection remains separate: Noninteractive validation uses an authored model ID ahead of automatic selection and only requires that it still exists in discovery.
Findings None None.
Security None None.

Live Verification

Command: pnpm openclaw --help

Result: PASS (completed)

$ node scripts/run-node.mjs --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 117.37 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.8s
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
───────╯

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
──────╯

[tsdown-build] invocation 2/2 finished in 14.5s
[plugin-control-plane-loads] verified 35 built modules with native require and checked doctor closures
runtime-postbuild: 11 phases completed in 4425ms (slowest: built plugin control-plane loads 3682ms)

OpenClaw 2026.8.1 (88af65d) — All your chats, one OpenClaw.

Usage: openclaw [options] [command]

Options:
  --container ‹name›   Run the CLI inside a running Podman/Docker container named ‹name› (default: env OPENCLAW_CONTAINER)
  --dev                Dev profile: isolate state under ~/.openclaw-dev, default gateway port 19001, and shift derived ports (browser/canvas)
  -h, --help           Display help for command
  --log-level ‹level›  Global log level override for file + console (silent|fatal|error|warn|info|debug|trace)
  --no-color           Disable ANSI colors
  --profile ‹name›     Use a named profile (iso
… output truncated …

Assertions:

  • PASS expect_output: Usage:

How this fits together

The llama.cpp plugin discovers models from an existing llama-server and maps them into OpenClaw provider setup. Guided and noninteractive setup select a default model, then produce provider and authentication configuration for the agent.

flowchart LR
  A[Existing llama-server] --> B[Model discovery]
  B --> C[Model status mapping]
  C --> D[Automatic setup selection]
  D --> E[Guided or noninteractive setup]
  E --> F[Provider and auth configuration]
Loading

Before merge

  • Resolve merge risk (P2) - This intentionally removes the existing all-failed fallback: automated setup for such servers will now stop before configuration/auth changes, so the upstream meaning of status.failed should be confirmed before merge.
  • Complete next step (P2) - This maintainer-authored PR has an intentional setup-compatibility change; confirm the provider contract and exact-head CI rather than queueing an automated repair.
Agent review details

Security

None.

PR surface

Source -25, Tests +22. Total -3 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 32 57 -25
Tests 1 22 0 +22
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 54 57 -3

Review metrics

Metric Value Why it matters
Production versus regression LOC production +32/-57 (net -25); tests +22/-0 (net +22) The repair removes duplicated guided-discovery handling while adding focused coverage for the failed-only selection invariant.

Merge-risk options

Maintainer options:

  1. Verify the failed-status contract (recommended)
    Confirm against llama.cpp source or a redacted existing-server trace that status.failed means the model must not be automatically selected, then merge with the intentional setup failure behavior.
  2. Accept the setup behavior change
    Merge with the documented tradeoff that failed-only implicit setup now stops before changing profiles or configuration.

Technical review

Best possible solution:

Keep failed rows out of automatic selection, preserve explicit operator model IDs, and verify the upstream catalog contract plus exact-head CI before landing.

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

Yes, from source: current main falls back to failed rows when no healthy row exists, making a failed-only catalog automatically selectable. This read-only review did not execute the test suite.

Is this the best way to solve the issue?

Yes: placing the exclusion in the shared automatic selector covers guided, interactive, and implicit noninteractive selection while explicit selection remains a separate path.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This repairs a bounded existing-server setup-selection failure with limited blast radius.
  • add merge-risk: 🚨 compatibility: Existing failed-only endpoints that previously completed implicit setup will now fail intentionally before configuration or auth mutation.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR is outside the external-contributor proof gate; its focused tests remain supplemental rather than real-server evidence.

Label justifications:

  • P2: This repairs a bounded existing-server setup-selection failure with limited blast radius.
  • merge-risk: 🚨 compatibility: Existing failed-only endpoints that previously completed implicit setup will now fail intentionally before configuration or auth mutation.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR is outside the external-contributor proof gate; its focused tests remain supplemental rather than real-server evidence.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Current-main blame attributes the automatic selection helper to this author, and the current PR is also authored by Peter Steinberger. (role: recent area contributor; confidence: medium; commits: 869d2073f61d, 88af65dd4e4e; files: extensions/llama-cpp/src/external-server/setup.ts, extensions/llama-cpp/src/external-server/setup.test.ts)

Rank-up moves

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

  • Confirm the llama.cpp status.failed contract with upstream source or a redacted existing-server trace.
  • Wait for exact-head required CI to complete successfully.

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

ClawSweeper's two rank-up items are now verified:

  • Upstream llama.cpp defines a failed model as status == SERVER_MODEL_STATUS_UNLOADED && exit_code != 0 in tools/server/server-models.h, and tools/server/server-models.cpp exposes that condition as status.failed: true. The model cannot be automatically considered ready until its failure state is reset.
  • Exact reviewed head 88af65dd4e4ee8467620420c3de83661a727bd76 completed all 51 jobs successfully in CI run 32974994558, including the required openclaw/ci-gate.

The intended compatibility boundary is explicit: implicit guided, interactive, and noninteractive setup now reject a failed-only catalog without mutating auth profiles; an operator's explicitly selected failed model remains accepted. Baseline owner tests reproduced both failures (2 failed / 27 passed), then the final provider/auth/discovery/model siblings and real generic setup ingress passed 62 tests across five files. Scoped formatting, type-aware plugin lint, two independent reviews, and structured autoreview are clean.

@steipete
steipete merged commit 6f0395e into main Aug 26, 2026
173 checks passed
@steipete
steipete deleted the codex/llama-cpp-skip-failed-setup-models branch August 26, 2026 14:05
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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

Labels

extensions: llama-cpp 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: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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.

1 participant