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}' 的会话记录"