Module 5: Running and Interacting with Agents
Theory​
Bringing Your Agent to Life​
Creating an agent configuration is the first step, but to test and use your agent, you need to run it. The ADK provides a powerful and flexible command-line interface (CLI) that offers several ways to run your agent, each suited for different stages of the development lifecycle.
Understanding these different execution modes is key to efficiently developing, debugging, and eventually deploying your agents.
1. Interactive Development: adk web​
The adk web command is your primary tool during development. It starts a local web server that hosts the ADK Developer UI.
Key Features:
- Chat Interface: Provides a user-friendly chat window to interact with your agent in real-time.
- Trace View: This is the most powerful feature. It gives you a detailed, step-by-step visualization of your agent's execution flow. You can see the exact prompts sent to the LLM, which tools were called with which arguments, the data returned by the tools, and any changes to the agent's internal state. This is invaluable for debugging.
- Session Management: The UI allows you to manage different conversation sessions, so you can test how your agent behaves over multiple interactions.
- No Code Changes Needed: You can test and iterate on your
root_agent.yamlconfiguration without restarting the server. Simply save your changes, and the UI will use the updated configuration for the next conversation.
The Dev UI is the best way to get immediate feedback and deep insight into your agent's reasoning process.
2. Headless Interaction: adk run​
The adk run command allows you to interact with your agent directly from your terminal, without a graphical user interface.
Key Features:
- Command-Line Chat: It drops you into a simple, text-based chat session with your agent.
- Quick Testing: It's a fast way to test a specific input or a simple conversation without the overhead of launching a web browser.
- Scripting and Automation: Because it runs in the terminal,
adk runcan be used in automated testing scripts. You can pipe input to it and check the output to verify the agent's behavior.
This mode is ideal for quick checks and for integrating agent tests into a continuous integration (CI) pipeline.