fix(spec): track current_token in ReasonerGrammarObject (#29102)
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
da0f4f6f92
commit
13b5bd962a
@@ -109,6 +109,14 @@ class ReasonerGrammarObject(BaseGrammarObject):
|
||||
self.tokens_after_end -= 1
|
||||
|
||||
def accept_token(self, token: int):
|
||||
# Track the last accepted token on the wrapper itself (mirroring
|
||||
# XGrammarGrammar.accept_token). Disaggregation's process_prebuilt uses
|
||||
# `grammar.current_token is None` to detect a retracted request whose
|
||||
# token was already accepted and must not be re-accepted. Without this,
|
||||
# a ReasonerGrammarObject's current_token stays None forever (the inner
|
||||
# grammar's is updated, not the wrapper's), so the guard never fires and
|
||||
# the token is accepted twice -> "Tokens not accepted" -> FINISH_ABORT.
|
||||
self.current_token = token
|
||||
if self._is_generation() and self.grammar is not None:
|
||||
self.grammar.accept_token(token)
|
||||
self.transfer_state(token)
|
||||
|
||||
Reference in New Issue
Block a user