fix(cli): support flat-module agents in _determine_agent_language#6251
Open
copybara-service[bot] wants to merge 1 commit into
Open
fix(cli): support flat-module agents in _determine_agent_language#6251copybara-service[bot] wants to merge 1 commit into
copybara-service[bot] wants to merge 1 commit into
Conversation
1402a30 to
96ba078
Compare
Merge #5235 `_determine_agent_language()` handled only 3 of the 4 agent structures that `load_agent()` supports. When an agent is a flat module (`agents_dir/my_agent.py`, with no subdirectory), `load_agent()` loads it successfully but `_determine_agent_language()` raised `ValueError`. This adds the missing flat-module branch so language detection is consistent with all four supported load patterns: - `{name}/agent.py` - `{name}/__init__.py` - `{name}/root_agent.yaml` - `{name}.py` (flat module) It also adds `__init__.py` to the recognized agent marker files listed in the `adk web` / `adk api_server` AGENTS_DIR docstrings, and adds a `TestDetermineAgentLanguage` suite covering all four patterns plus the unrecognized-structure error case. Co-authored-by: Haran Rajkumar <haranrk@google.com> PiperOrigin-RevId: 933831825
96ba078 to
80fb269
Compare
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.
fix(cli): support flat-module agents in _determine_agent_language
Merge #5235
_determine_agent_language()handled only 3 of the 4 agent structures thatload_agent()supports. When an agent is a flat module(
agents_dir/my_agent.py, with no subdirectory),load_agent()loads itsuccessfully but
_determine_agent_language()raisedValueError.This adds the missing flat-module branch so language detection is consistent
with all four supported load patterns:
{name}/agent.py{name}/__init__.py{name}/root_agent.yaml{name}.py(flat module)It also adds
__init__.pyto the recognized agent marker files listed in theadk web/adk api_serverAGENTS_DIR docstrings, and adds aTestDetermineAgentLanguagesuite covering all four patterns plus theunrecognized-structure error case.
Co-authored-by: Haran Rajkumar haranrk@google.com