[Bugfix][Structured Output] Avoid spurious FSM errors after speculative reasoning end (#53046)

Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
This commit is contained in:
Chauncey
2026-08-21 10:01:06 +08:00
committed by GitHub
parent 83c5d59209
commit c6e19b3be2
2 changed files with 8 additions and 2 deletions
+6 -1
View File
@@ -326,7 +326,12 @@ class StructuredOutputManager:
advance_grammar = False
post_reasoning_end_in_window = True
if advance_grammar and not grammar.is_terminated():
accepted = grammar.accept_tokens(req_id, [token])
if post_reasoning_end_in_window:
accepted = bool(grammar.validate_tokens([token]))
if accepted:
accepted = grammar.accept_tokens(req_id, [token])
else:
accepted = grammar.accept_tokens(req_id, [token])
if accepted:
state_advancements += 1
elif not post_reasoning_end_in_window: