Repository navigation
feat(cli): add adk graph command - #7466
Open
BichengWang wants to merge 1 commit into
Open
BichengWang wants to merge 1 commit into
BichengWang wants to merge 1 commit into
Conversation
Renders an agent's structure with the existing agent_graph builder, so the tree can be inspected without starting the dev UI. Prints DOT by default and can write DOT, PNG or SVG to a file (PNG and SVG need Graphviz). --ascii-only drops the emoji label prefix for consoles that cannot encode it.
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.
Closes #3426
Problem
The agent graph is only available through the dev UI. There is no way to get it from the command line, for example to check the structure of a multi-agent setup in CI or paste it into a doc.
Change
New command
adk graph AGENT, built on the existingagent_graph.get_agent_graph:--formatisdot(default),pngorsvg. png and svg are rendered by Graphviz and need--output; if thedotexecutable is missing the command says so instead of printing a traceback.--ascii-onlyremoves the emoji prefix from node labels, so the DOT can be written on consoles that can't encode it. It only toucheslabel="...", so non-ASCII agent names keep distinct nodes.AgentLoaderthe same wayadk rundoes, and anAppis unwrapped to its root agent.ClickExceptions.The graph is built with the same default palette as the dev UI (dark background). Note that building it resolves the agent's tools, so toolsets such as MCP servers are contacted, as they are when the dev UI draws the graph.
Testing plan
New tests in
tests/unittests/cli/utils/test_cli_tools_click.py:--ascii-only, including a case with two non-ASCII agent names--outputrequired for png/svg,--ascii-onlyrejected for png/svgpytest tests/unittests/cli/utils/test_cli_tools_click.py tests/unittests/cli/test_cli_tools_click_option_mismatch.pygives 143 passed, 1 xfailed. pyink and isort are clean. I also ran the command by hand on a small agent with a sub-agent and a tool (DOT output and--ascii-only); I didn't have Graphviz installed, so the png/svg path is covered by the mocked tests only.