veadk-python icon indicating copy to clipboard operation
veadk-python copied to clipboard

fix(web): filter non-agent directories from agent selection dropdown

Open wucm667 opened this issue 7 months ago • 0 comments

Description

Fixes #552

The Web UI agent selection dropdown inherits Google ADK's directory scanning mechanism, which lists ALL subdirectories including non-agent directories (like tools/, tests/, schemas/). Selecting these invalid directories causes loading errors.

This change adds a monkey-patch to AgentLoader.list_agents that filters the directory list to only include valid agent directories. A directory is considered a valid agent if it contains any of the following patterns:

  • {dir}/agent.py
  • {dir}/__init__.py
  • {dir}/root_agent.yaml
  • {dir}.py (as a module)

The patch is applied in the veadk web command alongside existing patches for OAuth2 and OpenAPI disabling, following the same pattern used in the codebase.

Changes

  • File: veadk/cli/cli_web.py
  • New function: patch_agent_loader_list_agents() — monkey-patches AgentLoader.list_agents to filter out non-agent directories
  • Integration: Called in web() after patch_adkwebserver_disable_openapi()

Testing

Manually verified the filtering logic against the issue's repro steps:

project/
├── agent.py            # ✅ valid
├── flows/              # ✅ valid (contains agent definitions)
├── tools/              # ❌ filtered out (no agent patterns)
├── schemas/            # ❌ filtered out (no agent patterns)
├── tests/              # ❌ filtered out (no agent patterns)
└── agents/             # ❌ filtered out (no agent patterns)

Only directories with valid agent entry points will appear in the dropdown.

wucm667 avatar Apr 27 '26 06:04 wucm667