Enable Gemma 4 unified thinking by default - #32
Merged
Conversation
atdrendel
commented
Jul 7, 2026
Contributor
- Update mlx-swift-lm to fix tool schemas for Gemma 4
- Update mlx-swift-lm to fix tool schemas for Gemma 4
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates SHLLM’s Gemma 4 integration to align with upstream mlx-swift-lm changes (notably tool schema behavior) and makes Gemma 4 Unified default to “thinking” mode unless explicitly disabled.
Changes:
- Default
enable_thinkingtotrueforLLM.gemma4Unified(...)when the caller does not provide it. - Update Gemma 4 model tests to remove manual
<|think|>prompt tokens and relax assertions that reasoning must be present. - Pin
mlx-swift-lmto a specific revision and updatePackage.resolvedaccordingly.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| Tests/SHLLMTests/Models/Gemma4-E4BTests.swift | Removes `< |
| Tests/SHLLMTests/Models/Gemma4-E2BTests.swift | Same test updates as E4B to match updated Gemma 4 behavior. |
| Tests/SHLLMTests/Models/Gemma4-12BTests.swift | Same test updates for Gemma 4 Unified (12B) tool-call flows. |
| Sources/SHLLM/LLM.swift | Enables “thinking” by default for gemma4Unified via additionalContext mutation. |
| Package.swift / Package.resolved | Pins mlx-swift-lm to a specific commit revision to pick up upstream fixes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
696
to
700
| /// **gemma-4-12b** | ||
| /// | ||
| /// To enable thinking, set | ||
| /// `UserInput(additionalContext: ["enable_thinking": true])` | ||
| /// and add `<|think|>` to the **beginning** and **end** of | ||
| /// the system prompt. (The documentation says to just add it to | ||
| /// the beginning of the system prompt, but testing has shown it | ||
| /// to be more reliable when added to the beginning and end of the | ||
| /// system prompt. | ||
| /// `UserInput(additionalContext: ["enable_thinking": true])`. | ||
| /// |
Comment on lines
709
to
+715
| try SHLLM.assertSupportedDevice | ||
| var input = input | ||
| var additionalContext = input.additionalContext ?? [:] | ||
| if additionalContext["enable_thinking"] == nil { | ||
| additionalContext["enable_thinking"] = true | ||
| } | ||
| input.additionalContext = additionalContext |
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.