Skip to content

fix(local-ai): bound default llama generation - #1241

Merged
karkarl merged 1 commit into
openclaw:mainfrom
jacobtomlinson:agents/create-worktree-fix-pr-issue-1240
Aug 27, 2026
Merged

karkarl merged 1 commit into
openclaw:mainfrom
jacobtomlinson:agents/create-worktree-fix-pr-issue-1240

Conversation

@jacobtomlinson

Copy link
Copy Markdown
Contributor

Summary

  • add an 8,192-token n-predict default to the managed llama-server model preset
  • reuse the existing gateway MaximumOutputTokens policy so server and provider limits stay aligned
  • add focused coverage that verifies the generated preset against the provider definition

Closes #1240

Validation

  • ./build.ps1 passed
  • dotnet test ./tests/OpenClaw.Connection.Tests/OpenClaw.Connection.Tests.csproj --no-restore passed: 687 passed, 0 failed, 0 skipped
  • dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore passed: 3,817 passed, 0 failed, 32 skipped
  • dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restore passed: 2,741 passed, 0 failed, 0 skipped

Real behavior proof

Verified on Windows ARM64 with the pinned llama.cpp b10488 runtime, the qualified Qwen 3.6 35B model, and an NVIDIA RTX Spark N1X GPU.

  • the production preset generated from current head contains n-predict = 8192
  • an isolated diagnostic copy changed only that limit to 8 so the omitted-limit behavior could be observed quickly
  • a completion request without max_tokens generated 8 tokens and returned finish_reason: length
  • a completion request with max_tokens: 3 generated 3 tokens and returned finish_reason: length

This proves omitted request limits inherit the server default while explicit request limits remain authoritative in b10488.

Review

  • rubber-duck review: no blocking issues
  • python .agents/skills/autoreview/scripts/autoreview --mode local: clean, no accepted or actionable findings

Apply the existing 8,192-token gateway ceiling to the managed llama-server preset so malformed or direct requests cannot inherit unlimited generation when max_tokens is omitted.

Co-authored-by: Copilot <[email protected]>
@clawsweeper

clawsweeper Bot commented Aug 27, 2026

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

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

@jacobtomlinson jacobtomlinson added the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Aug 27, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. P2 Normal priority bug or improvement with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 27, 2026
@clawsweeper

clawsweeper Bot commented Aug 27, 2026

Copy link
Copy Markdown

Codex review: needs real behavior proof before merge. Reviewed August 27, 2026, 10:46 AM ET / 14:46 UTC.

ClawSweeper review

What this changes

The PR adds the gateway’s 8,192-token output ceiling to the managed llama-server preset and tests that the generated preset and provider definition remain aligned.

Merge readiness

⛔ Blocked until real behavior proof is added - 4 items remain

This PR remains necessary: current main generates the managed llama-server preset without an n-predict limit. The patch is focused and has no line-level correctness finding, but its claimed ARM64 runtime result needs inspectable real-behavior evidence before merge.

Priority: P2
Reviewed head: 42bb55cadc16a63e6c85fa89281f7e7a9053e388

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The patch and focused regression coverage look sound, but inspectable real-behavior proof is required before merge.
Proof confidence 🧂 unranked krab (1/6) Needs real behavior proof before merge: The PR describes a real ARM64 llama-server check, but it provides no linked or copied redacted runtime output, logs, screenshot, recording, or artifact that can be inspected. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The PR describes a real ARM64 llama-server check, but it provides no linked or copied redacted runtime output, logs, screenshot, recording, or artifact that can be inspected. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 7 items Current-main gap: Current main writes context size and then parallelism, with no n-predict entry in the managed preset.
Patch reaches the runtime preset: The proposed line adds n-predict from the existing shared maximum; the runtime service consumes the launch plan’s preset content when preparing llama-server.
Existing policy alignment: The provider definition already exposes MaximumOutputTokens as 8,192 in the generated provider JSON, and the added test verifies the preset emits that same value.
Findings None None.
Security None None.

Live Verification

Command: dotnet test ./tests/OpenClaw.Connection.Tests/OpenClaw.Connection.Tests.csproj --no-restore --filter FullyQualifiedName~RouterPreset_BoundsOmittedGenerationAtGatewayMaximum

Result: FAIL (failed) — execution before step 1 expect_output: sh -lc pnpm install --ignore-scripts --frozen-lockfile failed: ! Corepack is about to download https://registry.npmjs.org/pnpm/-/pnpm-11.24.0.tgz

