common/peg : implement ac parser for stricter grammar generation#24869
Merged
Conversation
pwilkin
approved these changes
Jun 21, 2026
ngxson
approved these changes
Jun 21, 2026
Contributor
|
Tested, seams to work |
Contributor
|
This might be expected behavior, but I still occasionally get in <tool_call>
<function=bash>
<parameter=command>
git fetch
</parameter>
</function>
</tool_call> ./build/bin/llama-server --version
version: 9755 (0ef6f06d5)
built with GNU 16.1.1 for Linux x86_64 |
Contributor
Author
|
@mtasic85 appears to be a well formed tool call. Do you see this in the content or thinking? |
Contributor
|
This is seen in the content. Thinking was disabled. |
Contributor
Author
|
@mtasic85 can you provide any verbose logs of the server when this occurs? I'm having a hard time finding a way to reproduce. I don't have a reason to believe it's related to the change here but may be related to the earlier whitespace updates. |
papamoose
pushed a commit
to papamoose/llama.cpp
that referenced
this pull request
Jun 27, 2026
…l-org#24869) * common/peg : implement ac parser * cont : extract functions * cont : tidy up * cont : remove a test * cont : move ac() def
adrianhoehne
pushed a commit
to adrianhoehne/llama.cpp
that referenced
this pull request
Jul 5, 2026
…l-org#24869) * common/peg : implement ac parser * cont : extract functions * cont : tidy up * cont : remove a test * cont : move ac() def
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.
Overview
Even after #24839, users are still seeing the model escape the grammar. It's because the exclusion grammar can accept a partial prefix of the delimiter and each use of
until(delim)is typically followed by aliteral(delim).This PR uses the same AC type and adds an including variant: consume all characters up to and including a delimiter. This way it terminates on first occurrence of
\n</parameter>\n.Fixes #24863
Additional information
New parser:
Requirements