Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/google/adk/cli/utils/agent_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,15 @@ def load_agent(self, agent_name: str) -> Union[BaseAgent, App]:
return agent_or_app

@override
@staticmethod
def _is_agent_dir(path: Path) -> bool:
"""Check if a directory contains a valid agent definition."""
return (
(path / 'root_agent.yaml').exists()
or (path / 'agent.py').exists()
or (path / '__init__.py').exists()
)

def list_agents(self) -> list[str]:
"""Lists all agents available in the agent loader (sorted alphabetically)."""
base_path = Path.cwd() / self.agents_dir
Expand All @@ -341,6 +350,7 @@ def list_agents(self) -> list[str]:
os.path.isdir(os.path.join(base_path, x))
and not x.startswith(".")
and x != "__pycache__"
and self._is_agent_dir(base_path / x)
):
try:
self._determine_agent_language(x)
Expand Down