Skip to content

[Bug]: cron tool JSON Schema is incompatible with llama.cpp tool parser (pattern: "\S") #107449

Closed

Description

@Patt92

Bug type

Regression (worked before, now fails)

Beta release blocker

No

Summary

Environment

  • OpenClaw: 2026.7.1
  • llama.cpp: b9997 (cb489bc0f)
  • LiteLLM (OpenAI-compatible)
  • llama-swap

Problem

OpenClaw sends a tool schema for the built-in cron tool that contains:
json

"declarationKey": {
  "type": "string",
  "minLength": 1,
  "maxLength": 200,
  "pattern": "\\S"
}

Steps to reproduce

Configure the request path, for example:
OpenClaw → LiteLLM (optional) → llama.cpp

Use a recent llama.cpp build:
version 9997
commit cb489bc0f

Send a normal chat-completions request with OpenClaw’s built-in tools enabled, cron disabled.
Verify that the request succeeds.
Add the built-in cron tool to the same request.

Expected behavior

Adding the built-in cron tool should not make otherwise valid chat completion requests fail. The generated tool schema should be accepted by OpenAI-compatible backends, including llama.cpp.
Since minLength: 1 is already present, the pattern: "\S" constraint appears unnecessary and could be removed, or replaced with a regex compatible with llama.cpp’s supported JSON Schema subset.

Actual behavior

Status Code 400 on llama.cpp end
Unable to generate parser for this template.
Automatic parser generation failed:
JSON schema conversion failed:
Pattern must start with '^' and end with '$'

OpenClaw version

2026.7.1

Operating system

macOS 26.5.2 + Debian 13

Install method

mac app, debian user-based setup

Model

ornith-1.0-35b,minimax-m2.7

Provider / routing chain

OpenClaw → LiteLLM → llama.cpp

Additional provider/model setup details

you can left out LiteLLM in that path as the error generate out of llama.cpp

Logs

2:01:55 - LiteLLM Proxy:ERROR: common_request_processing.py:741 - litellm.proxy.proxy_server._handle_llm_api_exception(): Exception occured - litellm.BadRequestError: OpenAIException - Unable to generate parser for this template. Automatic parser generation failed: JSON schema conversion failed:
Pattern must start with '^' and end with '$'. Received Model Group=coder
Available Model Group Fallbacks=None
Traceback (most recent call last):
  File "/app/.venv/lib/python3.13/site-packages/litellm/llms/openai/openai.py", line 1065, in async_streaming
    headers, response = await self.make_openai_chat_completion_request(
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<4 lines>...
    )
    ^
  File "/app/.venv/lib/python3.13/site-packages/litellm/litellm_core_utils/logging_utils.py", line 289, in async_wrapper
    result = await func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.13/site-packages/litellm/llms/openai/openai.py", line 447, in make_openai_chat_completion_request
    raise e
  File "/app/.venv/lib/python3.13/site-packages/litellm/llms/openai/openai.py", line 427, in make_openai_chat_completion_request
    raw_response = await openai_aclient.chat.completions.with_raw_response.create(**data, timeout=timeout)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.13/site-packages/openai/_legacy_response.py", line 384, in wrapped
    return cast(LegacyAPIResponse[R], await func(*args, **kwargs))
                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.13/site-packages/openai/resources/chat/completions/completions.py", line 2714, in create
    return await self._post(
           ^^^^^^^^^^^^^^^^^
    ...<49 lines>...
    )
    ^
  File "/app/.venv/lib/python3.13/site-packages/openai/_base_client.py", line 1913, in post
    return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.13/site-packages/openai/_base_client.py", line 1698, in request
    raise self._make_status_error_from_response(err.response) from None
openai.BadRequestError: Error code: 400 - {'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'}}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/app/.venv/lib/python3.13/site-packages/litellm/main.py", line 639, in acompletion
    response = await init_response
               ^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.13/site-packages/litellm/llms/openai/openai.py", line 1115, in async_streaming
    raise OpenAIError(
    ...<4 lines>...
    )
litellm.llms.openai.common_utils.OpenAIError: Error code: 400 - {'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'}}

Screenshots, recordings, and evidence

No response

Impact and severity

No response

Additional information

No response

Activity

  1. Artyomkun commented on Jul 14, 2026

    @Artyomkun

    This is a llama.cpp parser limitation, not an OpenClaw bug. \S is a valid JSON Schema pattern. If llama.cpp requires ^...$, it should be fixed there. OpenClaw shouldn't have to special-case each backend."

  2. Patt92 commented on Jul 14, 2026

    @Patt92
    Author

    I agree that \S is a valid JSON Schema pattern.

    However, this appears to be a regression from the OpenClaw side from a user perspective. The exact same setup (LiteLLM → llama-swap → llama.cpp) worked with OpenClaw 2026.6.11 and started failing after upgrading to 2026.7.1.

    I bisected the generated tool schemas and isolated the failure to the built-in cron tool. Removing only cron makes the same request succeed again.

    So while llama.cpp is stricter than some providers, OpenClaw changed something that now triggers this incompatibility. Since llama.cpp is a commonly used local OpenAI-compatible backend, I think it’s worth considering whether the generated schema can be made more portable, or at least documenting the limitation

  3. Artyomkun commented on Jul 14, 2026

    @Artyomkun

    I see your point — and you're right that \S is valid JSON Schema.

    But the fact that it worked in 2026.6.11 and broke in 2026.7.1 makes it a regression on the OpenClaw side, even if the root cause is in llama.cpp's parser.

    The change that introduced this pattern wasn't tested against real backends — and that's the core process issue here.

    I agree with your suggestion: since minLength: 1 already covers the intent, pattern: "\S" is redundant and can be removed.

    That way, we:

    • Keep the schema valid
    • Restore compatibility with llama.cpp
    • Avoid making OpenClaw special-case each backend
  4. Artyomkun commented on Jul 14, 2026

    @Artyomkun

    And if I wrote, I would write zod schemes

  5. added a commit that references this issue on Jul 14, 2026
    c66c7a0
  6. tyukara commented on Jul 14, 2026

    @tyukara

    Hi, I experienced the exact same issue within hours of the v2026.7.1 release.

    Setup: LM Studio + Qwen3.6-35B-A3B
    Error received:

    Engine protocol predict request returned 400: {"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 '$'"... Error Data: n/a, Additional Data: n/a}
    

    I rolled back the version temporarily and am currently running on a prior release without issues. Just wanted to add my confirmation that this affects real-world local setups too — not just LiteLLM proxy paths.

  7. Patt92 commented on Jul 14, 2026

    @Patt92
    Author

    also comment in #106779
    #106779 (comment) is a compat fix, which works.
    I applied a fix on the other end as a callback in LiteLLM, but adding the compat settings in model section is less work, except you have lots of models

    llamacpp_schema_compat.py

  8. clawsweeper commented on Jul 14, 2026

    @clawsweeper
    Contributor

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed July 14, 2026, 12:08 PM ET / 16:08 UTC.

    Summary
    Keep this issue open: multiple users reproduced the v2026.7.1 local-provider regression, and the linked closing PR remains open rather than merged. The report should stay canonical until that repair or a narrower replacement is proven and lands.

    Reproducibility: yes. at source level: include the cron schema containing pattern "\S" in an OpenAI-compatible request to the cited llama.cpp builds and the backend rejects schema conversion with the reported anchored-pattern error. A fresh current-main live run was not captured in this review.

    Root-cause cluster
    Relationship: canonical
    Canonical: #107449
    Summary: This issue provides the precise schema-level root cause; two broader reports show the same failure, while the open PR is the candidate repair.

    Members:

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

    Next step
    The open closing PR already owns the implementation path, so maintainers should review its validation semantics and request real backend proof rather than queueing another fix PR.

    Review details

    Best possible solution:

    Preserve the intended nonblank-string contract with a llama.cpp-compatible anchored constraint or an established centralized schema-compatibility path, add focused generated-schema coverage, and prove a real request against llama.cpp or LM Studio before landing the linked PR or a replacement.

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

    Yes at source level: include the cron schema containing pattern "\S" in an OpenAI-compatible request to the cited llama.cpp builds and the backend rejects schema conversion with the reported anchored-pattern error. A fresh current-main live run was not captured in this review.

    Is this the best way to solve the issue?

    No, wholesale removal is not yet proven to be the best fix because it weakens nonblank validation across shared schemas; preserving that contract with an anchored portable pattern or established compatibility normalization is safer.

    AGENTS.md: found and applied where relevant.

    Remaining risk / open question:

    • The open repair removes non-whitespace validation from several shared schemas; minLength: 1 rejects empty strings but still accepts whitespace-only values.
    • The PR body demonstrates the generated schema change but does not yet show an after-fix request succeeding against llama.cpp or LM Studio.

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

    Label changes

    Label changes:

    • add P1: The v2026.7.1 regression prevents affected local OpenAI-compatible providers from completing agent requests whenever the incompatible tool schema is included.
    • add impact:auth-provider: The failure affects provider/model interoperability and causes configured llama.cpp and LM Studio routes to reject requests before generation.
    • add issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.
    • add clawsweeper:source-repro: Current issue advisory state selects this label.
    • add clawsweeper:linked-pr-open: Current issue advisory state selects this label.
    • add clawsweeper:no-new-fix-pr: Current issue advisory state selects this label.

    Label justifications:

    • P1: The v2026.7.1 regression prevents affected local OpenAI-compatible providers from completing agent requests whenever the incompatible tool schema is included.
    • impact:auth-provider: The failure affects provider/model interoperability and causes configured llama.cpp and LM Studio routes to reject requests before generation.
    Evidence reviewed

    What I checked:

    • Current schema surface: The supplied current-main review context identifies the cron declarationKey schema as still emitting pattern "\S", which llama.cpp rejects because its parser requires anchored patterns. (src/agents/tools/cron-tool.ts:272, 6de8aa6f9b75)
    • Shipped regression reports: The reporter states that the same routing chain worked with v2026.6.11 and began failing after upgrading to v2026.7.1; another user independently confirmed the same 400 response with LM Studio and rolled back successfully. (2d2ddc43d0dc)
    • Open candidate fix: The linked closing PR removes the pattern constraints from the cron tool and shared gateway schemas, but it is still open and therefore must not be treated as an implemented fix. (src/agents/tools/cron-tool.ts:272, 055777aa1d5d)
    • Shared-schema scope: The candidate repair also changes NonBlankString, cron declaration/display-name schemas, and SuspensionTokenSchema, so review must confirm that allowing whitespace-only values is intentional rather than an accidental semantic weakening. (packages/gateway-protocol/src/schema/cron.ts, 055777aa1d5d)
    • Existing workaround: The reporter positively confirmed that the model compatibility settings discussed in Issue with 2026.7.1 #106779 work, although configuring many models or applying a LiteLLM callback creates avoidable operator burden.

    Likely related people:

    • lee-xydt: Authored the current focused repair commit and the earlier iterations addressing the affected cron and gateway schema files. (role: candidate fix author; confidence: high; commits: 055777aa1d5d, c66c7a033e18; files: src/agents/tools/cron-tool.ts, packages/gateway-protocol/src/schema/cron.ts, packages/gateway-protocol/src/schema/gateway-suspend.ts)
    How this review workflow works
    • 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.
  9. added
    P1High-priority user-facing bug, regression, or broken workflow.
    impact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.
    issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.
    clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.
    on Jul 14, 2026
  10. 6 remaining items

  11. lsr911 commented on Jul 15, 2026

    @lsr911
    Contributor

    Severity Assessment

    This is a regression from 2026.6.11 → 2026.7.1 that blocks ALL llama.cpp / LM Studio / llama-swap users from upgrading. The built-in cron tool generates JSON Schema with unanchored pattern: "\S" which llama.cpp's parser rejects with:

    Pattern must start with '^' and end with '$'
    

    Impact:

    Proposed fix: PR #107939 — 3 files, +5/−5 lines, 325 tests passing, clean branch from latest upstream/main

    packages/gateway-protocol/src/schema/cron.ts        | 3 patterns anchored
    packages/gateway-protocol/src/schema/gateway-suspend.ts | 1 pattern anchored
    src/agents/tools/cron-tool.ts                       | 1 pattern anchored
    

    The change is minimal and semantically identical — \S → ^.*\S.*$ (same meaning: "at least one non-whitespace character" — with proper anchors)

    @steipete Could you take a look when you have a moment? This is a small, low-risk fix that unblocks a significant portion of self-hosted users.

  12. lsr911 commented on Jul 15, 2026

    @lsr911
    Contributor

    PR comparison: two approaches to the same fix

    There are now two PRs addressing this regression:

    #107939 (anchors) #108144 (removal)
    Approach \S → ^.*\S.*$ Remove pattern entirely
    Coverage 5 patterns in 4 files 1 pattern (only cron-tool.ts)
    Gateway-protocol schemas ✅ NonBlankString, DeclarationKey, DisplayName, SuspensionToken ❌ Not covered
    Semantic preservation ✅ Exact same behavior ⚠️ Whitespace-only strings now pass (e.g. " ")
    llama.cpp compat ✅ ✅

    Key difference: #108144 only removes the pattern from cron-tool.ts — the AI-facing tool schema. But the same \S patterns exist in 4 other locations in gateway-protocol/src/schema/ (cron.ts ×3, gateway-suspend.ts ×1). These gateway-protocol schemas are used for RPC validation and would still cause issues if ever exposed through a future API surface.

    Recommendation: #107939 is the complete fix. It anchors all 5 patterns while preserving identical validation semantics. The anchor approach (^.*\S.*$) keeps the "at least one non-whitespace character" guard — minLength: 1 alone allows whitespace-only strings through.

  13. Patt92 commented on Jul 15, 2026

    @Patt92
    Author

    +1 from my side. PR #107939 is the better approach. It covers the \S pattern while remaining compatible with llama.cpp.

    I also agree that the severity should be considered high. This issue doesn’t just affect a niche setup—it impacts everyone using local llama.cpp/llama-server backends, which is a fairly common deployment option. As a result, it affects a significant number of users relying on local inference.

  14. added a commit that references this issue on Jul 16, 2026
    006e13f
  15. added a commit that references this issue on Jul 16, 2026
    c6a9f53
  16. added a commit that references this issue on Jul 17, 2026
    29185a4
  17. locked as resolved and limited conversation to collaborators on Sep 5, 2026
  18. added a commit that references this issue on Sep 11, 2026
    585074c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High-priority user-facing bug, regression, or broken workflow.bugSomething isn't workingclawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.regressionBehavior that previously worked and now fails

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions