1212# See the License for the specific language governing permissions and
1313# limitations under the License.
1414
15+ import importlib
16+
1517from google .adk .agents import BaseAgent
16- from google .adk .agents .llm_agent import ToolUnion
1718from omegaconf import OmegaConf
1819
1920from veadk .a2a .remote_ve_agent import RemoteVeAgent
@@ -48,8 +49,20 @@ def _build(self, agent_config: dict) -> BaseAgent:
4849 sub_agents .append (agent )
4950 agent_config .pop ("sub_agents" )
5051
52+ tools = []
53+ if agent_config .get ("tools" , []):
54+ for tool in agent_config ["tools" ]:
55+ module_name = tool ["module" ]
56+ func_name = tool ["func" ]
57+
58+ module = importlib .import_module (module_name )
59+ func = getattr (module , func_name )
60+
61+ tools .append (func )
62+ agent_config .pop ("tools" )
63+
5164 agent_cls = AGENT_TYPES [agent_config ["type" ]]
52- agent = agent_cls (** agent_config , sub_agents = sub_agents )
65+ agent = agent_cls (** agent_config , sub_agents = sub_agents , tools = tools )
5366
5467 logger .debug ("Build agent done." )
5568
@@ -72,14 +85,10 @@ def build(
7285 self ,
7386 path : str ,
7487 root_agent_identifier : str = "root_agent" ,
75- tools : list [ToolUnion ] | None = None ,
7688 ) -> BaseAgent :
7789 config = self ._read_config (path )
7890
7991 agent_config = config [root_agent_identifier ]
8092 agent = self ._build (agent_config )
8193
82- if tools and isinstance (agent , Agent ):
83- agent .tools = tools
84-
8594 return agent
0 commit comments