1717import importlib
1818import logging
1919import os
20+ from pathlib import Path
2021import sys
2122from typing import Optional
2223
2324from pydantic import ValidationError
25+ from typing_extensions import override
2426
2527from . import envs
2628from ...agents import config_agent_utils
2729from ...agents .base_agent import BaseAgent
2830from ...utils .feature_decorator import working_in_progress
31+ from .base_agent_loader import BaseAgentLoader
2932
3033logger = logging .getLogger ("google_adk." + __name__ )
3134
3235
33- class AgentLoader :
36+ class AgentLoader ( BaseAgentLoader ) :
3437 """Centralized agent loading with proper isolation, caching, and .env loading.
3538 Support loading agents from below folder/file structures:
3639 a) {agent_name}.agent as a module name:
@@ -188,6 +191,7 @@ def _perform_load(self, agent_name: str) -> BaseAgent:
188191 " exposed."
189192 )
190193
194+ @override
191195 def load_agent (self , agent_name : str ) -> BaseAgent :
192196 """Load an agent module (with caching & .env) and return its root_agent."""
193197 if agent_name in self ._agent_cache :
@@ -199,6 +203,20 @@ def load_agent(self, agent_name: str) -> BaseAgent:
199203 self ._agent_cache [agent_name ] = agent
200204 return agent
201205
206+ @override
207+ def list_agents (self ) -> list [str ]:
208+ """Lists all agents available in the agent loader (sorted alphabetically)."""
209+ base_path = Path .cwd () / self .agents_dir
210+ agent_names = [
211+ x
212+ for x in os .listdir (base_path )
213+ if os .path .isdir (os .path .join (base_path , x ))
214+ and not x .startswith ("." )
215+ and x != "__pycache__"
216+ ]
217+ agent_names .sort ()
218+ return agent_names
219+
202220 def remove_agent_from_cache (self , agent_name : str ):
203221 # Clear module cache for the agent and its submodules
204222 keys_to_delete = [
0 commit comments