Skip to content

feat(llama-cpp): raise default context size to 64K - #123701

Merged
steipete merged 1 commit into
mainfrom
feat/llama-cpp-default-context-64k
Aug 14, 2026
Merged

steipete merged 1 commit into
mainfrom
feat/llama-cpp-default-context-64k

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What problem this solves

The managed llama.cpp default ctx-size was 8192. The full OpenClaw agent system prompt alone is ~31K tokens, so the very first agent turn on a fresh local-model install overflowed the context window and forced immediate compaction. Observed live during the Mac app local-model onboarding: at 8K the turn failed with "Context overflow: prompt too large for the model"; even at 32K the session sat at 93% context with compaction firing. Only at 64K did a clean agent turn complete (47% used).

Why this change was made

The 8K default predates the external-llama-server migration (#123105) and was never sized against the real agent prompt. Raising the default makes the out-of-box local-model agent actually usable.

  • DEFAULT_LLAMA_CPP_CONTEXT_SIZE: 8192 → 65536 in extensions/llama-cpp/src/defaults.ts.
  • Docs (docs/plugins/llama-cpp.md) updated to match.

This only changes headroom, not the offer gate: the 16 GiB RAM floor for the default download already bounds weaker machines, and Gemma 4 E4B supports far more than 64K context. Operators can still override per-model via params.contextSize.

User impact

Fresh llama.cpp onboarding now produces a model that can run a real agent turn without immediate context overflow. No migration needed — the value applies at setup/prepare time; existing installs keep whatever context their generated models.ini already has until they re-run setup.

Evidence

  • Live Mac app onboarding (profile dev instance): 8K → "Context overflow"; 32K → 93% used + compaction; 64K → clean agent turn "local model online", 47% of 65.5k used.
  • node scripts/run-vitest.mjs extensions/llama-cpp → 4 files, 24 tests passed.
  • The two test literals that mention 8192 pass explicit values (not the constant), so they stay green.

The managed llama-server default ctx-size was 8192, but the full OpenClaw
agent system prompt alone is ~31K tokens, so the first agent turn overflowed
the context window and forced immediate compaction (observed live on the Mac
app local-model onboarding). Raise the default to 65536 so a fresh local-model
install can run a real agent turn out of the box.

The default-download 16 GiB RAM floor already bounds weaker machines, and
Gemma 4 supports far more than 64K, so this only changes headroom, not the
offer gate. Docs updated to match.
@clawsweeper

clawsweeper Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation extensions: llama-cpp size: XS labels Aug 14, 2026
@steipete
steipete marked this pull request as ready for review August 14, 2026 14:56
@openclaw-barnacle openclaw-barnacle Bot added the maintainer Maintainer-authored PR label Aug 14, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P1 High-priority user-facing bug, regression, or broken workflow. 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 14, 2026
@clawsweeper

clawsweeper Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 14, 2026, 11:02 AM ET / 15:02 UTC.

ClawSweeper review

What this changes

This PR raises the managed llama.cpp plugin’s default context window from 8K to 64K and updates its setup documentation.

Regression provenance

Possible regression — probable (reproduction; reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open for maintainer review: the PR repairs a source-proven first-run local-model failure through the plugin’s canonical default, but the 16 GiB onboarding threshold needs capacity confirmation for the eightfold context increase.

Priority: P1
Reviewed head: e7bce0b7596653c56f89a2509c0d2bc004744467
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is a small, coherent owner-boundary repair with one minimum-hardware capacity decision still visible before merge.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR reports a live onboarding result; the external-contributor proof gate does not apply.
Patch quality 🐚 platinum hermit (4/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR reports a live onboarding result; the external-contributor proof gate does not apply.
Evidence reviewed 7 items Canonical default: Current main defines the default model’s advertised context window, context token budget, and server context parameter from one canonical constant.
Setup caller: Guided setup selects the model context parameter and passes it to managed-server preparation, so the default reaches fresh onboarding rather than only documentation.
Server preset owner: The managed-server renderer writes the chosen value as llama-server's ctx-size setting.
Findings 1 actionable finding [P3] Describe 64K as headroom, not a prompt requirement
Security None None.

How this fits together

The llama.cpp plugin builds the default local model configuration during onboarding, then writes that model’s context size into a managed llama-server preset. The server uses that preset for local agent turns and local embeddings.

flowchart LR
  A[Local-model onboarding] --> B[Default model configuration]
  B --> C[Selected context size]
  C --> D[Managed server preset]
  D --> E[llama-server]
  E --> F[First agent turn]
Loading

Decision needed

Question Recommendation
Should the existing 16 GiB onboarding offer threshold remain the supported hardware floor for the new 64K default? Validate the 16 GiB floor: Record a fresh 64K onboarding and first-agent-turn result at the minimum supported memory tier, then retain the current offer gate.

Why: The code correctly changes the canonical default, but choosing the minimum supported memory envelope is a maintainer product and reliability tradeoff.

Before merge

  • Describe 64K as headroom, not a prompt requirement (P3) - The PR description says the full system prompt is about 31K tokens, but this sentence says it requires 65,536. Describe 64K as the headroom needed for the prompt, history, tool output, and generation so operators do not infer that a 32K-capable custom model cannot load the prompt.
  • Resolve merge risk (P1) - All newly offered 16 GiB machines will receive an eightfold larger context setting; the checked-in 16 GiB gate has no capacity proof that it still leaves enough headroom for the 64K KV cache across supported backends.

Findings

  • [P3] Describe 64K as headroom, not a prompt requirement — docs/plugins/llama-cpp.md:41-42
Agent review details

Security

None.

PR surface

Source +3, Docs +1. Total +4 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 4 1 +3
Tests 0 0 0 0
Docs 1 5 4 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 9 5 +4

Review metrics

Metric Value Why it matters
Default surface 1 changed: 8,192 → 65,536 tokens The fresh-install model metadata and generated llama-server preset both inherit this single default.
Production versus tests production +3, tests 0, docs +1 net The code growth is explanatory commentary; the behavioral change remains one constant replacement.

Merge-risk options

Maintainer options:

  1. Prove the minimum-memory setup (recommended)
    Before merge, attach redacted evidence that a 16 GiB supported host completes fresh setup and a first 64K agent turn without memory pressure or server failure.
  2. Increase the hardware floor
    Raise the onboarding offer threshold if the 64K preset cannot reliably retain sufficient operating-system and server headroom at 16 GiB.
  3. Accept the narrower margin
    Retain the 16 GiB floor while explicitly accepting that the new default has less unverified capacity margin on minimum-spec hosts.

Technical review

Best possible solution:

Keep the plugin-owned 64K default, but land only after confirming the 16 GiB offer threshold is safe for a 64K first turn or raising the threshold to match the measured envelope.

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

Yes. Current main routes the default model’s 8K context value into the generated llama-server preset, and the PR supplies a real fresh-onboarding report of the resulting overflow.

Is this the best way to solve the issue?

Yes for the context-overflow defect: the canonical plugin default feeds both setup metadata and the server preset. The remaining question is whether the RAM offer floor must change with it.

Full review comments:

  • [P3] Describe 64K as headroom, not a prompt requirement — docs/plugins/llama-cpp.md:41-42
    The PR description says the full system prompt is about 31K tokens, but this sentence says it requires 65,536. Describe 64K as the headroom needed for the prompt, history, tool output, and generation so operators do not infer that a 32K-capable custom model cannot load the prompt.
    Confidence: 0.98

Overall correctness: patch is correct
Overall confidence: 0.9

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P1: This repairs a fresh local-model onboarding path that otherwise overflows before a useful first agent turn.
  • add merge-risk: 🚨 availability: The larger default can make the managed local server unavailable on hosts that previously passed the unchanged 16 GiB eligibility gate.
  • 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 reports a live onboarding result; the external-contributor proof gate does not apply.

Label justifications:

  • P1: This repairs a fresh local-model onboarding path that otherwise overflows before a useful first agent turn.
  • merge-risk: 🚨 availability: The larger default can make the managed local server unavailable on hosts that previously passed the unchanged 16 GiB eligibility gate.
  • 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 reports a live onboarding result; the external-contributor proof gate does not apply.

Evidence

What I checked:

Likely related people:

  • steipete: Authored this PR and the merged managed llama-server migration that established the affected setup path. (role: feature owner; confidence: high; commits: 134838707603, e7bce0b75966; files: extensions/llama-cpp/src/defaults.ts, docs/plugins/llama-cpp.md)
  • Ayaan Zaidi: Current-main blame for the default-model retention and setup/preset handoff points to this integration commit. (role: recent area contributor; confidence: medium; commits: e826501fdb6a; files: extensions/llama-cpp/src/defaults.ts, extensions/llama-cpp/src/setup.ts, extensions/llama-cpp/src/managed-server.ts)

Rank-up moves

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

  • Correct the documentation wording to distinguish a 31K prompt from 64K operating headroom.
  • Confirm the 16 GiB offer floor with a 64K fresh-setup run at the minimum supported memory tier.

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
steipete merged commit f65a6f8 into main Aug 14, 2026
234 checks passed
@steipete
steipete deleted the feat/llama-cpp-default-context-64k branch August 14, 2026 15:26
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 15, 2026
The managed llama-server default ctx-size was 8192, but the full OpenClaw
agent system prompt alone is ~31K tokens, so the first agent turn overflowed
the context window and forced immediate compaction (observed live on the Mac
app local-model onboarding). Raise the default to 65536 so a fresh local-model
install can run a real agent turn out of the box.

The default-download 16 GiB RAM floor already bounds weaker machines, and
Gemma 4 supports far more than 64K, so this only changes headroom, not the
offer gate. Docs updated to match.
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 maintainer Maintainer-authored PR merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS 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