diff --git a/pipeline_service/agent_loop_v2.py b/pipeline_service/agent_loop_v2.py index dc0cfc0..667042d 100644 --- a/pipeline_service/agent_loop_v2.py +++ b/pipeline_service/agent_loop_v2.py @@ -261,15 +261,18 @@ class AgentExecutor: if skill_block: prompt += f"\n\n{skill_block}" - # 注入工具列表 - prompt += "\n\n## 可用工具\n" + # 注入工具列表(先构建,再替换占位符) + tools_text = "" if self._tool_registry: - prompt += self._tool_registry.to_text_description() + tools_text = self._tool_registry.to_text_description() else: + lines = [] for t in self.config.tools: if t.enabled: params = ", ".join(f"{k}: {v}" for k, v in (t.parameters or {}).items()) - prompt += f"- {t.name}({params}): {t.description}\n" + lines.append(f"- {t.name}({params}): {t.description}") + tools_text = "\n".join(lines) + prompt = prompt.replace("{tools_description}", tools_text) # 注入项目上下文 try: