Skip to content
This repository was archived by the owner on Oct 28, 2026. It is now read-only.

list: scan the template dir we cloned, not the clone root - #1003

Open
rootkiller6788 wants to merge 4 commits into
GoogleCloudPlatform:mainfrom
rootkiller6788:fix-list-remote-source-scan
Open

rootkiller6788 wants to merge 4 commits into
GoogleCloudPlatform:mainfrom
rootkiller6788:fix-list-remote-source-scan

Conversation

@rootkiller6788

Copy link
Copy Markdown

list -s <url> never found any agents.

fetch_remote_template hands back (template_dir, temp_dir), and list.py read the tuple the other way round, so the scan got pointed at the temp root of the clone instead of the template dir inside it. For adk-samples that root has no python/agents/, so this is what you get:

$ agent-starter-pack list -s https://github.com/google/adk-samples
Fetching agents from https://github.com/google/adk-samples...
No agents found in https://github.com/google/adk-samples

while list --adk on the very same repo lists them fine. Same for any remote source with a sub-path, e.g. -s google/adk-samples/python/agents/data-science.

Fix is to use the first element of the tuple. The scan_from_root flag goes away with it: when the spec has no sub-path template_dir already is the clone root, which is all that flag did, and --adk was its only caller.

While in there I noticed list never removes the temp clone (create does), so every list -s / list --adk left a copy of the repo behind in /tmp. It's dropped in a finally now.

Added a test that mocks the fetch against a fake clone and checks the agents show up and the temp dir is gone. It fails on the current code.

fetch_remote_template returns (template_dir, temp_dir) but this unpacked it
the other way round, so every --source scan pointed at the temp root of the
clone. For adk-samples there is no python/agents/ at that level, so

    agent-starter-pack list -s https://github.com/google/adk-samples

just said "No agents found" while `list --adk` on the same repo listed them
fine. Same for any remote source with a sub-path.

The old scan_from_root flag goes away with it: when the spec has no sub-path
template_dir already *is* the clone root, which is the only thing it was used
for.
create does clean up the temp dir it gets back from fetch_remote_template,
list never did, so every `list -s <url>` / `list --adk` left a copy of the
repo in /tmp. Drop it once the table is rendered.
Nothing exercised list_remote_agents, which is how the wrong tuple element
slipped through. Point fetch_remote_template at a fake clone and check the
agents show up and the temp dir is gone afterwards.

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

Copy link
Copy Markdown
Contributor

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 refactors the remote agent listing functionality to ensure that the temporary repository clone is properly cleaned up after use. It updates list_remote_agents to retrieve both the template directory and the temporary clone root from fetch_remote_template, utilizing a finally block with shutil.rmtree to clean up the clone. A new test is also added to verify this behavior. The review feedback suggests keeping the tracking variable as a pathlib.Path object and passing it directly to shutil.rmtree instead of converting it to a string, which simplifies the code and maintains type consistency.

Comment thread agent_starter_pack/cli/commands/list.py Resolved
@rootkiller6788
rootkiller6788 marked this pull request as ready for review October 16, 2026 03:52
fetch_remote_template already returns pathlib.Path for both elements, so
there is no need to round-trip the clone root through str. Drop the
conversion and type the variable as pathlib.Path | None.

This branch has not been deployed

No deployments
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant