[Bugfix][Structured Output] Mask request stop tokens in xgrammar until grammar terminates (#49227)

Signed-off-by: sfeng33 <4florafeng@gmail.com>
This commit is contained in:
Flora Feng
2026-08-10 14:29:20 -04:00
committed by GitHub
parent 405bc86768
commit 05f0a80016
7 changed files with 114 additions and 6 deletions
+8 -1
View File
@@ -184,7 +184,14 @@ class StructuredOutputManager:
try:
request_type, grammar_spec = struct_request.structured_output_key
assert self.backend is not None
return self.backend.compile_grammar(request_type, grammar_spec)
stop_token_ids = (
request.sampling_params.all_stop_token_ids
if request.sampling_params is not None
else None
)
return self.backend.compile_grammar(
request_type, grammar_spec, stop_token_ids=stop_token_ids
)
except Exception:
logger.exception(
"Failed to compile grammar for request %s", request.request_id