Repository navigation
Description
Bug type
Regression (worked before, now fails)
Beta release blocker
No
Summary
The cron tool's schema in OpenClaw 2026.7.1 contains fields that fail to compile into a valid GBNF grammar under llama.cpp's grammar-constrained tool calling, causing every chat request to fail — not just cron-related ones — whenever the cron tool is present in the active tool list. Three distinct schema issues were found, each masking the next until the previous one was patched:
job.declarationKey has pattern: "\S" — unanchored. llama.cpp requires all pattern values to be fully anchored (^...$); unanchored patterns are rejected with 400: Pattern must start with '^' and end with '$'.
After anchoring to ^\S+$, llama.cpp's regex-to-GBNF converter fails with unknown escape — it doesn't support PCRE shorthand character classes like \S, only a small set of literal escapes (\n, \t, \r, etc.).
After replacing \S with an explicit character class, job.trigger.script.maxLength: 65536 fails GBNF compilation with number of repetitions exceeds sane defaults, please reduce the number of repetitions — llama.cpp enforces a hard repetition ceiling (~2000) for length-bounded string fields under grammar constraints.
Because tool schemas are compiled into a single grammar covering the entire active tool list, one malformed field anywhere in that set blocks all messages on all channels, not just requests that would invoke the affected tool.
Steps to reproduce
Run OpenClaw 2026.7.1 against a llama.cpp llama-server backend with strict JSON-schema grammar tool calling enabled (default for OpenAI-compatible tool calling on llama.cpp).
Ensure the cron tool is enabled/present in the active tool list.
Send any message on any channel.
Expected behavior
The message is processed normally; the model responds, using or ignoring the cron tool as appropriate.
Actual behavior
Every request fails with a 400 from the llama.cpp endpoint. OpenClaw surfaces this generically as LLM request failed: provider rejected the request schema or tool payload. with rawError varying depending on which of the three schema issues is hit first (see Summary). No indication is given of which tool or field caused the failure — diagnosing this required a custom logging proxy to capture the raw outbound request and cross-referencing llama.cpp's own server-side grammar-parse error log.
OpenClaw version
2026.7.1 (2d2ddc4)
Operating system
Ubuntu 24.04, Linux
Install method
npm global install
Model
Qwen3.6-27B
Provider / routing chain
openclaw → llamacpp (OpenAI-compatible /v1/chat/completions) → self-hosted llama-server (latest build, --flash-attn on, grammar-constrained tool calling)
Additional provider/model setup details
No response
Logs
Screenshots, recordings, and evidence
No response
Impact and severity
No response
Additional information
No response
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
brantzh commentedon Jul 16, 2026
operator(): got exception: {"error":{"code":400,"message":"Unable to generate parser for this template. Automatic parser generation failed: JSON schema conversion failed:\nPattern must start with '^' and end with '$'","type":"invalid_request_error"}}
thegoldenflow commentedon Jul 16, 2026
Opened #108671 to fix this.
It removes the three grammar-hostile constructs from the model-facing tool schemas (
src/agents/tools/*), which is what actually reaches llama.cpp —packages/gateway-protocol/src/schema/cron.tsis the RPC validation contract and is never compiled into the model's grammar, so it's deliberately left untouched:cronjob.declarationKey: dropspattern: "\S"(both unanchored and PCRE shorthand).crontrigger.script: dropsmaxLength: 65536(past the ~2000 GBNF repetition ceiling), on both the job and patch branches.spawn_taskprompt/cwd(maxLength32768/4096) andsessions_searchquery(maxLength4096).No validation is weakened — the non-blank and length guarantees still hold server-side (cron gateway handler + RPC
CronDeclarationKeySchema/CronTriggerSchema, the task-suggestions RPC schema, and the sessions_search runtime guard); the byte caps move into each field'sdescription.There's a new generic regression test that walks the real tool schemas (raw and provider-normalized) and asserts every
patternis fully anchored with no PCRE shorthand and everymaxLengthstays under the repetition ceiling, so future model-facing tools in this family are covered as well. It fails on the pre-fix schemas with exactly the reported violations.(Note vs the other open PRs: #107939 and #108469 anchor the pattern but keep the
\Sshorthand, so they still hit the unknown-escape rejection; #108360 removes thedeclarationKeypattern only. None address themaxLengthceiling.)DecentralizedJM commentedon Jul 16, 2026
Update on candidate fix: #108469 (head
8bad86f1dd4) now covers all three #108580 GBNF constraints on model-facing tool schemas, with live before/afterllama-serverproof in the PR body:\\S→ HTTP 400Pattern must start with '^' and end with '$'maxLength: 65536→ HTTP 400 grammar parse failureAlso sweeps
spawn_taskandsessions_searchmaxLength offenders. RPC validation inpackages/gateway-protocol/unchanged.fix(agents): drop llama.cpp-incompatible pattern/maxLength from model…
test(agents): guard model-facing tool schemas against llama.cpp GBNF …
test(agents): regenerate codex prompt snapshots for the tool-schema c…
18 remaining items
aidiffuser commentedon Jul 22, 2026
Confirming this also affects LM Studio (not only raw llama.cpp) on 2026.7.1 stable. After cherry-picking #108360 we found a second grammar-hostile construct in the same schema, still present on
mainat the time of writing.1.
pattern: "\S"(fixed by #108360) — fails schema-to-grammar conversion:2.
trigger.scriptmaxLength: 65536(cron-tool.ts, exit-trigger feature — not yet fixed) — survives conversion but fails sampler initialization:Isolation method, in case it is useful for triage: we binary-searched our live 73-tool request against LM Studio's
/v1/chat/completions(max_tokens: 1probes), which converged on the cron tool; a keep-one bisect inside that schema converged onjob.trigger, whose children all pass individually; A/B probes on the field showmaxLength: 65536fails,4096fails, small values (200) pass, and removingmaxLengthpasses. Large string-length bounds appear to expand into repetition rules that the grammar compiler rejects.Gateway-side symptom (difficult to connect to this root cause from the logs users see): agent/cron turns fail with a generic
LLM request failed.,[empty-error-retry] stopReason=error non-visible-outputexhausts 3 attempts within milliseconds, andmodel-fetchlogs showstatus=200because the error only exists inside the SSE stream. The provider's own server log contains the real message.Suggested fix, following the same reasoning as #108360: remove
maxLengthfrom the model-facing schema; the CLI/server-side validator already enforces the size limit. We have been running that one-line change in production and all grammar-constrained cron runs are healthy.Since stable-channel users with grammar-constrained local engines currently experience silently failing agent turns, a 7.1.x backport of both fixes would be appreciated.
fix(agents): project llama.cpp GBNF-safe tool schemas at provider bou…
zhidanliu-lab commentedon Jul 23, 2026
OpenClaw: 2026.7.2-beta2
Working version: 2026.6.11
Backend:
llama.cpp master 61328e6a9
Model:
Qwen3.6-35B-A3B-UD-Q5_K_XL.gguf
Repro:
400 Failed to initialize samplers: failed to parse grammar
steipete commentedon Jul 29, 2026
Fixed by #115598, merged in 98a066c.
The pattern-related half landed earlier in #108360. #115598 completes the remaining llama.cpp GBNF compatibility fix by projecting tool schemas only for the affected provider family: llama-cpp, LM Studio, and Ollama now strip unsupported patterns and repetition-expanding
maxLengthconstraints, while unrelated providers retain their full schemas.Proof: 204 focused tests passed, autoreview was clean, and the required exact-head CI gate succeeded before merge. This issue is complete.