Repository navigation
Add reasoning streaming events and support Gemma 4 channels #563
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
davidkoski
merged 13 commits into
ml-explore:main
from
abra-code:reasoning-generation-events
Oct 28, 2026
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
b4e7e45
Support Gemma 4's labeled reasoning channels
abra-code 107245d
Resolve the think-then-call gate through the template's own default
abra-code cda84ef
Add reasoning on the streaming API as Generation.reasoning
abra-code 5e528bc
Shorten the comments and add new tests
abra-code 6f8cb43
Match reasoning delimiters by token id and prime only at the prompt's…
abra-code 4ced797
Fix the Swift 6.3 build of ChatSession
abra-code fa89b26
Match a reasoning exit tag by token id
abra-code 69d3bff
Merge branch 'main' into reasoning-generation-events
abra-code ef0bddc
Merge branch 'main' into reasoning-generation-events
abra-code e3e49db
Merge remote-tracking branch 'upstream/main' into reasoning-generatio…
abra-code c93d8f8
Replay recorded reasoning for every model
abra-code cebc965
Read the prompt for reasoning priming before the prefill
abra-code 69071be
End a Gemma 4 thought on <|tool_call>
abra-code File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is hooked up in Qwen3VLMessageGenerator, but I don't see it anywhere else.
For other models that support reasoning, maybe add this in the default implementation:
models / templates that want it will pick it up, those that don't won't.
Does it need to be added to other
MessageGeneratorimplementations? GPTOSS, Gemma4, etc?I will attach repro tests to illustrate. See qwen3LLMGeneratorDropsReasoning and qwen3LLMToolLoopRewindsCache.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, that was a behavior change. The default MessageGenerator.generate(message:) and Gemma4MessageGenerator now pass message.reasoning as reasoning_content. Your tool-loop repros are in ReasoningReplayTests and keep the cache. They also showed a whitespace issue: a newline before the close could stream as reasoning so Gemma's re-render doubled it. A thought's trailing whitespace is now held until the close so the recorded thought does not depend on token boundaries.
See the fixes here: c93d8f8