fix: replace {tools_description} placeholder in system prompt

This commit is contained in:
ymq 2026-08-10 17:50:12 +08:00
parent 9ea2b498d6
commit 945e43cf62

View File

@ -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: