Skip to content

fix(cli): filter non-agent directories from list_agents#4733

Open
giulio-leone wants to merge 1 commit intogoogle:mainfrom
giulio-leone:fix/list-agents-filter-valid
Open

fix(cli): filter non-agent directories from list_agents#4733
giulio-leone wants to merge 1 commit intogoogle:mainfrom
giulio-leone:fix/list-agents-filter-valid

Conversation

@giulio-leone
Copy link

The list_agents CLI command currently lists all subdirectories, including those that are not valid agent directories (e.g., __pycache__, .git, etc.). This can be confusing to users.

This PR adds structural validation to only list directories that contain valid agent configurations.

Supersedes #4652 (closed due to CLA issue, now resolved).

Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves an issue where the list_agents CLI command displayed all subdirectories, including those not relevant to agent configurations, leading to user confusion. By introducing structural validation, the command now accurately lists only directories that contain valid agent definitions, significantly improving the clarity and user experience of the agent listing functionality.

Highlights

  • Agent Directory Validation: Added a new static method _is_agent_dir to AgentLoader to determine if a given directory contains a valid agent definition by checking for root_agent.yaml, agent.py, or __init__.py.
  • Improved list_agents Filtering: Modified the list_agents method to incorporate the _is_agent_dir validation, ensuring that only directories containing valid agent configurations are listed, thereby filtering out irrelevant subdirectories.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • src/google/adk/cli/utils/agent_loader.py
    • Introduced _is_agent_dir static method to check for valid agent directory structure.
    • Integrated _is_agent_dir into list_agents to filter out invalid agent directories.
Activity
  • No human activity has occurred on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@adk-bot adk-bot added the tools [Component] This issue is related to tools label Mar 6, 2026
@adk-bot
Copy link
Collaborator

adk-bot commented Mar 6, 2026

Response from ADK Triaging Agent

Hello @giulio-leone, thank you for creating this PR!

This PR is a bug fix. Could you please provide a testing plan and logs or a screenshot after the fix is applied?

This information will help reviewers to review your PR more efficiently. Thanks!

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly filters non-agent directories from the list_agents command by introducing a new _is_agent_dir validation method. The implementation is effective. My review includes a suggestion to remove some redundant code that was made unnecessary by the new validation, which will improve both readability and performance.

@giulio-leone giulio-leone force-pushed the fix/list-agents-filter-valid branch from 1eac366 to 85f54ab Compare March 6, 2026 16:13
list_agents() returns all non-hidden subdirectories, including those
that contain no agent definition (e.g. utils/, data/, tmp/). This
causes the web UI agent selector and /list-apps endpoint to show
non-agent entries that fail to load when selected.

Add _is_agent_dir() static method that checks for root_agent.yaml,
agent.py, or __init__.py — the same files _determine_agent_language()
already relies on — and filter list_agents() output accordingly.

Fixes google#4647
@giulio-leone giulio-leone force-pushed the fix/list-agents-filter-valid branch from 85f54ab to c842000 Compare March 6, 2026 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tools [Component] This issue is related to tools

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants