fix(agent_loader): support flat-module agents in _determine_agent_language#5235
Open
RudrenduPaul wants to merge 2 commits intogoogle:mainfrom
Open
fix(agent_loader): support flat-module agents in _determine_agent_language#5235RudrenduPaul wants to merge 2 commits intogoogle:mainfrom
RudrenduPaul wants to merge 2 commits intogoogle:mainfrom
Conversation
Author
|
I have read the CLA Document and I hereby sign the CLA |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
_determine_agent_language()inagent_loader.pyhandles only 3 of the 4 agent structures thatload_agent()supports. When a user structures their agent as a flat module (agents_dir/my_agent.pywith no subdirectory),load_agent()successfully loads it, but_determine_agent_language()raisesValueError— causinglist_agents_detailed()(used byadk webandadk api_server) to fail with a crash for that agent.The four load patterns
load_agent()supports:{name}/agent.py✅ detected{name}/__init__.py✅ detected{name}/root_agent.yaml✅ detected{name}.pyflat module ❌ raised ValueError — this PR fixes thisChanges
src/google/adk/cli/utils/agent_loader.py: Addelif (base_path.parent / f"{agent_name}.py").exists(): return "python"branch to_determine_agent_language()src/google/adk/cli/cli_tools_click.py: Update docstrings forcli_webandcli_api_serverthat incorrectly stated agents must be subdirectories with__init__.pyandagent.pytests/unittests/cli/utils/test_agent_loader.py: AddTestDetermineAgentLanguageclass with 5 tests covering all 4 supported patterns plus the unrecognized-structure error caseTesting plan
New
TestDetermineAgentLanguageclass added with tests for:agents_dir/my_agent.py) → returns"python"✅agent.py→ returns"python"✅__init__.py→ returns"python"✅root_agent.yaml→ returns"yaml"✅ValueError✅Full CI run required to verify (local run requires
google.genaidependency installation).