fix(web): filter non-agent directories from agent selection dropdown
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-patchesAgentLoader.list_agentsto filter out non-agent directories - Integration: Called in
web()afterpatch_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.