From 9ffee5780c18adf96d5738e01773c08c012ab76a Mon Sep 17 00:00:00 2001 From: ymq Date: Mon, 10 Aug 2026 17:54:57 +0800 Subject: [PATCH] feat: auto-inject tool_call on first reply (deepseek fails to follow prompt) --- pipeline_service/agent_loop_v2.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pipeline_service/agent_loop_v2.py b/pipeline_service/agent_loop_v2.py index e272816..2aceb91 100644 --- a/pipeline_service/agent_loop_v2.py +++ b/pipeline_service/agent_loop_v2.py @@ -136,6 +136,21 @@ class AgentExecutor: action_type = act.get("action", "") if action_type == "reply": + # 第一轮就 reply 且没调过工具 → 强制注入 tool_call + if self._tool_call_count == 0 and turn == 0: + yield json.dumps({ + "type": "auto_tool", "message": "未调工具,自动注入 diagnose_project", + }, ensure_ascii=False) + "\n" + self._msgs.append({ + "role": "assistant", + "content": "已调用 diagnose_project", + }) + self._msgs.append({ + "role": "user", + "content": "请调用 diagnose_project 查看项目状态", + }) + continue # 不退出,继续下一轮 + final_reply = act.get("message", "") yield json.dumps({ "type": "reply", "message": final_reply,