Skip to content

docs(gateway): document llamacpp toolSchemaProfile for custom llama.cpp endpoints - #117120

Merged
vincentkoc merged 5 commits into
openclaw:mainfrom
SunnyShu0925:docs/llamacpp-tool-schema-profile-117070
Aug 1, 2026
Merged

vincentkoc merged 5 commits into
openclaw:mainfrom
SunnyShu0925:docs/llamacpp-tool-schema-profile-117070

Conversation

@SunnyShu0925

@SunnyShu0925 SunnyShu0925 commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

OpenClaw already supports compat.toolSchemaProfile: "llamacpp" for custom model entries, but the gateway docs did not name the value or explain when a custom llama-server route needs it. Operators could therefore hit llama.cpp HTTP 400 grammar failures without a documented path to the existing compatibility cleaner.

Related to #117070

Why This Change Was Made

This documents the existing llamacpp profile and adds a complete custom openai-completions provider example for llama-server. The wording is intentionally narrow: the profile removes pattern and maxLength values at or above 2000, covering the reported cron maxLength: 65536 failure without claiming complete compatibility for every JSON Schema constraint or minLength.

Built-in llama-cpp, ollama, and lmstudio providers already apply the same cleaner through provider hooks. Custom endpoints remain explicit because an arbitrary OpenAI-compatible URL is not a reliable llama.cpp identity contract. The broader first-party provider decision is already tracked in #116765.

User Impact

Operators using a custom llama-server endpoint can now configure the supported schema profile directly instead of reverse-engineering a provider rejection. Older builds also get a clearly labeled broader keyword-stripping fallback.

Evidence

  • Runtime profile selection: packages/ai/src/providers/agent-tools-parameter-schema.ts
  • Cleaner contract and 2000 threshold: packages/ai/src/providers/clean-for-llamacpp-gbnf.ts
  • Built-in provider hooks: extensions/llama-cpp/index.ts, extensions/ollama/index.ts, extensions/lmstudio/index.ts
  • Triggering cron constraint: src/agents/tools/cron-tool-schema.ts
  • Existing regression coverage: src/plugin-sdk/provider-tools.test.ts
  • Upstream llama.cpp contract checked at ddd4ec1428a6201e18975ea52b07c71e0f9aef26: string minLength/maxLength become grammar repetitions, and llama.cpp rejects repetition expansion at its 2000-rule ceiling.

Validation on head 0fc2c856d17cc7b5408c89584eea1576ceb682b1:

node scripts/docs-list.js
node scripts/check-docs-mdx.mjs docs README.md
Docs MDX check passed (764 files)

node scripts/docs-link-audit.mjs
checked_internal_links=6346
broken_links=0

node scripts/check-docs-i18n-glossary.mjs
node scripts/generate-docs-map.mjs --check
docs:map: docs/docs_map.md is up to date.

./node_modules/.bin/oxfmt --check docs/gateway/config-tools.md
All matched files use the correct format.

git diff --check

.agents/skills/autoreview/scripts/autoreview --mode uncommitted
autoreview clean: no accepted/actionable findings reported
overall: patch is correct (0.99)

No runtime behavior changes.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: XS triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Aug 1, 2026
…pp endpoints

Custom openai-completions providers pointed at a llama.cpp / llama-server
endpoint bypass the GBNF-safe schema normalization that built-in llama-cpp,
ollama, and lmstudio providers apply automatically. The toolSchemaProfile:
"llamacpp" switch activates it, but the supported value was never named in
the docs, so users hit llama.cpp 400 'failed to parse grammar' on tools with
large minLength/maxLength (e.g. cron trigger.script, maxLength 65536).

- Expand the toolSchemaProfile row to name the values recognized on a model's
  compat (llamacpp, gemini) and when llamacpp must be set explicitly;
  cross-reference the unsupportedToolSchemaKeywords escape hatch.
- Add a 'Local models (llama.cpp / llama-server)' provider example showing
  the required compat.toolSchemaProfile: "llamacpp" on a custom endpoint.

Related to openclaw#117070

Co-Authored-By: iCodeMate <[email protected]>
@SunnyShu0925
SunnyShu0925 force-pushed the docs/llamacpp-tool-schema-profile-117070 branch from 60d6c04 to 93ae825 Compare August 1, 2026 00:16
@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Aug 1, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Aug 1, 2026
@clawsweeper

clawsweeper Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 2:06 AM ET / 06:06 UTC.

ClawSweeper review

What this changes

This PR documents the existing compat.toolSchemaProfile: "llamacpp" setting and adds a custom openai-completions example for llama.cpp llama-server endpoints.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep this PR open for normal maintainer merge. The prior P3 finding is fixed on the current head: the new llama.cpp accordion now precedes LM Studio alphabetically. Current main implements and tests the documented llamacpp cleaner, while current docs still lack the custom-endpoint configuration path; no patch defect was found.

