Skip to content

fix(llama-cpp): preserve live router model limits and tools on refresh - #168309

Merged
steipete merged 10 commits into
mainfrom
fix/llama-cpp-router-unverified-facts
Oct 10, 2026
Merged

steipete merged 10 commits into
mainfrom
fix/llama-cpp-router-unverified-facts

Conversation

@steipete

@steipete steipete commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Related: #139802

What Problem This Solves

Fixes oversized requests and stale tool capabilities when Existing llama-server setup discovers unloaded router models.

User Impact

Setup leaves unverified context/tool fields unset. After a model is loaded, refresh supplies its live /props facts to the catalog and agent runtime. Explicit configured values remain authoritative. Background discovery still uses autoload=false; unknown runtime facts retain the existing 128,000-token/tools-disabled fallback.

Older generated overrides cannot be distinguished from authored values. Remove the affected generated model row before refreshing or rerunning setup, as documented in the provider guide. Rerunning setup alone preserves existing overrides. No migration, new configuration, dependency, or automatic model loading is added.

Why This Change Was Made

The llama.cpp mapper separates setup persistence from runtime defaults, and provider refresh fills omitted fields. A single lightweight catalog entry exposes the existing discovery/auth policy before full plugin activation; full registration reuses it. This builds on the manifest-auth catalog repair in #168039.

Live testing also exposed a resolver gap: sparse configured rows discarded admitted registry facts except price, falling back to a 200K agent budget despite a refreshed 32K catalog. Resolution now inherits the current same-route catalog and preserves omitted context fields, while the existing owner retains transport and capability rules. Refresh also leaves model-specific endpoint/API overrides alone instead of copying facts from a different route.

Production: +167/-144 (net +23, including manifest); tests: +219/-3; docs: +20/-1. The small production increase covers the catalog entry/auth split and route-checked runtime inheritance; no duplicate discovery owner remains.

Evidence

  • Real Homebrew llama.cpp 0.6.0 (build 11429), --models-max 1, Qwen3-1.7B and Qwen3-0.6B Q8_0, both ctx-size=32768: actual noninteractive Existing llama-server onboarding formerly persisted 128000/false for unloaded B; repaired onboarding omits those fields. After explicitly warming B, CLI and Gateway models list --provider llama-cpp --refresh --json report 32768/32768 without saving overrides.
  • Final real Gateway turn (agent --model llama-cpp/qwen3-0.6b --message-file long-1.txt --thinking off --json) returned ACK1. in 21.11s with 26,128 prompt tokens and a resolved 32,768-token budget, with no context override in config. The second large turn is refused locally in 10.99s against that same limit; before repair it sent 45,398 tokens to the 32K server and received HTTP 400. Compaction cannot retain a complete recent message beside this oversized new prompt, so a smaller request/new session is still required.
  • Real-HTTP setup/catalog regression and real resolver regression both failed before their repairs. The earlier full selection of 95 llama.cpp tests passed (7 files, 138.80s wall); 57 core resolver/route/override tests passed (4 files, 342.39s wall). New regression cases execute in milliseconds; most wall time is compilation/import. The corrected 7-case resolver file passed again in 113.11s wall; the final route regression and mapper/provider siblings passed 26 tests in 44.13s. The cross-route regression failed before its fix. Prior-head CI completed changed Node jobs in 85–195s and the ratchet job in 96s, then fail-fast canceled remaining checks. The complete integrated-head result below supersedes that partial run.
  • Core production and targeted core-test typechecks passed, as did targeted llama.cpp production/test typechecks. Broad extension checking is unavailable in this gateway-only install because private QA Crabbox declarations are absent.
  • Affected max-lines, line-cap, assertion-safety, timeout-race, and mock-export ratchets passed; config docs and plugin inventory checks passed.
  • Before the mechanical main merge, typed lint and runtime-only pnpm build passed (474.32s wall). Build emitted an unrelated UI gzip-budget warning (365.3 KiB versus 364.7 KiB); no UI files changed. Codex autoreview is scoped-clean at P0–P2 after fixing its cross-route finding. ClawSweeper reviewed this exact head with no code findings. Its sole latest-stable saved-config upgrade-proof hold is maintainer-overridden under the campaign instruction; that upgrade cell was not run.

