-
Notifications
You must be signed in to change notification settings - Fork 2.1k
fix(cli): Improve error message when adk web is run in wrong directory #3196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(cli): Improve error message when adk web is run in wrong directory #3196
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Summary of ChangesHello @jpantsjoha, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses user confusion experienced during workshops by enhancing the error message displayed when the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
Response from ADK Triaging Agent Hello @jpantsjoha, thank you for your contribution! Before we can merge this PR, you need to sign the Contributor License Agreement (CLA). You can find more information at https://cla.developers.google.com/. Once you have signed the CLA, the status check will be updated, and we can proceed with the review. |
There was a problem hiding this comment.
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 improves the error message when adk web is run from an incorrect directory. The changes add a smart detection mechanism to check for common mistakes, such as running the command from within an agent directory, and provide a clear, actionable hint to the user. The error message now also includes a visual diagram of the expected directory structure. My review focuses on improving the code's readability and modernizing the path handling.
Enhances the AgentLoader error message to help users who run 'adk web' from incorrect directories. This issue affected multiple teams during internal workshops when getting started with ADK. Changes: - Adds visual directory structure diagram to error message - Includes explicit 'adk web <agents_dir>' usage example - Detects when user is inside an agent directory and provides targeted hint to run 'adk web .' from parent directory Fixes google#3195
286a278 to
d73a5c6
Compare
Applies Gemini Code Assist bot suggestion to use pathlib.Path instead of os.path for improved readability and platform-agnostic path handling. Changes: - Replace os.path.isfile(os.path.join(...)) with Path.joinpath(...).is_file() - More concise and modern Python idiom - No semantic changes, maintains identical behavior
|
Response from ADK Triaging Agent Hello @jpantsjoha, thank you for your contribution! It looks like a few of the status checks are failing ( Could you please run the auto-formatter and the unit tests locally to fix these issues?
You can find more details in our contribution guidelines. Let us know if you have any questions. Thanks! |
|
Could you fix the lint error by running |
Reformatted code to comply with pyink style guide: - Line length limits enforced - Multi-line conditional formatting improved - String concatenation formatting optimized Addresses lint check failure in PR google#3196. Co-Authored-By: Claude <noreply@anthropic.com>
Reformatted code to comply with pyink style guide: - Line length limits enforced - Multi-line conditional formatting improved - String concatenation formatting optimized Addresses lint check failure in PR google#3196.
ad8d1a2 to
c89389c
Compare
Reformatted code to comply with pyink style guide: - Line length limits enforced - Multi-line conditional formatting improved - String concatenation formatting optimized Addresses lint check failure in PR google#3196.
c89389c to
e3b42aa
Compare
Reformatted code to comply with pyink style guide: - Line length limits enforced - Multi-line conditional formatting improved - String concatenation formatting optimized Addresses lint check failure in PR google#3196.
e3b42aa to
18b6f6d
Compare
…joha:jpantsjoha/adk-python into fix/improve-adk-web-error-message
Merge #3196 ## Summary Enhances the `AgentLoader` error message to provide clear guidance when users run `adk web` from incorrect directories. ## Motivation During internal workshops, multiple teams encountered confusion when starting `adk web` from the wrong directory. This often happened when: - Running `adk web my_agent/` instead of `adk web .` - Being inside an agent directory when executing the command - Configuring incorrect start paths during development ## Changes - **Smart detection**: Checks if `agent.py` or `root_agent.yaml` exists in the current directory - **Visual diagram**: Shows expected directory structure with actual agent name - **Explicit command**: Includes `adk web <agents_dir>` usage example - **Conditional hint**: Provides targeted guidance when user is detected to be inside an agent directory ## Example Error Message ### Before ``` ValueError: No root_agent found for 'my_agent'. Searched in 'my_agent.agent.root_agent', 'my_agent.root_agent' and 'my_agent/root_agent.yaml'. Ensure 'path/my_agent' is structured correctly, an .env file can be loaded if present, and a root_agent is exposed. ``` ### After ``` ValueError: No root_agent found for 'my_agent'. Searched in 'my_agent.agent.root_agent', 'my_agent.root_agent' and 'my_agent/root_agent.yaml'. Expected directory structure: <agents_dir>/ my_agent/ agent.py (with root_agent) OR root_agent.yaml Then run: adk web <agents_dir> Ensure 'path/my_agent' is structured correctly, an .env file can be loaded if present, and a root_agent is exposed. HINT: It looks like you might be running 'adk web' from inside an agent directory. Try running 'adk web .' from the parent directory that contains your agent folder, not from within the agent folder itself. ``` ## Testing - ✅ Existing unit tests pass (17/22, with 5 pre-existing failures unrelated to this change) - ✅ `test_agent_not_found_error` passes, confirming error message enhancement works correctly - ✅ Code follows ADK contribution guidelines ## Type - [x] Bug fix (improved error messaging) - [ ] Feature - [ ] Breaking change - [ ] Documentation ## Related Fixes #3195 --- **Tags**: #non-breaking 🤖 Generated with [Claude Code](https://claude.com/claude-code) COPYBARA_INTEGRATE_REVIEW=#3196 from jpantsjoha:fix/improve-adk-web-error-message a73b190 PiperOrigin-RevId: 822186700
|
This has been merged! Thank you for your contribution |
Summary
Enhances the
AgentLoadererror message to provide clear guidance when users runadk webfrom incorrect directories.Motivation
During internal workshops, multiple teams encountered confusion when starting
adk webfrom the wrong directory. This often happened when:adk web my_agent/instead ofadk web .Changes
agent.pyorroot_agent.yamlexists in the current directoryadk web <agents_dir>usage exampleExample Error Message
Before
After
Testing
test_agent_not_found_errorpasses, confirming error message enhancement works correctlyType
Related
Fixes #3195
Tags: #non-breaking
🤖 Generated with Claude Code