diff --git a/comfy_extras/nodes_textgen.py b/comfy_extras/nodes_textgen.py index b4f793f9a..0d4cf3a2b 100644 --- a/comfy_extras/nodes_textgen.py +++ b/comfy_extras/nodes_textgen.py @@ -71,7 +71,15 @@ class TextGenerate(io.ComfyNode): seed=seed ) - generated_text = clip.decode(generated_ids, skip_special_tokens=True) + generated_text = clip.decode(generated_ids, skip_special_tokens=not thinking) + + if thinking: + # Translate Gemma4 thinking channel markers to standard / tags + generated_text = generated_text.replace("<|channel>thought\n", "\n") + generated_text = generated_text.replace("", "") + # Strip remaining special tokens + generated_text = generated_text.replace("", "").replace("", "").strip() + return io.NodeOutput(generated_text)