Skip to content

fix(cli): support flat-module agents in _determine_agent_language#6251

Open
copybara-service[bot] wants to merge 1 commit into
mainfrom
copybara/933831825
Open

fix(cli): support flat-module agents in _determine_agent_language#6251
copybara-service[bot] wants to merge 1 commit into
mainfrom
copybara/933831825

Conversation

@copybara-service

Copy link
Copy Markdown

fix(cli): support flat-module agents in _determine_agent_language

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

@copybara-service copybara-service Bot force-pushed the copybara/933831825 branch 4 times, most recently from 1402a30 to 96ba078 Compare July 1, 2026 20:35
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
@copybara-service copybara-service Bot force-pushed the copybara/933831825 branch from 96ba078 to 80fb269 Compare July 1, 2026 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant