Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

Fix only one of multiple retrieval tools is effective (#12110)

TeslaZYd1bc7ad2eef2
diff --git a/agent/component/agent_with_tools.py b/agent/component/agent_with_tools.py
index 3fadbc956c..91b467cc53 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 82f8ca556c..5f93f112a7 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())])