From 13370d205600b5d117764313f981dbd511370623 Mon Sep 17 00:00:00 2001 From: zhayujie Date: Fri, 17 Apr 2026 15:31:59 +0800 Subject: [PATCH] fix: thinking display is disabled by default --- README.md | 2 +- agent/protocol/agent_stream.py | 20 +++++++++++++------- bridge/agent_bridge.py | 4 ++-- channel/web/chat.html | 2 +- channel/web/static/js/console.js | 2 +- channel/web/web_channel.py | 4 ++-- config.py | 2 +- docs/channels/web.mdx | 4 ++-- docs/intro/architecture.mdx | 4 ++-- 9 files changed, 25 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index a0d29e38..5120fa7d 100644 --- a/README.md +++ b/README.md @@ -206,7 +206,7 @@ cow install-browser "agent_max_context_tokens": 50000, # Agent 模式下最大上下文 tokens,超出将自动智能压缩处理 "agent_max_context_turns": 20, # Agent 模式下最大上下文记忆轮次,一问一答为一轮,超出后智能压缩处理 "agent_max_steps": 20, # Agent 模式下单次任务的最大决策步数,超出后将停止继续调用工具 - "enable_thinking": true # 是否启用深度思考,开启后 Web 端展示模型推理过程,关闭后可加速响应 + "enable_thinking": false # 是否启用深度思考,开启后 Web 端展示模型推理过程,关闭后可加速响应 } ``` diff --git a/agent/protocol/agent_stream.py b/agent/protocol/agent_stream.py index 39a28c15..dd830457 100644 --- a/agent/protocol/agent_stream.py +++ b/agent/protocol/agent_stream.py @@ -81,20 +81,26 @@ class AgentStreamExecutor: def _is_thinking_enabled(self) -> bool: from config import conf channel_type = getattr(self.model, 'channel_type', '') or '' - return conf().get("enable_thinking", True) and channel_type == 'web' + return conf().get("enable_thinking", False) and channel_type == 'web' def _filter_think_tags(self, text: str) -> str: """ - Remove and tags but keep the content inside. - Some LLM providers (e.g., MiniMax) may return thinking process wrapped in tags. - We only remove the tags themselves, keeping the actual thinking content. + Handle ... blocks in content returned by some LLM providers + (e.g., MiniMax). + + - When thinking is enabled: remove the tags but keep the content inside. + - When thinking is disabled: remove both the tags and the content entirely. """ if not text: return text import re - # Remove only the and tags, keep the content - text = re.sub(r'', '', text) - text = re.sub(r'', '', text) + if self._is_thinking_enabled(): + text = re.sub(r'', '', text) + text = re.sub(r'', '', text) + else: + text = re.sub(r'[\s\S]*?', '', text) + # Also strip unclosed tag at the end (streaming partial) + text = re.sub(r'[\s\S]*$', '', text) return text def _hash_args(self, args: dict) -> str: diff --git a/bridge/agent_bridge.py b/bridge/agent_bridge.py index 4b178bee..8f6f6316 100644 --- a/bridge/agent_bridge.py +++ b/bridge/agent_bridge.py @@ -169,7 +169,7 @@ class AgentLLMModel(LLMModel): # Determine thinking: respect global config, then channel_type from config import conf - global_thinking = conf().get("enable_thinking", True) + global_thinking = conf().get("enable_thinking", False) if not global_thinking: kwargs['thinking'] = {"type": "disabled"} else: @@ -222,7 +222,7 @@ class AgentLLMModel(LLMModel): # Determine thinking: respect global config, then channel_type from config import conf - global_thinking = conf().get("enable_thinking", True) + global_thinking = conf().get("enable_thinking", False) if not global_thinking: kwargs['thinking'] = {"type": "disabled"} else: diff --git a/channel/web/chat.html b/channel/web/chat.html index 25065316..0326482d 100644 --- a/channel/web/chat.html +++ b/channel/web/chat.html @@ -552,7 +552,7 @@