adk-python
adk-python copied to clipboard
feat(cli): add adk graph command and --ascii-only option for DOT output
Close issue #3426
This adds a small-but-useful CLI feature for agent debugging and docs.
- New command:
adk graph <agent_dir> --format dot|png|svg [--out path] - New flag:
--ascii-only(DOT output only) to strip Unicode icons for Windows CMD
Usage:
python -m google.adk.cli graph contributing\samples\hello_world --format dot --ascii-only --out graph.dot python -m google.adk.cli graph contributing\samples\hello_world --format png --out hello.png (requires Graphviz)
Testing Plan
Environment: Windows 10/11, Python 3.12 venv Repo installed editable: pip install -e ".[test,eval,a2a]" Optional for images: winget install Graphviz.Graphviz
DOT output (no Graphviz needed):
python -m google.adk.cli graph contributing\samples\hello_world --format dot --ascii-only --out graph.dot Verify: type graph.dot | more Expect: strict digraph { ... hello_world_agent, roll_die, check_prime ... } Without ascii-only (UTF-8 console), optional: chcp 65001 set PYTHONIOENCODING=utf-8 python -m google.adk.cli graph contributing\samples\hello_world --format dot --out graph.dot
PNG/SVG (requires Graphviz):
python -m google.adk.cli graph contributing\samples\hello_world --format png --out hello.png dir hello.png (file exists)
Negative test:
python -m google.adk.cli graph invalid\path --format dot Expect a clear error about the path not existing.
No breaking changes:
adk run, adk web still work as before (unchanged).
Formatting:
python -m isort src tests contributing python -m pyink --config pyproject.toml src tests contributing
Summary of Changes
Hello @kamalraj23, I'm Gemini Code Assist[^1]! 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 significantly enhances the Agent Development Kit's command-line interface by introducing a new "graph" command. This feature allows developers to generate visual representations of their agent structures, which is invaluable for debugging complex agent flows and creating clear documentation. It supports various output formats, including DOT, PNG, and SVG, and includes a specific option to ensure compatibility for DOT output on Windows systems.
Highlights
- New CLI Command: "adk graph": Introduces a new command-line interface command "adk graph" to visualize agent structures, aiding in debugging and documentation.
- Multiple Output Formats: The "adk graph" command supports outputting agent graphs in DOT (text), PNG, and SVG formats, providing flexibility for different use cases.
- Windows Compatibility for DOT Output: Adds an "--ascii-only" flag for the "adk graph" command when outputting in DOT format, which strips non-ASCII characters to ensure compatibility with Windows command prompts that may not render Unicode correctly.
Using Gemini Code Assist
The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in pull request comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.
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 :thumbsup: and :thumbsdown: 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.
[^1]: Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.
Response from ADK Triaging Agent
Hello @kamalraj23, thank you for creating this PR!
This PR is a new feature, could you please associate the github issue with this PR? If there is no existing issue, could you please create one?
In addition, could you please provide a testing plan section in your PR to talk about how you will test?
This information will help reviewers to review your PR more efficiently. Thanks!
Hi @kamalraj23, Thank you for your work on this pull request. We appreciate the effort you've invested. It looks like the automated code formatting check failed. You can use autoformat.sh to fix it. Let us know once you have done the changes so we can begin the review process.