From d1bc7ad2eef205c6753ba2319f8fcc9a94662353 Mon Sep 17 00:00:00 2001 From: TeslaZY Date: Tue, 23 Dec 2025 14:08:25 +0800 Subject: [PATCH] Fix only one of multiple retrieval tools is effective (#12110) ### What problem does this PR solve? Fix only one of multiple retrieval tools is effective ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- agent/component/agent_with_tools.py | 5 +++-- rag/prompts/generator.py | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/agent/component/agent_with_tools.py b/agent/component/agent_with_tools.py index 3fadbc956..91b467cc5 100644 --- a/agent/component/agent_with_tools.py +++ b/agent/component/agent_with_tools.py @@ -84,9 +84,10 @@ class Agent(LLM, ToolBase): def __init__(self, canvas, id, param: LLMParam): LLM.__init__(self, canvas, id, param) self.tools = {} - for cpn in self._param.tools: + for idx, cpn in enumerate(self._param.tools): cpn = self._load_tool_obj(cpn) - self.tools[cpn.get_meta()["function"]["name"]] = cpn + name = cpn.get_meta()["function"]["name"] + self.tools[f"{name}_{idx}"] = cpn self.chat_mdl = LLMBundle(self._canvas.get_tenant_id(), TenantLLMService.llm_id2llm_type(self._param.llm_id), self._param.llm_id, max_retries=self._param.max_retries, diff --git a/rag/prompts/generator.py b/rag/prompts/generator.py index 82f8ca556..5f93f112a 100644 --- a/rag/prompts/generator.py +++ b/rag/prompts/generator.py @@ -324,8 +324,9 @@ def tool_schema(tools_description: list[dict], complete_task=False): } } } - for tool in tools_description: - desc[tool["function"]["name"]] = tool + for idx, tool in enumerate(tools_description): + name = tool["function"]["name"] + desc[f"{name}_{idx}"] = tool return "\n\n".join([f"## {i+1}. {fnm}\n{json.dumps(des, ensure_ascii=False, indent=4)}" for i, (fnm, des) in enumerate(desc.items())])