Main integration and complete CI

Merged origin/main at 0aee279a71af78b8914dced0507ddb94c0d1f5b0, including db6449d3f609 and #167814, without conflicts or changes to this lane's source/test files. Pushed once at c490a35fe6deab8d10df95ab8f46f4e5b1f95327 with ci:no-fail-fast applied. The earlier live proof and scoped-clean autoreview cover the unchanged repair.

The integrated tree passed all 152 focused tests (11 files, 295.65s wall), touched-file formatting and typed lint, and all required ratchets. CI run 38044975304 completed successfully: 40 jobs passed, 25 conditionally skipped, zero failures or cancellations. Both UI e2e shards and openclaw/ci-gate passed. Logs confirm all eight session-dashboard cases ran, including both previously failing pin cases; the guest-publication suite was not selected. This run does not establish that the inherited UI defect is fixed.

ClawSweeper reviewed the integrated head at 2026-10-10T10:34:46Z and found no code defects. Its sole saved-config upgrade-proof hold is covered by the lead’s explicit proof-only override; that upgrade cell was not run.

@clawsweeper

clawsweeper Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation extensions: llama-cpp size: S labels Oct 10, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Oct 10, 2026
@clawsweeper

clawsweeper Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR separates unverified setup metadata from runtime defaults and carries refreshed llama.cpp model facts into agent resolution.

Example: Qwen3-0.6B is unloaded during setup and later loaded with a 32,768-token context.

  • Before: Setup pins a 128,000-token context and disabled tools, preventing refresh from correcting those values.
  • After: Setup leaves unverified fields unset, allowing refresh to supply the live context limit and tool capability.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Strong live behavior evidence and no code findings; partial recovery scope and the outstanding saved-state compatibility gate limit readiness.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Recorded real llama.cpp 0.6.0 runs exercise noninteractive onboarding, CLI/Gateway refresh, and agent context enforcement after the repair; the latest-stable saved-config upgrade run is explicitly unperformed, and a proof-only override does not satisfy the separate persisted-data compatibility requirement.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Partial
User problem: Models discovered while unloaded can retain incorrect context limits and disabled tools after they become available.
Reason: The repair prevents new generated pins and enables refresh, while deliberately preserving indistinguishable older authored/generated values and documenting recovery.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open: this maintainer-authored PR repairs a confirmed router-discovery bug, with no actionable code findings in the reviewed patch.

Priority: P2
Reviewed head: c490a35fe6deab8d10df95ab8f46f4e5b1f95327

Before merge

  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

None.

Tests

  • Missing end-to-end proof: The remaining required scenario is an upgrade from v2026.9.9 with saved model rows, credentials, and explicit settings intact, followed by refresh and agent use.
Agent review details

How this fits together

The llama.cpp plugin discovers server models and properties, publishes runtime catalog entries, and supplies model limits and capabilities to the shared agent resolver.

flowchart LR
  A[Existing llama server] --> B[Guarded discovery]
  B --> C[Plugin model mapper]
  C --> D[Setup configuration]
  C --> E[Runtime catalog]
  D --> F[Agent model resolver]
  E --> F
  F --> G[Agent request]
Loading

Technical review

Best possible solution:

Keep the route-scoped repair and explicit override preservation, with latest-stable saved-configuration compatibility demonstrated before merge.

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

Current-main source confirms that skipped unloaded rows acquire fallback values that setup persists; the linked report independently documents the resulting tool failure.

Is this the best way to solve the issue?

