Skip to main content

Lab 5: Exploring Different Execution Modes Challenge

Goalโ€‹

Your task is to run and interact with your "Support Analyzer" agent using the three primary execution modes provided by the ADK CLI. Always run these commands from your main adk-training directory.

Environment setup: this lab modifies the support_analyzer project from Module 4, in place -- it's not a fresh project. If you're continuing the course in sequence, cd into that project (inside your adk-training directory) and you're all set. If you're starting fresh at this module, you'll need that project first -- Module 4's lab-solution.md has the complete support_analyzer code to recreate it, then come back here. Note that lab-solution.md usually only shows the contents of agent.py; if that's not enough to get a working project (e.g. you still need to scaffold it with uv/adk create), check Module 4's lab.md for those setup steps.

Lab Tasksโ€‹

  1. uv run adk web:
    • Run the command uv run adk web.
    • Note: When running from the parent directory, you don't need to specify the agent name; the Dev UI will allow you to select any agent in the subdirectories.
    • Interact with your support_analyzer in the Dev UI and inspect the "Trace" view to see the full prompt sent to the LLM.
  2. uv run adk run:
    • Stop the web server (Ctrl+C).
    • Run the command uv run adk run support_analyzer.
    • Interact with the agent directly in your terminal.
  3. uv run adk api_server:
    • Stop the command-line runner.
    • Run the command uv run adk api_server.
    • Open a separate terminal window to act as the client.
    • Step A (The Failure): Try to send a message without creating a session first. Copy and run this command:
      curl -X POST http://127.0.0.1:8000/run_sse \
      -H "Content-Type: application/json" \
      -d '{
      "app_name": "support_analyzer",
      "user_id": "test_user",
      "session_id": "missing_session",
      "new_message": {"role": "user", "parts": [{"text": "Hello"}]}
      }'
      Observe the error response. Why did it fail?
    • Step B (The Fix): Create the session explicitly.
      curl -X POST http://127.0.0.1:8000/apps/support_analyzer/users/test_user/sessions/test_session
    • Step C (Success): Now send the message again, targeting the session you just created (test_session).
      curl -X POST http://127.0.0.1:8000/run_sse \
      -H "Content-Type: application/json" \
      -d '{
      "app_name": "support_analyzer",
      "user_id": "test_user",
      "session_id": "test_session",
      "new_message": {"role": "user", "parts": [{"text": "I am so happy with your service!"}]}
      }'
    • Verify that you receive a stream of JSON responses containing the structured analysis (category, sentiment, summary).

Self-Reflection Questionsโ€‹

  • In what scenarios would the detailed "Trace View" in uv run adk web be more useful than the simple chat interface of uv run adk run?
  • The curl command in the uv run adk api_server section is a simple example of a programmatic client. What kind of real-world applications could you build that would interact with your agent's API in this way?
  • Why is it necessary to run the uv run adk api_server and the curl command in two separate terminal windows? What does this separation represent in a real-world application architecture?

๐Ÿ” Reference Solution Vaultโ€‹

๐Ÿ”

Module 05 Reference Solution Vault

Active Comprehension Gate โ€ข Zero Guessable URLs โ€ข Guided Verification

Step 1/3: Question 1 of 3

Where MUST the `adk web` command be launched in your terminal filesystem?