Support optional removal of <think> tags and reasoning blocks via LLM_NODE_THINKING_TAGS_ENABLED #15108

Closed
opened 2026-02-21 19:20:12 -05:00 by yindo · 1 comment
Owner

Originally created by @ultramancode on GitHub (Jul 3, 2025).

Self Checks

  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

1. Is this request related to a challenge you're experiencing? Tell me about your story.

I'm building a chat-flow where multiple LLMs are chained together.
One model (e.g. Qwen-3.0) outputs its reasoning inside
<think>reasoning process...</think>
blocks, while another model (e.g. Gemini-2.0) does not.

When the flow continues to the next node (code-executor, tool parser, etc.),
the raw <think></think> tags and reasoning blocks cause parsing errors and unpredictable behavior.
Maintaining ad-hoc regex cleansers after every LLM node is fragile and error-prone.

2. Additional context or comments

I propose adding a single environment variable called LLM_NODE_THINKING_TAGS_ENABLED.
If you leave it at its default value (true), Dify keeps behaving exactly as it does today and the blocks remain visible.
If you set the variable to false, the LLMNode quietly strips out every <think></think> reasoning segment before the text reaches the next node, so mixed-model flows parse cleanly.

It addresses both sides of the long-running discussion: people who need the reasoning can keep it, and anyone who just wants a clean answer can switch it off with no code changes.

Fixes #13419
Related: #13107, #18556

3. Can you help us with this feature?

  • I am interested in contributing to this feature.
Originally created by @ultramancode on GitHub (Jul 3, 2025). ### Self Checks - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [x] Please do not modify this template :) and fill in all the required fields. ### 1. Is this request related to a challenge you're experiencing? Tell me about your story. I'm building a chat-flow where multiple LLMs are chained together. One model (e.g. Qwen-3.0) outputs its reasoning inside &lt;think&gt;reasoning process...&lt;/think&gt; blocks, while another model (e.g. Gemini-2.0) does not. When the flow continues to the next node (code-executor, tool parser, etc.), the raw &lt;think&gt;&lt;/think&gt; tags and reasoning blocks cause parsing errors and unpredictable behavior. Maintaining ad-hoc regex cleansers after every LLM node is fragile and error-prone. ### 2. Additional context or comments I propose adding a single environment variable called LLM_NODE_THINKING_TAGS_ENABLED. If you leave it at its default value (true), Dify keeps behaving exactly as it does today and the <think> blocks remain visible. If you set the variable to false, the LLMNode quietly strips out every &lt;think&gt;&lt;/think&gt; reasoning segment before the text reaches the next node, so mixed-model flows parse cleanly. It addresses both sides of the long-running discussion: people who need the reasoning can keep it, and anyone who just wants a clean answer can switch it off with no code changes. Fixes #13419 Related: #13107, #18556 ### 3. Can you help us with this feature? - [x] I am interested in contributing to this feature.
yindo added the 💪 enhancementstale labels 2026-02-21 19:20:12 -05:00
yindo closed this issue 2026-02-21 19:20:13 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Aug 27, 2025):

Hi, @ultramancode. I'm Dosu, and I'm helping the Dify team manage their backlog and am marking this issue as stale.

Issue Summary:

  • You proposed adding an environment variable, LLM_NODE_THINKING_TAGS_ENABLED, to optionally strip <think> reasoning tags from LLM outputs in multi-model chat flows.
  • The goal is to prevent parsing errors caused by raw <think> blocks when outputs are passed between nodes.
  • This feature would improve robustness and flexibility by allowing toggling of reasoning segment removal without code changes.
  • There has been no further activity or discussion on this suggestion since it was opened.

Next Steps:

  • Please let me know if this feature is still relevant to your use case with the latest version of Dify by commenting on this issue.
  • If I do not hear back within 15 days, I will automatically close this issue to keep the backlog manageable.

Thank you for your understanding and contribution!

@dosubot[bot] commented on GitHub (Aug 27, 2025): Hi, @ultramancode. I'm [Dosu](https://dosu.dev), and I'm helping the Dify team manage their backlog and am marking this issue as stale. **Issue Summary:** - You proposed adding an environment variable, `LLM_NODE_THINKING_TAGS_ENABLED`, to optionally strip `<think>` reasoning tags from LLM outputs in multi-model chat flows. - The goal is to prevent parsing errors caused by raw `<think>` blocks when outputs are passed between nodes. - This feature would improve robustness and flexibility by allowing toggling of reasoning segment removal without code changes. - There has been no further activity or discussion on this suggestion since it was opened. **Next Steps:** - Please let me know if this feature is still relevant to your use case with the latest version of Dify by commenting on this issue. - If I do not hear back within 15 days, I will automatically close this issue to keep the backlog manageable. Thank you for your understanding and contribution!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#15108