Describe the bug
The Bug
The CLI command adk create my-agent succeeds, but the resulting agent fails to load in the Web UI or with adk run.
The Error
ValueError: Invalid app name 'my-agent': must be a valid identifier.
The Cause
The ADK uses the directory name as the Agent's internal name attribute, but the Agent class (via Pydantic) restricts names to valid Python identifiers (no hyphens).
To Reproduce
Please share a minimal code and data to reproduce your problem.
Steps to reproduce the behavior:
- Run " adk create sample-agent --model gemini-1.5-flash --api_key $GOOGLE_API_KEY"
Agent created in /Users/***/sample-agent:
- run " adk web ."
error log:
"File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pydantic/main.py", line 250, in init
validated_self = self.pydantic_validator.validate_python(data, self_instance=self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for App
Value error, Invalid app name 'sample-agent': must be a valid identifier consisting of letters, digits, and underscores. [type=value_error, input_value={'name': 'sample-agent', ...ck=None), 'plugins': []}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.12/v/value_error"
Expected behavior
- Validation: Reject agent names with hyphens at the create step, and inform the user that the name must be a valid identifier.
- or Sanitization: Automatically convert hyphens to underscores (e.g.,
my-agent becomes folder my-agent but agent name my_agent).
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: macOS
- Python version(python -V): 3.12.7
- ADK version(pip show google-adk): 1.21.0
Model Information:
- Are you using LiteLLM: Yes
- Which model is being used(e.g. gemini-2.5-pro): gemini-2.5-flash-lite
Describe the bug
The Bug
The CLI command
adk create my-agentsucceeds, but the resulting agent fails to load in the Web UI or withadk run.The Error
ValueError: Invalid app name 'my-agent': must be a valid identifier.
The Cause
The ADK uses the directory name as the Agent's internal
nameattribute, but theAgentclass (via Pydantic) restricts names to valid Python identifiers (no hyphens).To Reproduce
Please share a minimal code and data to reproduce your problem.
Steps to reproduce the behavior:
Agent created in /Users/***/sample-agent:
error log:
"File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pydantic/main.py", line 250, in init
validated_self = self.pydantic_validator.validate_python(data, self_instance=self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for App
Value error, Invalid app name 'sample-agent': must be a valid identifier consisting of letters, digits, and underscores. [type=value_error, input_value={'name': 'sample-agent', ...ck=None), 'plugins': []}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.12/v/value_error"
Expected behavior
my-agentbecomes foldermy-agentbut agent namemy_agent).Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Model Information: