]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commit
chat: harden peg-native tool call parsing (#24329)
authorPascal <redacted>
Mon, 15 Jun 2026 13:37:04 +0000 (15:37 +0200)
committerGitHub <redacted>
Mon, 15 Jun 2026 13:37:04 +0000 (15:37 +0200)
commit581e8eca8b412fd8db4b1d179cb3190bac90bc0d
tree4f36723582d60d76c1c8a52936484cdc655e827f
parent0ae3f450f0c6454277db12f9659e7ac11ca081c0
chat: harden peg-native tool call parsing (#24329)

* chat: harden peg-native tool call parsing

accept an optional leading type: function field in
build_json_tools_flat_keys so openai style tool calls parse on
templates whose serialization opens on the name field.

return a clean error and log the unparsed fragment on a final peg
parse failure instead of throwing the raw parser position and input.

keep the raw arguments string in func_args_not_string when it is not
valid json instead of aborting the prompt render.

* chat: surface peg-native parse failures

a final peg parse failure threw the raw parser position and input. log
the unparsed fragment and raise a clearer error instead, so a model
output that does not match the expected format no longer fails silently
with an empty assistant turn.

minimal change, no behavior change on successful parses.

* chat: handle openai style tool calls in peg-native

* nits

* common: scope OpenAI wrapper grammar trigger via autoparser flag

* chat: gate type:function parsing leniency on the analysis flag

Thread accept_openai_wrapper from the generator to build_json_tools_flat_keys
so the leading "type": "function" field is accepted only when openai_wrapper_trigger is set.
common/chat-auto-parser-generator.cpp
common/chat-auto-parser.h
common/chat-diff-analyzer.cpp
common/chat-peg-parser.cpp
common/chat-peg-parser.h
common/chat.cpp