[Bugfix][Gemma4] Pre-initialise streaming reasoning state when prompt ends inside an open <|channel> (fixes #45834) (#45852)

Signed-off-by: nikhilesh-csa <nchhetri@csa1.com>
This commit is contained in:
Nikhilesh Chhetri
2026-06-17 06:16:02 -04:00
committed by GitHub
parent 68ff30d40e
commit 3c6084bb0d
6 changed files with 270 additions and 0 deletions
+7
View File
@@ -758,6 +758,13 @@ class DelegatingParser(Parser):
prompt_token_ids
):
state.reasoning_ended = True
else:
# Reasoning is still open at the end of the prompt; let the
# reasoning parser adjust its initial parsing state so the
# first generated tokens are classified correctly.
self._reasoning_parser.adjust_initial_state_from_prompt(
prompt_token_ids
)
current_text, current_token_ids = state.advance(delta_text, delta_token_ids)
delta_message: DeltaMessage | None = None