From 3e40c63674b3c0f2fa89de3b68ac5adb43ba8d08 Mon Sep 17 00:00:00 2001 From: gongwei-130 <56567052+gongwei-130@users.noreply.github.com> Date: Sat, 6 Dec 2025 06:15:22 -0800 Subject: [PATCH] fix "GrammarMatcher has terminated after accepting the stop token, but is trying to find the next token mask" when both reasoning and spec are enabled (#14464) --- python/sglang/srt/constrained/reasoner_grammar_backend.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/python/sglang/srt/constrained/reasoner_grammar_backend.py b/python/sglang/srt/constrained/reasoner_grammar_backend.py index 5fe7b0c8c..0179d3426 100644 --- a/python/sglang/srt/constrained/reasoner_grammar_backend.py +++ b/python/sglang/srt/constrained/reasoner_grammar_backend.py @@ -51,6 +51,9 @@ class ReasonerGrammarObject(BaseGrammarObject): self.grammar.accept_token(token) self.transfer_state(token) + def is_terminated(self): + return self.grammar.is_terminated() + def rollback(self, k): steps_after_think = min(k, self.tokens_after_think_end) if steps_after_think > 0: