Skip to content

fix(llama-cpp): stop hijacking explicitly configured HTTP provider routes - #118293

Merged
steipete merged 2 commits into
mainfrom
fix/llamacpp-route-hijack
Aug 3, 2026
Merged

steipete merged 2 commits into
mainfrom
fix/llamacpp-route-hijack

Conversation

@steipete

@steipete steipete commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes #118212: the native llama-cpp plugin hijacked explicitly configured HTTP provider routes. An operator pointing a model at a Hugging Face local-app HTTP endpoint got LLM request failed because the plugin's stream factory intercepted the route instead of letting the configured HTTP transport serve it. Discovered when the huggingface-local-app-openclaw E2E was adjudicated red on main (MLX passed, llama.cpp failed).

Why This Change Was Made

Provenance: commit 658b601ee584 (PR #109444) introduced an unconditional llama.cpp createStreamFn, which preempted the generic HTTP fallback for any route the plugin could claim. Nothing in the commit, PR, or docs indicates that precedence was intentional — explicit configuration losing to plugin-native discovery inverts the repo's routing contract.

The fix scopes the plugin to its canonical route: extensions/llama-cpp claims local://llama-cpp only, and returns undefined for explicit HTTP routes so the existing configured transport handles them. No shim, no shared-resolver change; +10/−4 production lines.

User Impact

Explicitly configured HTTP endpoints (Hugging Face local apps, self-hosted llama.cpp servers addressed by URL) work again regardless of the native plugin being installed. The native local://llama-cpp path is unchanged.

Evidence

  • HF local-app E2E: 2/2 green (GGUF llama.cpp and MLX) — previously red on main for the llama.cpp case
  • llama.cpp suite 56/56; provider-routing suite 65/65; 123 focused tests total
  • Exact-source build; tsgo + tsgo:test; format/oxlint/diff checks; structured autoreview clean

Fixes #118212

🤖 Generated with Claude Code

@steipete
steipete marked this pull request as ready for review August 2, 2026 23:11
@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Aug 2, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. labels Aug 2, 2026
@clawsweeper

clawsweeper Bot commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 2, 2026, 8:03 PM ET / August 3, 2026, 00:03 UTC.

ClawSweeper review

What this changes

The PR restricts llama.cpp’s native inference hook to the canonical local://llama-cpp route so explicitly configured OpenAI-compatible HTTP endpoints use their configured transport.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep this PR open for landing: current main still invokes the llama.cpp native stream factory for every matching provider id, while this patch makes the plugin decline explicit HTTP model routes and lets the established configured-transport fallback handle them. The owner-local change is the narrowest repair; refresh the merge result and required checks on the exact landing head before merge.

Priority: P1
Reviewed head: 78262881a301b2a925b090d28ef973fc536637eb

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-local repair with direct route-boundary coverage and stated real E2E proof; only exact-head merge validation remains.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The PR body reports a post-fix run of the existing Hugging Face local-app E2E with both GGUF llama.cpp and MLX cases green; the checked-in E2E directly observes the fake HTTP server receiving the chat-completions request.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body reports a post-fix run of the existing Hugging Face local-app E2E with both GGUF llama.cpp and MLX cases green; the checked-in E2E directly observes the fake HTTP server receiving the chat-completions request.
Evidence reviewed 6 items Current-main defect: Current main’s llama.cpp provider creates a native stream function without examining the resolved model route, so a configured llama-cpp HTTP provider can be intercepted before transport fallback.
Fallback contract: The agent stream registration calls the provider hook first and invokes createTransportAwareStreamFnForModel only when that hook returns undefined; the proposed change uses that existing contract rather than adding a parallel resolver.
Configured-route reproduction coverage: The existing local-app E2E configures an HTTP base URL and provider id llama-cpp, then asserts an HTTP /v1/chat/completions request reaches the fake OpenAI-compatible server. This directly covers the affected operator flow.
Findings None None.
Security None None.

How this fits together

OpenClaw resolves a configured model into a provider runtime hook before registering a stream. A provider plugin may return a native stream function, but when it declines the model route, the agent runtime falls back to the configured API transport, which sends requests to the model’s HTTP base URL.

flowchart LR
  A[Operator model configuration] --> B[Resolved model with provider and base URL]
  B --> C[Provider runtime hook]
  C --> D{Canonical local llama.cpp route?}
  D -->|Yes| E[Native in-process llama.cpp stream]
  D -->|No| F[Configured API transport]
  F --> G[HTTP endpoint request]
Loading

Before merge

  • Resolve merge risk (P1) - Merging intentionally changes existing llama-cpp configurations with an HTTP base URL from accidental native interception to configured HTTP transport; that is the desired repair, but the exact merge result and required checks should be refreshed on current main before landing.
  • Complete next step (P2) - No mechanical repair is outstanding; the protected maintainer label and exact-head merge/check refresh require a normal maintainer landing decision.
Agent review details

Security

None.

PR surface

Source +6, Tests +33. Total +39 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 2 10 4 +6
Tests 1 48 15 +33
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 58 19 +39

Review metrics

Metric Value Why it matters
Provider-route precedence 1 canonical native route retained; explicit HTTP routes delegated The patch changes which runtime owns existing llama-cpp provider configurations, so maintainers should verify both route classes on the merged head.

Merge-risk options

Maintainer options:

  1. Refresh exact-head routing proof (recommended)
    Recompute the GitHub merge result against current main and require the focused provider-routing and local-app coverage to pass before landing this provider-route behavior change.
  2. Pause if the merge result changes route semantics
    Hold the PR if rebasing exposes a competing provider-routing change that makes the local-versus-HTTP ownership rule ambiguous.

Technical review

Best possible solution:

Keep native inference exclusively on the documented canonical local://llama-cpp route, preserve the established undefined-to-transport fallback for configured HTTP routes, and land after exact-head merge validation.

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

Yes, at source level: the existing local-app E2E configures llama-cpp with a loopback OpenAI-compatible HTTP base URL and asserts that the agent reaches that endpoint; current main’s unconditional native hook preempts the fallback path.

Is this the best way to solve the issue?

Yes. The plugin is the owner of native llama.cpp behavior, and returning undefined for non-canonical routes reuses the existing transport fallback rather than changing shared resolver precedence or adding configuration.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add merge-risk: 🚨 auth-provider: The patch changes provider stream selection for existing llama-cpp configurations based on their configured model base URL.

Label justifications:

  • P1: This repairs a current provider-routing regression that blocks a documented local-app HTTP workflow for the llama-cpp provider id.
  • merge-risk: 🚨 auth-provider: The patch changes provider stream selection for existing llama-cpp configurations based on their configured model base URL.
  • 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. Sufficient (terminal): The PR body reports a post-fix run of the existing Hugging Face local-app E2E with both GGUF llama.cpp and MLX cases green; the checked-in E2E directly observes the fake HTTP server receiving the chat-completions request.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body reports a post-fix run of the existing Hugging Face local-app E2E with both GGUF llama.cpp and MLX cases green; the checked-in E2E directly observes the fake HTTP server receiving the chat-completions request.

Evidence

What I checked:

  • Current-main defect: Current main’s llama.cpp provider creates a native stream function without examining the resolved model route, so a configured llama-cpp HTTP provider can be intercepted before transport fallback. (extensions/llama-cpp/index.ts:48, b7f9cd0a0167)
  • Fallback contract: The agent stream registration calls the provider hook first and invokes createTransportAwareStreamFnForModel only when that hook returns undefined; the proposed change uses that existing contract rather than adding a parallel resolver. (src/agents/provider-stream.ts:37, b7f9cd0a0167)
  • Configured-route reproduction coverage: The existing local-app E2E configures an HTTP base URL and provider id llama-cpp, then asserts an HTTP /v1/chat/completions request reaches the fake OpenAI-compatible server. This directly covers the affected operator flow. (test/huggingface-local-app-openclaw.e2e.test.ts:60, b7f9cd0a0167)
  • Patch-level boundary test: The PR adds a focused provider-plugin assertion: an HTTP base URL yields no native stream function, while local://llama-cpp still yields the native function. (extensions/llama-cpp/index.test.ts:91, 78262881a301)
  • Model-route source of truth: Resolved configured models carry modelDef.baseUrl or the provider configuration’s baseUrl, so the PR’s condition evaluates the same effective route that the transport fallback would use. (src/agents/sessions/model-registry.ts:1036, b7f9cd0a0167)
  • Feature provenance: Blame attributes the unconditional stream-factory block on current main to Peter Steinberger; the supplied linked merged PR identifies commit 658b601ee584d42679b3b470a549f8a9601da113 as the feature introduction. Local history is promisor-incomplete, so that older commit could not be opened without network access. (extensions/llama-cpp/index.ts:48, 761c3e33be19)

Likely related people:

  • steipete: The linked merged llama.cpp inference feature was authored by this contributor, current-main blame attributes the affected hook block to Peter Steinberger, and shortlog shows repeated work across the plugin’s entry, defaults, and tests. (role: feature author and recent area contributor; confidence: high; commits: 658b601ee584, 761c3e33be19; files: extensions/llama-cpp/index.ts, extensions/llama-cpp/src/defaults.ts, extensions/llama-cpp/index.test.ts)

Rank-up moves

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

  • Refresh the GitHub merge result and required checks against current main before landing.

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 (1 earlier review cycle)
  • reviewed 2026-08-02T23:52:12.699Z sha 3082a16 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. label Aug 3, 2026
@steipete
steipete merged commit b521e0a into main Aug 3, 2026
89 checks passed
@steipete
steipete deleted the fix/llamacpp-route-hijack branch August 3, 2026 00:07
@steipete

steipete commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 3, 2026
…utes (openclaw#118293)

* fix(llama-cpp): preserve configured HTTP routes

* chore: drop release-owned CHANGELOG edit from PR branch
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: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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.

Custom provider id llama-cpp is routed through the native plugin instead of its HTTP endpoint

1 participant