From 55ef45e04d00fd23b1f0a4c26783db2fc2685772 Mon Sep 17 00:00:00 2001 From: JOJO <1498581755@qq.com> Date: Tue, 3 Feb 2026 23:11:15 +0800 Subject: [PATCH] feat: add silent disable option and workspace prompt split --- core/main_terminal.py | 10 + modules/personalization_manager.py | 7 + prompts/main_system.txt | 21 +- prompts/main_system_qwenvl.txt | 21 +- prompts/workspace_system.txt | 12 + .../personalization/PersonalizationDrawer.vue | 214 ++++++++++-------- static/src/stores/personalization.ts | 3 + .../styles/components/overlays/_overlays.scss | 13 +- sub_agent/core/main_terminal.py | 7 + sub_agent/utils/context_manager.py | 68 +++++- utils/context_manager.py | 74 +++++- 11 files changed, 300 insertions(+), 150 deletions(-) create mode 100644 prompts/workspace_system.txt diff --git a/core/main_terminal.py b/core/main_terminal.py index d405334..ad69330 100644 --- a/core/main_terminal.py +++ b/core/main_terminal.py @@ -145,6 +145,7 @@ class MainTerminal: ) self.easter_egg_manager = EasterEggManager() self._announced_sub_agent_tasks = set() + self.silent_tool_disable = False # 是否静默工具禁用提示 self.current_session_id = 0 # 用于标识不同的任务会话 # 工具类别(可被管理员动态覆盖) self.tool_categories_map = dict(TOOL_CATEGORIES) @@ -428,6 +429,9 @@ class MainTerminal: except ValueError: logger.warning("忽略无效默认运行模式: %s", preferred_mode) + # 静默禁用工具提示 + self.silent_tool_disable = bool(effective_config.get("silent_tool_disable")) + def _handle_read_tool(self, arguments: Dict) -> Dict: """集中处理 read_file 工具的三种模式。""" @@ -664,6 +668,8 @@ class MainTerminal: def _format_disabled_tool_notice(self) -> Optional[str]: """生成禁用工具提示信息 / Format disabled tool notice.""" + if getattr(self, "silent_tool_disable", False): + return None if not self.disabled_notice_tools: return None @@ -2508,6 +2514,10 @@ class MainTerminal: {"role": "system", "content": system_prompt} ] + workspace_system = self.context_manager._build_workspace_system_message(context) + if workspace_system: + messages.append({"role": "system", "content": workspace_system}) + if self.tool_category_states.get("todo", True): todo_prompt = self.load_prompt("todo_guidelines").strip() if todo_prompt: diff --git a/modules/personalization_manager.py b/modules/personalization_manager.py index d61c720..99fd6b8 100644 --- a/modules/personalization_manager.py +++ b/modules/personalization_manager.py @@ -38,6 +38,7 @@ DEFAULT_PERSONALIZATION_CONFIG: Dict[str, Any] = { "tool_intent_enabled": True, "default_model": "kimi-k2.5", "image_compression": "original", # original / 1080p / 720p / 540p + "silent_tool_disable": False, # 禁用工具时不向模型插入提示 } __all__ = [ @@ -164,6 +165,12 @@ def sanitize_personalization_payload( elif base.get("image_compression") not in allowed_image_modes: base["image_compression"] = "original" + # 静默禁用工具提示 + if "silent_tool_disable" in data: + base["silent_tool_disable"] = bool(data.get("silent_tool_disable")) + else: + base["silent_tool_disable"] = bool(base.get("silent_tool_disable")) + return base diff --git a/prompts/main_system.txt b/prompts/main_system.txt index 6624cef..602bb38 100644 --- a/prompts/main_system.txt +++ b/prompts/main_system.txt @@ -136,22 +136,7 @@ --- -## 7. 工作区信息 - -- **运行环境**:隔离容器中(挂载目录 {container_path}),宿主机路径已隐藏 -- **资源限制**:CPU {container_cpus} 核,内存 {container_memory},磁盘配额 {project_storage} -- **当前时间**:{current_time} -- **项目结构**: - -``` -{file_tree} -``` - -- **长期记忆**:{memory} - ---- - -## 8. 核心原则 +## 7. 核心原则 1. **安全第一**:只操作授权范围内的文件 2. **沟通为主**:不确定时多问,不要自作主张 @@ -159,8 +144,6 @@ 4. **用户友好**:用简单的语言解释复杂的操作 5. **正确执行**:主动确认细节,获得明确许可后再开始 ---- - -## 9. 个性化配置 +## 8. 个性化配置 当用户的个性化信息与上文冲突时,以用户的个性化信息为准。 diff --git a/prompts/main_system_qwenvl.txt b/prompts/main_system_qwenvl.txt index 74218fc..7d31573 100644 --- a/prompts/main_system_qwenvl.txt +++ b/prompts/main_system_qwenvl.txt @@ -154,22 +154,7 @@ --- -## 7. 工作区信息 - -- **运行环境**:隔离容器中(挂载目录 {container_path}),宿主机路径已隐藏 -- **资源限制**:CPU {container_cpus} 核,内存 {container_memory},磁盘配额 {project_storage} -- **当前时间**:{current_time} -- **项目结构**: - -``` -{file_tree} -``` - -- **长期记忆**:{memory} - ---- - -## 8. 核心原则 +## 7. 核心原则 1. **安全第一**:只操作授权范围内的文件 2. **沟通为主**:不确定时多问,不要自作主张 @@ -177,8 +162,6 @@ 4. **用户友好**:用简单的语言解释复杂的操作 5. **正确执行**:主动确认细节,获得明确许可后再开始 ---- - -## 9. 个性化配置 +## 8. 个性化配置 当用户的个性化信息与上文冲突时,以用户的个性化信息为准。 diff --git a/prompts/workspace_system.txt b/prompts/workspace_system.txt new file mode 100644 index 0000000..6c9a8da --- /dev/null +++ b/prompts/workspace_system.txt @@ -0,0 +1,12 @@ +## 工作区信息 + +- **运行环境**:{runtime_environment} +- **资源限制**:{resource_limit} +- **当前时间**:{current_time} +- **项目结构**: + +``` +{file_tree} +``` + +- **长期记忆**:{memory} diff --git a/static/src/components/personalization/PersonalizationDrawer.vue b/static/src/components/personalization/PersonalizationDrawer.vue index f809118..7c6e104 100644 --- a/static/src/components/personalization/PersonalizationDrawer.vue +++ b/static/src/components/personalization/PersonalizationDrawer.vue @@ -63,6 +63,7 @@ +

仅作用于当前工作区,可随时在左下角开关。

@@ -254,25 +255,6 @@ Qwen-Max 仅支持快速模式;Qwen-VL 不支持深度思考模式,选择时会给出提示。

-
-
-
-
- - {{ status }} - - - {{ error }} - -
- -
-
- -
-
默认思考模型 @@ -296,75 +278,6 @@
-
-
- 堆叠块显示 -

使用新版堆叠动画展示思考/工具块,超过 6 条自动收纳为“更多”。默认开启。

-
- -
-
-
- 自动生成对话标题 -

默认开启;关闭后标题将沿用首条消息。

-
- -
-
-
- 工具意图提示 -

开启后,调用工具时会先用约15字告诉你要做什么,替代“正在/完成”文案。

-
- -
思考频率 @@ -401,11 +314,122 @@
+
+
+
+
+ + {{ status }} + + + {{ error }} + +
+ +
+
+
+
+
- 默认禁用工具类别 -

选择后,这些类别在新任务中会保持关闭,也可随时通过快捷菜单临时开启。

+ 堆叠块显示 +

使用新版堆叠动画展示思考/工具块,超过 6 条自动收纳为“更多”。默认开启。

+ +
+
+
+ 静默禁用 +

禁用工具时不再注入提示消息,模型不会感知被禁用项。

+
+ +
+
+
+ 自动生成对话标题 +

默认开启;关闭后标题将沿用首条消息。

+
+ +
+
+
+ 工具意图提示 +

开启后,调用工具时会先用约15字告诉你要做什么,替代“正在/完成”文案。

+
+ +
+
+
+ 默认禁用工具类别 +

选择后,这些类别在新任务中会保持关闭,也可随时通过快捷菜单临时开启。

+