[PR #2477] [MERGED] feat: Add client-side thinking content filtering for Minimax M2.1 #2509

Closed
opened 2026-02-16 11:17:11 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langgenius/dify-official-plugins/pull/2477
Author: @DeiuDesHommies
Created: 1/23/2026
Status: Merged
Merged: 1/31/2026
Merged by: @crazywoola

Base: mainHead: fix/openai-compatible-minimax-thinking


📝 Commits (2)

  • b62e19f feat: Add client-side thinking content filtering for Minimax M2.1
  • 5d9293b fix: Address code review feedback from Gemini Code Assist

📊 Changes

2 files changed (+65 additions, -2 deletions)

View changed files

📝 models/openai_api_compatible/manifest.yaml (+1 -1)
📝 models/openai_api_compatible/models/llm/llm.py (+64 -1)

📄 Description

Summary

This PR adds client-side filtering support for models like Minimax M2.1 that don't support server-side thinking mode control via API parameters.

Problem

Minimax M2.1 model deployed on SGLang/vLLM frameworks doesn't respond to API parameters like thinking: {type: "disabled"} or chat_template_kwargs: {enable_thinking: false}. The model always returns thinking content wrapped in <think> tags, even when the user disables thinking mode in Dify UI.

Testing Results

Tested 10+ different API parameter combinations:

  • thinking.type = "disabled" (GLM format)
  • chat_template_kwargs.enable_thinking = false (vLLM format)
  • reasoning_split = true (Minimax official parameter)
  • All other common parameter combinations

Conclusion: Minimax M2.1's SGLang deployment does not support server-side thinking mode control.

Solution

Added client-side response filtering that:

  • Detects and removes <think>...</think> blocks from responses
  • Only activates when enable_thinking is explicitly set to False
  • Supports both streaming and non-streaming responses
  • Maintains full compatibility with models that support server-side control (like GLM)

Implementation Details

Smart Triggering Logic

The filter only activates when:

  1. User explicitly disables thinking mode (enable_thinking = False)
  2. Response actually contains <think> tags (prevents unnecessary processing)
  3. Server-side control didn't work (automatic fallback)

Compatibility

Models NOT Affected

  • GLM 4.7: Server-side control works, no <think> tags in response when disabled
  • OpenAI GPT: No thinking feature, no filtering triggered
  • Other models: Only filters if <think> present AND user disabled thinking

Models Benefited

  • Minimax M2.1: Client-side filtering removes <think> blocks when SGLang ignores parameters
  • Similar models: Automatic fallback to client-side filtering

Testing

Tested with Minimax M2.1 on SGLang framework
Tested 10+ different API parameter combinations
Confirmed GLM models are not affected
Verified backward compatibility

Impact

  • No impact on existing models (GLM, OpenAI, etc.)
  • Fixes thinking mode control for Minimax M2.1 and similar models
  • Improves user experience when server-side control is unavailable
  • Minimal processing overhead (only when filtering is needed)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/langgenius/dify-official-plugins/pull/2477 **Author:** [@DeiuDesHommies](https://github.com/DeiuDesHommies) **Created:** 1/23/2026 **Status:** ✅ Merged **Merged:** 1/31/2026 **Merged by:** [@crazywoola](https://github.com/crazywoola) **Base:** `main` ← **Head:** `fix/openai-compatible-minimax-thinking` --- ### 📝 Commits (2) - [`b62e19f`](https://github.com/langgenius/dify-official-plugins/commit/b62e19f49a3810a04bc4e5513e28d8ff1dad1fa3) feat: Add client-side thinking content filtering for Minimax M2.1 - [`5d9293b`](https://github.com/langgenius/dify-official-plugins/commit/5d9293b86fcbb1de1c148bab34137b3a98ce88c7) fix: Address code review feedback from Gemini Code Assist ### 📊 Changes **2 files changed** (+65 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `models/openai_api_compatible/manifest.yaml` (+1 -1) 📝 `models/openai_api_compatible/models/llm/llm.py` (+64 -1) </details> ### 📄 Description ## Summary This PR adds client-side filtering support for models like Minimax M2.1 that don't support server-side thinking mode control via API parameters. ## Problem Minimax M2.1 model deployed on SGLang/vLLM frameworks doesn't respond to API parameters like `thinking: {type: "disabled"}` or `chat_template_kwargs: {enable_thinking: false}`. The model always returns thinking content wrapped in `<think>` tags, even when the user disables thinking mode in Dify UI. ### Testing Results Tested 10+ different API parameter combinations: - ❌ `thinking.type = "disabled"` (GLM format) - ❌ `chat_template_kwargs.enable_thinking = false` (vLLM format) - ❌ `reasoning_split = true` (Minimax official parameter) - ❌ All other common parameter combinations **Conclusion**: Minimax M2.1's SGLang deployment does not support server-side thinking mode control. ## Solution Added client-side response filtering that: - Detects and removes `<think>...</think>` blocks from responses - Only activates when `enable_thinking` is explicitly set to `False` - Supports both streaming and non-streaming responses - Maintains full compatibility with models that support server-side control (like GLM) ## Implementation Details ### Smart Triggering Logic The filter only activates when: 1. User explicitly disables thinking mode (`enable_thinking = False`) 2. Response actually contains `<think>` tags (prevents unnecessary processing) 3. Server-side control didn't work (automatic fallback) ## Compatibility ### Models NOT Affected - **GLM 4.7**: Server-side control works, no `<think>` tags in response when disabled - **OpenAI GPT**: No thinking feature, no filtering triggered - **Other models**: Only filters if `<think>` present AND user disabled thinking ### Models Benefited - **Minimax M2.1**: Client-side filtering removes `<think>` blocks when SGLang ignores parameters - **Similar models**: Automatic fallback to client-side filtering ## Testing ✅ Tested with Minimax M2.1 on SGLang framework ✅ Tested 10+ different API parameter combinations ✅ Confirmed GLM models are not affected ✅ Verified backward compatibility ## Impact - No impact on existing models (GLM, OpenAI, etc.) - Fixes thinking mode control for Minimax M2.1 and similar models - Improves user experience when server-side control is unavailable - Minimal processing overhead (only when filtering is needed) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 11:17:11 -05:00
yindo closed this issue 2026-02-16 11:17:11 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-official-plugins#2509