feat: support to initialize a tool from defined Tool attributes (#3023)

* feat: support to initialize a tool from defined Tool attributes

* fix: ensure Agent is able to load a list of Tools dynamically
This commit is contained in:
Lucas Gomide
2025-06-20 11:53:37 -03:00
committed by GitHub
parent 463ea2b97f
commit e9d8a853ea
2 changed files with 37 additions and 7 deletions

View File

@@ -476,7 +476,14 @@ def load_agent_from_repository(from_repository: str) -> Dict[str, Any]:
try:
module = importlib.import_module(tool["module"])
tool_class = getattr(module, tool["name"])
attributes[key].append(tool_class())
tool_value = tool_class(**tool["init_params"])
if isinstance(tool_value, list):
attributes[key].extend(tool_value)
else:
attributes[key].append(tool_value)
except Exception as e:
raise AgentRepositoryError(
f"Tool {tool['name']} could not be loaded: {e}"