The repair addresses the metadata producer and shared resolver while preserving non-loading discovery, explicit pins, and route ownership.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 123d5a1331a8.

Provenance checked

  • External-server model mapping and configured-row precedence changes intended behavior with a stated reason (c2de320: Provide passive external-server discovery and model metadata; subsequent consolidation retained explicit configuration ownership.)
  • Conservative tool capability defaults keeps the original intent (fix(llama-cpp): restore tools for fallback-capable chat templates #129684: Enable supported fallback chat templates while keeping unknown or malformed capabilities tool-disabled.)
  • Catalog/auth registration keeps the original intent (0135046: One provider owns managed and existing-server discovery, authentication, and catalog behavior.)
  • Inline model catalog inheritance changes intended behavior with a stated reason (0bc11c4: Separate model resolution concerns while preserving configured transport and catalog capability ownership.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Onur Solmaz: Raw commit c2de320 adds extensions/llama-cpp/src/external-server/models.ts:114 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: c2de3206d43a; files: extensions/llama-cpp/src/external-server/models.ts)

PR surface

Source +23, Tests +216, Docs +19. Total +258 across 16 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 11 167 144 +23
Tests 4 219 3 +216
Docs 1 20 1 +19
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 16 406 148 +258

Labels

Label changes:

No label changes.

Label justifications:

  • P2: The repair addresses incorrect model limits and disabled tools for existing-server router configurations.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rank-up moves

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

  • Demonstrate the latest-stable saved-configuration upgrade, preserving explicit settings and credentials through refresh and an agent turn.

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 need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (4 earlier review cycles)
  • reviewed 2026-10-10T07:25:34.213Z sha 84faf93 :: blocked before merge. :: none
  • reviewed 2026-10-10T09:52:52.512Z sha f3bfc0a :: blocked before merge. :: none
  • reviewed 2026-10-10T10:03:10.764Z sha f3bfc0a :: blocked before merge. :: none
  • reviewed 2026-10-10T10:33:42.424Z sha c490a35 :: blocked before merge. :: none

Reviewed October 10, 2026, 6:58 AM ET / 10:58 UTC (Revision 5).

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: L and removed size: S labels Oct 10, 2026
@steipete
steipete marked this pull request as ready for review October 10, 2026 09:46
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Oct 10, 2026
@steipete steipete added the ci:no-fail-fast Keep all selected CI matrix jobs running after failures on the next PR run. label Oct 10, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Oct 10, 2026
@steipete steipete self-assigned this Oct 10, 2026
@steipete
steipete merged commit 8972b77 into main Oct 10, 2026
133 checks passed
@steipete
steipete deleted the fix/llama-cpp-router-unverified-facts branch October 10, 2026 11:17
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 11, 2026
openclaw#168309)

* fix(llama-cpp): keep unverified router facts out of setup config

* fix(models): admit deferred local catalogs with captured auth

* fix(llama-cpp): expose catalog auth before runtime activation

* chore: remove stale doctor test line allowance

* fix(agents): retain discovered facts for sparse configured models

* test(agents): type sparse catalog fixtures at the runtime boundary

* test(agents): use complete configured model fixtures

* fix(llama-cpp): keep discovered facts on their verified route
RomneyDa pushed a commit that referenced this pull request Oct 14, 2026
#168309)

* fix(llama-cpp): keep unverified router facts out of setup config

* fix(models): admit deferred local catalogs with captured auth

* fix(llama-cpp): expose catalog auth before runtime activation

* chore: remove stale doctor test line allowance

* fix(agents): retain discovered facts for sparse configured models

* test(agents): type sparse catalog fixtures at the runtime boundary

* test(agents): use complete configured model fixtures

* fix(llama-cpp): keep discovered facts on their verified route

(cherry picked from commit 8972b77)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling ci:no-fail-fast Keep all selected CI matrix jobs running after failures on the next PR run. docs Improvements or additions to documentation extensions: llama-cpp P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant