Skip to content

json-schema-to-grammar : report incomplete-conversion warnings only once - #28598

Open
RIVOIRA wants to merge 1 commit into
ggml-org:masterfrom
RIVOIRA:json-schema-warn-once
Open

json-schema-to-grammar : report incomplete-conversion warnings only once#28598
RIVOIRA wants to merge 1 commit into
ggml-org:masterfrom
RIVOIRA:json-schema-warn-once

Conversation

@RIVOIRA

@RIVOIRA RIVOIRA commented Sep 8, 2026

Copy link
Copy Markdown

In llama-server the tool-call grammar is (re)built on every request (common/chat.cpp build_chat_peg_parser -> build_grammar), so a tool schema containing a regex pattern with no grammar equivalent (e.g. a lookahead, as in some agentic clients' tool definitions) logs a "WARNING: JSON schema conversion was incomplete" line on every request.

Report each distinct warning only once per process; repeats are suppressed. Behavior is unchanged otherwise - the affected fields still fall back to "any string".

Overview

Problem

llama-server logs one

WARNING: JSON schema conversion was incomplete: pattern … is not supported (unsupported group syntax), accepting any string

line per request whenever a tool schema contains a regex pattern with no
grammar equivalent (lookaheads (?!…) / (?=…) / (?<!…), named groups, …).
Such patterns appear in real agentic clients' tool definitions (path-segment
validation regexes), so a server serving one such client spams the log once
per turn — in a short session: 74 warning lines for 78 tasks.

Why it repeats

The tool-call grammar is (re)built on every request
(common/chat.cppbuild_chat_peg_parserbuild_grammar()), and each
build_grammar() call creates a fresh common_schema_converter.
check_errors() therefore re-emits the same warning on every request.

Fix

Report each distinct warning once per process: check_errors() now keeps a
process-wide set of already-emitted warning strings (guarded by a mutex).
First occurrence still prints the usual WARNING line; repeats are suppressed.

No behavior change: the affected fields still fall back to "any string", and
the full diagnostic (with the offending pattern) is in the log from the first
occurrence.

A follow-up could cache the compiled grammar keyed on the tool schema to
avoid the per-request rebuild altogether; that is a much larger change and is
out of scope here.

Requirements

  • I have read and agree with the contributing guidelines
  • AI usage disclosure: YES — Claude Code was used to investigate the warning and draft the patch. I reviewed the change and verified it locally before submitting (unit test + functional before/after comparison).

In llama-server the tool-call grammar is (re)built on every request
(common/chat.cpp build_chat_peg_parser -> build_grammar), so a tool
schema containing a regex pattern with no grammar equivalent (e.g. a
lookahead, as in some agentic clients' tool definitions) logs a
"WARNING: JSON schema conversion was incomplete" line on every request.

Report each distinct warning only once per process; repeats are
suppressed. Behavior is unchanged otherwise - the affected fields
still fall back to "any string".
@RIVOIRA
RIVOIRA requested a review from a team as a code owner September 8, 2026 09:14
@ggml-gh-bot

ggml-gh-bot Bot commented Sep 8, 2026

Copy link
Copy Markdown

Hi @RIVOIRA, thanks for your contribution!

Per our contribution guidelines, the automated PR checker found the following issue(s) that need your attention:

  • AI-generated content: While code is allowed to be generated by AI, please write the PR description and commit messages on your own without the help of AI.

Please note that maintainers reserve the right to make final decisions on PRs. If you believe there is a mistake, please comment below.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant