adk-web icon indicating copy to clipboard operation
adk-web copied to clipboard

Inconsistent behaviour between `adk web` vs `adk run`

Open shu8hamrajput opened this issue 9 months ago • 4 comments

the behaviour is different when running agent via run command and web command i have following dir structure.

agent_flow
├── __init__.py
├── agent.py

init.py looks like

from . import agent

agent.py looks like

from google.adk.agents import LlmAgent
from google.adk.tools import agent_tool

root_agent = LlmAgent(
    name="RefineRequest",
    model="gemini-2.0-flash",
    description="You are a agent that refines user requests",
    instruction=(
        " Your task is to refine the user request to make it more specific and actionable."
        " You can split the request into smaller tasks if needed."
        " You can ask clarifying questions or provide suggestions to improve the request."
    ),
    tools=[]
)

when running a agent from a module via adk run agent_flow the agent is able to start conversation with root_agent by default but when i run adk web agent_flow the ui can not detect any agent.

To Reproduce Steps to reproduce the behaviour:

  1. create above project structure
  2. Run adk run agent_flow
  3. Now run adk web agent_flow
  4. notice the difference

Expected behaviour the web should run with root_agent agent.

Desktop (please complete the following information):

  • OS: ProductName: macOS 13.7.5
  • Python version(python -V): Python 3.11.11
  • ADK version(pip show google-adk): google-adk 0.3.0

shu8hamrajput avatar Apr 29 '25 11:04 shu8hamrajput

Hi,

I was facing the same issue. The issue got resolved once I executed only adk web command from the root folder (in your case the folder containing agent_flow)

Rohit990634 avatar Apr 29 '25 17:04 Rohit990634

I ran into a similar problem. My project contains a directory with subagents like this

main_agent/
├── subagents/
│   ├── __init__.py
│   ├── subagent_1.py
│   └── subagent_2.py
├── __init__.py
└── agent.py

When running adk web main_agent it always loads subagents instead of main_agent. adk run main_agent runs correctly, however.

rodolfo-salgado avatar Apr 29 '25 21:04 rodolfo-salgado

Hi all, you need to run adk web in the PARENT folder of your agent. @shu8hamrajput , in your case, you need to run adk web in the parent folder of agent_flow, and @rodolfo-salgado same here, run adk web in the parent folder of main_agent.

There is a troubleshoot section in the tutorial doc stating this: https://google.github.io/adk-docs/get-started/quickstart/#run-your-agent

wyf7107 avatar May 04 '25 19:05 wyf7107

We are looking into adding the ability for you to run adk web directly with the agent folder, but for now run the command against the parent folder will solve

wyf7107 avatar May 04 '25 19:05 wyf7107