66FilePath: /comfyui_copilot/backend/service/mcp-client.py
77Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
88'''
9+ from ..service .workflow_rewrite_tools import get_current_workflow
910from ..utils .globals import BACKEND_BASE_URL , get_comfyui_copilot_api_key , DISABLE_WORKFLOW_GEN
1011from .. import core
1112import asyncio
@@ -202,7 +203,7 @@ def rewrite_handoff_input_filter(data: HandoffInputData) -> HandoffInputData:
202203 # Construct instructions based on DISABLE_WORKFLOW_GEN
203204 if DISABLE_WORKFLOW_GEN :
204205 workflow_creation_instruction = """
205- **CASE 2 : SEARCH WORKFLOW**
206+ **CASE 3 : SEARCH WORKFLOW**
206207IF the user wants to find or generate a NEW workflow.
207208- Keywords: "create", "generate", "search", "find", "recommend", "生成", "查找", "推荐".
208209- Action: Use `recall_workflow`.
@@ -212,7 +213,7 @@ def rewrite_handoff_input_filter(data: HandoffInputData) -> HandoffInputData:
212213"""
213214 else :
214215 workflow_creation_instruction = """
215- **CASE 2 : CREATE NEW / SEARCH WORKFLOW**
216+ **CASE 3 : CREATE NEW / SEARCH WORKFLOW**
216217IF the user wants to find or generate a NEW workflow from scratch.
217218- Keywords: "create", "generate", "search", "find", "recommend", "生成", "查找", "推荐".
218219- Action: Use `recall_workflow` AND `gen_workflow`.
@@ -242,6 +243,16 @@ def rewrite_handoff_input_filter(data: HandoffInputData) -> HandoffInputData:
242243- DO NOT call any other tools (like search_node, gen_workflow).
243244- DO NOT ask for more details. Just handoff.
244245
246+ **CASE 2: ANALYZE CURRENT WORKFLOW**
247+ IF the user wants to:
248+ - Analyze, explain, or understand the current workflow structure/logic.
249+ - Ask questions about the current workflow (e.g., "how does this work?", "explain the workflow").
250+ - Keywords: "analyze", "explain", "understand", "how it works", "workflow structure", "分析", "解释", "怎么工作的", "解读".
251+
252+ **ACTION:**
253+ - You MUST call `get_current_workflow` to retrieve the workflow details.
254+ - Then, based on the returned workflow data, provide a detailed analysis or explanation to the user.
255+
245256{ workflow_creation_instruction }
246257
247258### CONSTRAINT CHECKLIST
@@ -280,6 +291,7 @@ def rewrite_handoff_input_filter(data: HandoffInputData) -> HandoffInputData:
280291 """ ,
281292 mcp_servers = server_list ,
282293 handoffs = [handoff_rewrite ],
294+ tools = [get_current_workflow ],
283295 config = config
284296 )
285297
0 commit comments