From f7225bc91a9155481682210a445247342df6d014 Mon Sep 17 00:00:00 2001 From: chiguyong Date: Thu, 11 Jun 2026 22:00:30 +0800 Subject: [PATCH] fix: include available tools in system prompt so LLM knows what it can call MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously get_system_prompt() only returned identity/instructions but did not tell the LLM what tools are available. The LLM would therefore refuse to call tools even when they were registered, saying it had no tools. Now the system prompt includes a '## 可用工具' section listing all registered tools with their descriptions and parameters. --- src/agentkit/core/config_driven.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/agentkit/core/config_driven.py b/src/agentkit/core/config_driven.py index ca61122..f88b3cf 100644 --- a/src/agentkit/core/config_driven.py +++ b/src/agentkit/core/config_driven.py @@ -405,16 +405,33 @@ class ConfigDrivenAgent(BaseAgent, EvolutionMixin): return self._config.llm.get("model", "default") if self._config.llm else "default" def get_system_prompt(self) -> str | None: - """Return the system prompt for this agent.""" + """Return the system prompt for this agent, including available tools.""" + parts = [] + if self._prompt_template: sections = self._prompt_template._sections - parts = [] for key in ("identity", "context", "instructions", "constraints", "output_format"): val = getattr(sections, key, "") if val: parts.append(val) - return "\n".join(parts) if parts else None - return None + + # Append available tools description so the LLM knows what it can use + if self._tools: + tools_desc = self._build_tools_description() + parts.append(f"\n\n## 可用工具\n{tools_desc}") + + return "\n".join(parts) if parts else None + + def _build_tools_description(self) -> str: + """Build a text description of available tools for the system prompt.""" + lines = [] + for tool in self._tools: + lines.append(f"- **{tool.name}**: {tool.description}") + if tool.input_schema and "properties" in tool.input_schema: + params = list(tool.input_schema["properties"].keys()) + if params: + lines[-1] += f" (参数: {', '.join(params)})" + return "\n".join(lines) def get_react_config(self) -> dict: """Return ReAct engine configuration."""