From 38c4e69513909a3164f0d5aad919239cf4483b03 Mon Sep 17 00:00:00 2001 From: ymq Date: Sun, 9 Aug 2026 22:35:44 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20agent=20must=20NOT=20auto-switch=20?= =?UTF-8?q?=E2=80=94=20stay=20in=20current=20project=20unless=20user=20exp?= =?UTF-8?q?licitly=20asks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wwwroot/api/cockpit_chat.dspy | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/wwwroot/api/cockpit_chat.dspy b/wwwroot/api/cockpit_chat.dspy index d9646d3..30fb53b 100644 --- a/wwwroot/api/cockpit_chat.dspy +++ b/wwwroot/api/cockpit_chat.dspy @@ -16,7 +16,13 @@ dbname = get_module_dbname('pipeline-sdlc') AGENT_PROMPT = """你是开发产线驾驶舱 Agent。用工具获取数据,用 reply 回复。 -工作流: +## 核心原则 +- 环境信息中已显示当前项目。绝大多数操作在当前项目内完成,不要切换 +- 仅当用户明确说出不同的项目名时才切换(如"切换到 XXX 项目") +- list_projects 仅当用户要求"列出项目"或需要切换但不知道项目名时才调用 +- 不要主动 list_projects 或 switch_project + +## 工作流 - 项目操作:当前项目已在环境信息中。如果已在目标项目,直接操作,不需要切换 - 切换项目:仅当需要切换时才 list_projects → switch_project - 创建项目:不存在则 create_project @@ -436,7 +442,7 @@ if action == 'send_message': return repos_str = ', '.join([r['n'] for r in ctx['repos']]) or '无' - env_text = f"【当前项目: {ctx['pname'] or '未选择'}】\n工作空间: {ctx['ws'] or '未设置'}\n仓库: {repos_str}\n⚠️ 在调用 switch_project 之前,先确认当前项目是否已经是目标项目" + env_text = f"【当前项目: {ctx['pname'] or '未选择'}】— 除非用户明确要求切换,否则在这里操作\n工作空间: {ctx['ws'] or '未设置'} | 仓库: {repos_str}" system = AGENT_PROMPT.replace('__TOOLS__',TOOLS_TEXT).replace('__ENV__',env_text) msgs = [{"role":"system","content":system}] for h in (await sor.sqlExe("SELECT role,content FROM pipeline_conversations WHERE created_by=${u}$ ORDER BY created_at ASC LIMIT 20",{"u":uid}) or []):