Repository navigation
fix(cli): restore the Gemma 4 thought opener after a tool response - #1672
Merged
RemiliaForever (RemiliaForever) merged 1 commit intoNov 24, 2026
Merged
RemiliaForever (RemiliaForever) merged 1 commit into
RemiliaForever (RemiliaForever) merged 1 commit into
Conversation
4 tasks done
Erin Genovy (jefgen)
marked this pull request as ready for review
November 15, 2026 10:56
RemiliaForever (RemiliaForever)
approved these changes
Nov 24, 2026
Contributor
Author
|
Thank you so much for reviewing! I took a quick look at the failing CI build and I wonder if this might be related to the path limit. Build SDK (Windows) failed while compiling the Rust tokenizer dependency.
The output path exceeds the Windows 260-character limit. A possible fix might be to move Cargo's target directory to a shorter path, such as |
After a tool response, Gemma 4's chat template ends the prompt with <|channel>thought\n, so the model starts inside the thought channel and only emits <channel|>. thinkfsm never entered thinking: the reasoning leaked into content with a stray <channel|>, and reasoning_content was empty. Replay the opener as the three tokens the Splitter matches, as RestoreOpener already does for <think>, so the Splitter and reasoning_format=none see the same thought channel as after a user message. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Signed-off-by: Erin Genovy <29107334+jefgen@users.noreply.github.com> Signed-off-by: RemiliaForever <remilia@koumakan.cc>
RemiliaForever (RemiliaForever)
force-pushed
the
fix/gemma4-thought-opener
branch
from
November 24, 2026 06:52
362cda1 to
c7fc449
Compare
RemiliaForever (RemiliaForever)
merged commit Nov 24, 2026
cbc93b3
into
qualcomm:main
40 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thank you RichardDong1225 for your comment on #1660, and thank you RemiliaForever (@RemiliaForever) for the
RestoreOpenerfix in 209be3d! 😊I was able to get GenieX building from source on Windows ARM64, and wanted to help out. This PR is my attempt to contribute back a fix for #1660.
This only changes
RestoreOpenerincli/internal/thinkfsm, and its test.After a tool response, Gemma 4's chat template ends the prompt with
<|channel>thought\n, so the model starts inside the thought channel and only generates the closing<channel|>. The splitter enters thinking only on the<|channel>,thoughtand\ntokens it sees, so the thinking goes tocontent, ending in a stray<channel|>, andreasoning_contentstays empty.RestoreOpeneralready covers prompts that end in<think>; this extends it to Gemma 4's opener.Summary
RestoreOpeneralso replays<|channel>,thoughtand\n, as the three tokens the splitter matches, when the prompt ends with<|channel>thought\n.TestRestoreOpenergains that case.reasoning_format: none, content after a tool response now starts with the opener, as it already does after a user message.Test plan
bazelisk test //cli/... //bindings/go/... --//sdk:sdk_type=local --test_output=errors --test_summary=terse -- -//cli/release/...: 18 pass, and the 10_posixtests are skipped, as on Windows CI.qualcomm-ai-hub-community/Gemma-4-E4B-it-Hi-Fi-fraQtl:Q4_K_M: sent the Gemma 4: thinking leaks into content after a tool response, ending in a stray <channel|> #1660 request, and the same with text beside the tool call, blocking and streaming. On v0.11.0 all four replies leaked; on this branch all four split, with no<channel|>in content. A user-message request split on both.reasoning_content.Fixes #1660
Co-authored by Copilot + Human.