[Bugfix][Parser] Stop re-parsing the whole GLM tool argument per chunk (#61253)

Signed-off-by: Maroon Ayoub <mayoub@redhat.com>
Co-authored-by: Flora Feng <4florafeng@gmail.com>
This commit is contained in:
Maroon Ayoub
2026-10-12 21:28:35 +00:00
committed by GitHub
co-authored by Flora Feng
parent 69d54eb078
commit 44f0ddfd7b
5 changed files with 226 additions and 26 deletions
@@ -24,6 +24,10 @@ from functools import cached_property
from vllm.parser.engine.events import EventType
# Maps a raw argument delta to the JSON text it appends to the open trailing
# value, or returns None when the delta may change anything else.
ArgValueExtender = Callable[[str], str | None]
class ParserState(Enum):
CONTENT = auto()
@@ -90,6 +94,11 @@ class ParserEngineConfig:
arg_structural_chars: frozenset[str] | None = None
# Called with the raw argument text when its converted JSON ends in an
# open value; returns an extender for that value, or None. Streaming
# skips ``arg_converter`` for every delta the extender accepts.
arg_value_extender: Callable[[str], ArgValueExtender | None] | None = None
# Special tokens exempt from auto-drop but not state-machine terminals.
preserve_tokens: frozenset[str] = field(default_factory=frozenset)