[Bugfix][Structured Output] Mask grammar-invalid implicit reasoning ends (#61574)

Signed-off-by: Maroon Ayoub <mayoub@redhat.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Robert Shaw <114415538+robertgshaw2-redhat@users.noreply.github.com>
This commit is contained in:
Maroon Ayoub
2026-10-16 12:53:41 +08:00
committed by GitHub
co-authored by Claude Robert Shaw
parent 92dc3dd393
commit 4ac1f8d2ac
7 changed files with 198 additions and 20 deletions
+4 -1
View File
@@ -161,12 +161,15 @@ class TestReasoningEndTokenIds:
)
engine = _make_engine(cfg)
assert engine.reasoning_end_token_ids == {201, 202}
assert engine.implicit_reasoning_end_token_ids == {202}
assert engine.find_reasoning_end([5, 201]) == ReasoningEnd(1, False)
assert engine.find_reasoning_end([5, 202]) == ReasoningEnd(1, True)
def test_transition_staying_in_reasoning_is_ignored(self):
cfg = _with_reasoning_exits(("THINK_START", ParserState.REASONING, ()))
assert _make_engine(cfg).reasoning_end_token_ids == {201}
engine = _make_engine(cfg)
assert engine.reasoning_end_token_ids == {201}
assert engine.implicit_reasoning_end_token_ids == frozenset()
def test_unreported_exit_fails_closed(self):
cfg = _with_reasoning_exits(