Priority: P3
Reviewed head: b1113aaebdd34eefdc1a6633d822113913477048

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused docs patch with accurate source-backed wording and all prior review findings addressed; only the in-progress exact-head docs check remains before merge.
Proof confidence 🌊 off-meta tidepool Not applicable: Real behavior proof is not required because this PR only changes files under docs/.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Real behavior proof is not required because this PR only changes files under docs/.
Evidence reviewed 8 items PR documentation matches the configuration contract: The proposed reference row names the two profile values used by the current normalizer and the new example applies llamacpp to one custom model entry; the wording accurately limits the cleaner to pattern and large maxLength removal.
Current-main runtime selection: Current main lowercases modelCompat.toolSchemaProfile, recognizes llamacpp, and invokes cleanSchemaForLlamacppGbnf before sending tool schemas.
Cleaner behavior is exact: The cleaner drops every pattern and only maxLength numeric values at or above the 2000 repetition threshold; it does not claim to remove minLength or provide blanket JSON Schema compatibility.
Findings None None.
Security None None.

How this fits together

Custom provider configuration supplies model compatibility declarations before OpenClaw builds tool schemas for an endpoint. The llamacpp declaration routes those schemas through the targeted cleaner, while bundled provider plugins apply equivalent hooks automatically.

flowchart LR
  A[Custom llama-server endpoint] --> B[Custom model configuration]
  B --> C[Tool-schema profile selection]
  C --> D[llama.cpp schema cleaner]
  D --> E[Tool request payload]
  E --> F[OpenAI-compatible llama.cpp server]
Loading

Before merge

  • Resolve merge risk (P1) - The supplied check snapshot still shows check-docs in progress; merge only after that exact-head documentation check completes successfully.
  • Complete next step (P2) - No repair lane is needed because the prior review blocker is fixed and no new defect was found; await the pending docs check and normal maintainer merge.
Agent review details

Security

None.

PR surface

Docs +38. Total +38 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 0 0 0 0
Docs 1 40 2 +38
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 40 2 +38

Review metrics

None.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Merge the targeted custom-provider reference and example after the pending docs check passes, keeping llama.cpp behavior model-level and explicit for arbitrary OpenAI-compatible endpoints.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Merge the targeted custom-provider reference and example after the pending docs check passes, keeping llama.cpp behavior model-level and explicit for arbitrary OpenAI-compatible endpoints.

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

Not applicable: this PR changes documentation only. The described runtime path is directly verified from current source and existing tests rather than requiring a new failing reproduction.

Is this the best way to solve the issue?

Yes. It documents the existing explicit per-model compatibility setting at the custom-provider reference point, avoids a new provider/default, and accurately distinguishes the targeted profile from the broader keyword-removal fallback.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P3: This is a focused documentation improvement for an existing advanced custom-provider compatibility setting and changes no runtime behavior.
  • 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: Real behavior proof is not required because this PR only changes files under docs/.

Evidence

What I checked:

Likely related people:

  • steipete: Introduced the current-main llama.cpp GBNF cleaner and the corresponding tool-schema behavior in the recent AI fix. (role: runtime behavior introducer; confidence: high; commits: a7e0ebe8e68e; files: packages/ai/src/providers/clean-for-llamacpp-gbnf.ts, packages/ai/src/providers/agent-tools-parameter-schema.ts)
  • vincentkoc: Is assigned to this PR and authored the two latest review-driven commits that tightened the documentation contract and corrected provider ordering. (role: recent docs contributor and assignee; confidence: high; commits: 0fc2c856d17c, b1113aaebdd3; files: docs/gateway/config-tools.md)

Rank-up moves

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

  • Wait for the exact-head check-docs run to finish successfully before merging.

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 (5 earlier review cycles)
  • reviewed 2026-08-01T00:22:17.805Z sha 93ae825 :: needs changes before merge. :: [P2] Describe the profile as stripping constraints, not clamping them
  • reviewed 2026-08-01T00:53:38.621Z sha 4ec9e0d :: needs changes before merge. :: [P2] Limit the profile description to its actual transformations
  • reviewed 2026-08-01T01:09:08.559Z sha 02bec17 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-01T01:18:58.859Z sha 02bec17 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-01T05:57:00.129Z sha 0fc2c85 :: needs changes before merge. :: [P3] Order the local-model accordions alphabetically

claude added 2 commits August 1, 2026 08:47
Address review feedback on openclaw#117120: the fallback sentence claimed the
llamacpp profile "also clamps" constraints, but cleanSchemaForLlamacppGbnf
only removes `pattern` outright and drops `maxLength` at or above the
2000-repetition threshold (LLAMACPP_GBNF_MAX_REPETITION_THRESHOLD). It
never clamps a value, and small bounds like `minLength: 1` are preserved
(confirmed by the projection test at src/plugin-sdk/provider-tools.test.ts).

Reword the escape-hatch sentence to describe the implemented stripping
behavior and contrast it with the unconditional keyword-list drops, so
operators do not expect a preserved bounded constraint.

No code or behavior changes; documentation only.
…formations

Address follow-up review on openclaw#117120: the toolSchemaProfile table row
described `llamacpp` as "rewriting tool schemas into the JSON Schema
subset llama.cpp can compile to GBNF," which overstates what
cleanSchemaForLlamacppGbnf does. The cleaner only removes `pattern`
outright and drops `maxLength` at or above the 2000-repetition threshold
(LLAMACPP_GBNF_MAX_REPETITION_THRESHOLD); it leaves every other keyword
and `minLength` untouched, and those are not guaranteed GBNF-safe.

