From 874a14b6bb3165e3597db6462400bb2a3dc69b21 Mon Sep 17 00:00:00 2001 From: ymq Date: Sat, 5 Sep 2026 15:29:44 +0800 Subject: [PATCH] =?UTF-8?q?fix(isolation):=20session=5Fsearch=20=E9=80=9A?= =?UTF-8?q?=E7=94=A8=E4=BC=9A=E8=AF=9D=E5=8F=AA=E6=90=9C=E8=87=AA=E8=BA=AB?= =?UTF-8?q?=E5=8E=86=E5=8F=B2=EF=BC=88=E4=B8=8E=20=5Fload=5Fhistory=20?= =?UTF-8?q?=E8=BF=87=E6=BB=A4=E5=AF=B9=E7=A7=B0=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 第7层泄漏补刀:session_search 原按 iteration_id 过滤,通用会话 iteration_id='' 匹配到的是所有无项目对话;统一改为按 pipeline_id='' 过滤通用会话历史, 防止修复前落库的污染对话被搜出复述。 --- pipeline_service/agent_loop_v2.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/pipeline_service/agent_loop_v2.py b/pipeline_service/agent_loop_v2.py index e1b3f4c..22e4c98 100644 --- a/pipeline_service/agent_loop_v2.py +++ b/pipeline_service/agent_loop_v2.py @@ -1368,10 +1368,19 @@ class AgentExecutor: if not query: return "FAIL: 需要搜索关键词" try: - recs = await sor.sqlExe( - "SELECT role, content, created_at FROM pipeline_conversations " - "WHERE created_by=${u}$ AND iteration_id=${pid}$ AND content LIKE ${q}$ " - "ORDER BY created_at DESC LIMIT 10", + # 产线隔离(2026-09-05 第7层):通用会话只搜自己的历史 + # (pipeline_id=''),与 _load_history 过滤对称;产线会话按 + # iteration_id(项目)过滤不变。 + if self.generic: + sql = ("SELECT role, content, created_at FROM pipeline_conversations " + "WHERE created_by=${u}$ AND (pipeline_id='' OR pipeline_id IS NULL) " + "AND content LIKE ${q}$ " + "ORDER BY created_at DESC LIMIT 10") + else: + sql = ("SELECT role, content, created_at FROM pipeline_conversations " + "WHERE created_by=${u}$ AND iteration_id=${pid}$ AND content LIKE ${q}$ " + "ORDER BY created_at DESC LIMIT 10") + recs = await sor.sqlExe(sql, {"u": self.user_id, "pid": pid, "q": f"%{query}%"}) if not recs: return f"未找到包含 '{query}' 的会话记录"