json-schema-to-grammar : report incomplete-conversion warnings only once - #28598
Open
RIVOIRA wants to merge 1 commit into
Open
json-schema-to-grammar : report incomplete-conversion warnings only once#28598RIVOIRA wants to merge 1 commit into
RIVOIRA wants to merge 1 commit into
Conversation
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".
|
Hi @RIVOIRA, thanks for your contribution! Per our contribution guidelines, the automated PR checker found the following issue(s) that need your attention:
Please note that maintainers reserve the right to make final decisions on PRs. If you believe there is a mistake, please comment below. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
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.cpp→build_chat_peg_parser→build_grammar()), and eachbuild_grammar()call creates a freshcommon_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 aprocess-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