gemma4: fix nothink case renderer (#15553)

Regressed in #15490

Fixes: #15536
This commit is contained in:
Devon Rifkin
2026-04-13 11:23:19 -07:00
committed by GitHub
parent 798fd09bfe
commit 4d75f5da03

View File

@@ -40,6 +40,7 @@ func (r *Gemma4Renderer) Render(messages []api.Message, tools []api.Tool, thinkV
// Emit system turn if there's a system/developer role, tools, or thinking.
hasThink := thinkValue != nil && thinkValue.Bool()
thinkingExplicitlyDisabled := thinkValue != nil && thinkValue.IsBool() && !thinkValue.Bool()
if hasSystemRole || len(tools) > 0 || hasThink {
sb.WriteString("<|turn>system\n")
if hasThink {
@@ -124,7 +125,7 @@ func (r *Gemma4Renderer) Render(messages []api.Message, tools []api.Tool, thinkV
// Generation prompt.
if prevMessageType != "tool_response" && prevMessageType != "tool_call" {
sb.WriteString("<|turn>model\n")
if !hasThink {
if !hasThink && !thinkingExplicitlyDisabled {
sb.WriteString("<|channel>thought\n<channel|>")
}
}