sh -lc pnpm install --ignore-scripts --frozen-lockfile failed: ! Corepack is about to download https://registry.npmjs.org/pnpm/-/pnpm-11.24.0.tgz

Assertions:

  • FAIL expect_output: Passed!

How this fits together

Local AI generates a llama-server preset for the managed model and separately writes the gateway provider definition. The preset controls the local server’s behavior when a request omits its generation limit.

flowchart LR
A[Managed local model] --> B[Preset generator]
D[Gateway output policy] --> B
D --> E[Gateway provider definition]
B --> C[llama-server]
E --> F[Gateway or local request]
F --> C
C --> G[Bounded completion]
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR describes a real ARM64 llama-server check, but it provides no linked or copied redacted runtime output, logs, screenshot, recording, or artifact that can be inspected. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve merge risk (P1) - Direct loopback callers that omit max_tokens will now receive a maximum 8,192-token completion rather than the runtime’s prior unlimited default.
  • Resolve merge risk (P1) - The PR describes an ARM64 runtime check but supplies no inspectable redacted terminal output, log, screenshot, recording, or artifact for the claimed omitted-limit and explicit-limit behavior.
  • Complete next step (P2) - No mechanical repair is identified; the contributor needs to attach inspectable real-behavior proof before merge.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Patch scope production +1, tests +24 The change is narrowly limited to managed preset generation and an alignment regression test.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #1240
Summary: This PR explicitly supplies the proposed fix for the linked runaway-generation report.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Verify direct-client behavior before merge (recommended)
    Add redacted b10488 runtime output showing an omitted request stops at the preset limit while an explicit lower max_tokens value still controls generation.
  2. Accept the direct-client cap
    Land the intentional 8,192-token ceiling for callers that use the managed loopback server without sending max_tokens.

Technical review

Best possible solution:

Keep one shared 8,192-token ceiling for the gateway definition and generated managed preset, with a redacted b10488 request transcript demonstrating the intended default and explicit override behavior.

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

Yes from source for the configuration gap: current main omits n-predict while advertising an 8,192-token gateway maximum. The exact pinned-runtime behavior still needs an inspectable b10488 request trace.

Is this the best way to solve the issue?

Yes, conditional on runtime proof. Reusing the existing shared ceiling at the sole managed-preset generation point avoids a competing limit policy.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: The PR addresses a bounded local-model generation defect with a limited blast radius.
  • add merge-risk: 🚨 compatibility: The change intentionally caps previously unlimited completions for direct local-server callers that omit max_tokens.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR describes a real ARM64 llama-server check, but it provides no linked or copied redacted runtime output, logs, screenshot, recording, or artifact that can be inspected. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Label justifications:

  • P2: The PR addresses a bounded local-model generation defect with a limited blast radius.
  • merge-risk: 🚨 compatibility: The change intentionally caps previously unlimited completions for direct local-server callers that omit max_tokens.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR describes a real ARM64 llama-server check, but it provides no linked or copied redacted runtime output, logs, screenshot, recording, or artifact that can be inspected. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

Likely related people:

  • Joel: Introduced the managed Local AI feature, including the preset generator and provider output ceiling now being aligned. (role: feature introducer; confidence: high; commits: ccd64bbb7d68; files: src/OpenClaw.Connection/LocalAi/LlamaServerRouterConfiguration.cs, src/OpenClaw.Connection/LocalAi/LocalAiGatewayProviderDefinition.cs)
  • Jacob Tomlinson: The original managed Local AI feature records Jacob as a co-author, and the current focused fix is authored by him. (role: initial Local AI co-author and current fix author; confidence: high; commits: ccd64bbb7d68, 42bb55cadc16; files: src/OpenClaw.Connection/LocalAi/LlamaServerRouterConfiguration.cs, tests/OpenClaw.Connection.Tests/LocalAiPortLifecycleTests.cs)

Rank-up moves

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

  • Attach a redacted terminal transcript or artifact from the pinned llama-server showing omitted max_tokens uses the preset limit and explicit max_tokens remains authoritative.

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.

@karkarl karkarl left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adversarial dual-model review verdict: SHIP TODAY.

Opus and Codex found no code defects, security issues, race conditions, correctness problems, or release blockers. The intentional compatibility change caps direct loopback callers that omit max_tokens at 8,192; supported gateway callers were already capped, and the first-party direct caller sends an explicit limit. CI is green and the PR is merge-clean.

@karkarl
karkarl merged commit 6f60d33 into openclaw:main Aug 27, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. P2 Normal priority bug or improvement with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Runaway generation with default llama.cpp settings

2 participants