Reword the row to state the exact transformation contract and explicitly
note it is a targeted compatibility cleaner, not a blanket GBNF-safety
guarantee. No code or behavior changes; documentation only.

Co-Authored-By: iCodeMate <[email protected]>
@SunnyShu0925

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added 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. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 1, 2026
@vincentkoc vincentkoc self-assigned this Aug 1, 2026
@vincentkoc

Copy link
Copy Markdown
Member

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. labels Aug 1, 2026
@vincentkoc

Copy link
Copy Markdown
Member

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@vincentkoc

Copy link
Copy Markdown
Member

Final maintainer landing gate for exact head b1113aaebdd34eefdc1a6633d822113913477048:

  • required openclaw/ci-gate: green, including exact-head check-docs
  • ClawSweeper: no findings; its sole rank-up move (check-docs green) is satisfied
  • review threads: 0 unresolved
  • live main: 236407806330238225cdc383c268b47f46a9015d
  • touched-file drift: 0
  • clean synthetic merge tree: 1e7178aa540d5776e5050c6f7e112da4eb86f896
  • docs contract matches the current llamacpp cleaner and bundled-provider hooks

Landing via squash with contributor authorship preserved.

@vincentkoc
vincentkoc merged commit d756014 into openclaw:main Aug 1, 2026
48 checks passed
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 1, 2026
…pp endpoints (openclaw#117120)

* docs(gateway): document llamacpp toolSchemaProfile for custom llama.cpp endpoints

Custom openai-completions providers pointed at a llama.cpp / llama-server
endpoint bypass the GBNF-safe schema normalization that built-in llama-cpp,
ollama, and lmstudio providers apply automatically. The toolSchemaProfile:
"llamacpp" switch activates it, but the supported value was never named in
the docs, so users hit llama.cpp 400 'failed to parse grammar' on tools with
large minLength/maxLength (e.g. cron trigger.script, maxLength 65536).

- Expand the toolSchemaProfile row to name the values recognized on a model's
  compat (llamacpp, gemini) and when llamacpp must be set explicitly;
  cross-reference the unsupportedToolSchemaKeywords escape hatch.
- Add a 'Local models (llama.cpp / llama-server)' provider example showing
  the required compat.toolSchemaProfile: "llamacpp" on a custom endpoint.

Related to openclaw#117070

Co-Authored-By: iCodeMate <[email protected]>

* docs(gateway): describe llamacpp profile as stripping, not clamping

Address review feedback on openclaw#117120: the fallback sentence claimed the
llamacpp profile "also clamps" constraints, but cleanSchemaForLlamacppGbnf
only removes `pattern` outright and drops `maxLength` at or above the
2000-repetition threshold (LLAMACPP_GBNF_MAX_REPETITION_THRESHOLD). It
never clamps a value, and small bounds like `minLength: 1` are preserved
(confirmed by the projection test at src/plugin-sdk/provider-tools.test.ts).

Reword the escape-hatch sentence to describe the implemented stripping
behavior and contrast it with the unconditional keyword-list drops, so
operators do not expect a preserved bounded constraint.

No code or behavior changes; documentation only.

* docs(gateway): scope llamacpp profile description to its actual transformations

Address follow-up review on openclaw#117120: the toolSchemaProfile table row
described `llamacpp` as "rewriting tool schemas into the JSON Schema
subset llama.cpp can compile to GBNF," which overstates what
cleanSchemaForLlamacppGbnf does. The cleaner only removes `pattern`
outright and drops `maxLength` at or above the 2000-repetition threshold
(LLAMACPP_GBNF_MAX_REPETITION_THRESHOLD); it leaves every other keyword
and `minLength` untouched, and those are not guaranteed GBNF-safe.

Reword the row to state the exact transformation contract and explicitly
note it is a targeted compatibility cleaner, not a blanket GBNF-safety
guarantee. No code or behavior changes; documentation only.

Co-Authored-By: iCodeMate <[email protected]>

* docs(gateway): tighten llama.cpp profile contract

* docs(gateway): order local model examples

---------

Co-authored-by: iCodeMate <[email protected]>
Co-authored-by: Vincent Koc <[email protected]>
vincentkoc added a commit to a-tokyo/openclaw that referenced this pull request Aug 1, 2026
…in-4caff51-20260801

* origin/main:
  fix(agents): surface /new guidance for thinking-signature replay errors (openclaw#116967) (openclaw#116987)
  fix(doctor): keep repaired session rows readable (openclaw#117207)
  fix(feishu): unify outbound delivery lifecycle (openclaw#117223)
  docs(gateway): document llamacpp toolSchemaProfile for custom llama.cpp endpoints (openclaw#117120)
  fix(clickclack): thread replies stop being answered past the 100-reply thread window (openclaw#117225)
  fix(talk): retain bounded relay close owners
  fix(talk): bound relay transcript persistence
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 gateway Gateway runtime P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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.

3 participants