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

Potential problem of Agent-as-a-tool example

Open hkbb2014 opened this issue 1 year ago • 3 comments

https://google.github.io/adk-docs/tools/function-tools/ I follow Agent-as-a-tool code example, and defined 2 agents, and use adk web ui to test it.

# tool agent
summary_agent = Agent(
    model="gemini-2.0-flash",
    name="summary_agent",
    instruction="""You are an expert summarizer. Please read the following text and provide a concise summary.""",
    description="Agent to summarize text",
)

root_agent = Agent(
    model='gemini-2.0-flash',
    name='root_agent',
    instruction="""You are a helpful assistant. When the user provides a long text, use the 'summarize' tool to get a summary and then present it to the user.""",
    tools=[AgentTool(agent=summary_agent)]
)

Based on the instruction, I will expect the root_agent to pass the long text to the summary_agent, and get the summary there. But from the ui, what I see is a bit different.

Image

Instead of passing the original long text to summary agent, root_agent pass a summary to summary agent, and summary_agent return a summary for that summary. This is unexpected.

Image

And the summary returned seems longer than root agent's input.

hkbb2014 avatar Apr 16 '25 02:04 hkbb2014

Maybe we can play with the instruction to nudge root_agent to pass the user text as it is to the summary agent.

abhishm avatar Apr 16 '25 05:04 abhishm

@abhishm I see root_agent's instructions is already updated. It works for gemini now, but is not very stable for other local LLMs. Thanks!

hkbb2014 avatar Apr 17 '25 10:04 hkbb2014

I'm closing this as it works for Gemini. Not all local LLMs have the same ability to follow instructions, especially small LLMs. You may want to adjust the instructions for them or use other techniques.

boyangsvl avatar Apr 19 '25 01:04 boyangsvl