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

In sub_sgents, there is a situation where agents cross-call tools that do not belong to them

Open devin2255 opened this issue 1 year ago • 9 comments

Image

As shown in the figure, my update_plan_status_tool tool is bound under the observe_agent, but action_agent tried to call this tool during execution and got an error: ValueError: Function update_plan_status is not found in the tools_dict.

Image

devin2255 avatar Sep 25 '25 09:09 devin2255

+1 we also started seeing this behavior when using 'adk web' from the latest version (1.14.0+)

reyolivo avatar Sep 25 '25 14:09 reyolivo

Actually, after doing some versioning checks - this bug appears to have been introduced in version 1.9.0 of google-adk. My agents works fine in adk web in version 1.8.0 and anything prior to that.

[EDIT] I lied, this is happening in versions 1.8.0 and 1.7.0 as well...

reyolivo avatar Sep 25 '25 15:09 reyolivo

@Jacksunwei hello, Is there any progress on this issue?

devin2255 avatar Sep 29 '25 01:09 devin2255

any update on this? We were able to reduce the frequency of the error by including tool specific instructions in the system prompt...but still not 100% resolved, and feels like a bad pattern to continue using. Is there at least a better way to catch an incorrect tool from being called, and have the agent retry? An example would be very helpful

reyolivo avatar Oct 01 '25 13:10 reyolivo

Does anyone have a minimal agent code that can reproduce this?

boyangsvl avatar Oct 08 '25 21:10 boyangsvl

Does anyone have a minimal agent code that can reproduce this?有没有人能提供一个能复现此问题的最小化智能体代码?

@reyolivo

devin2255 avatar Oct 10 '25 05:10 devin2255

Hi @devin2255 and @reyolivo,

Thanks for reporting this issue. After investigating the codebase, I can confirm that ADK correctly scopes tools per agent - each agent only receives its own tools in the LLM request, not tools from other agents.

Debugging Steps:

  1. Check the actual prompt sent to the LLM - Run adk web with verbose logging:

    adk web -v
    

    Look at the system instruction and tool declarations when action_agent is active. Verify whether update_plan_status_tool incorrectly appears in either:

    • The tool declarations for action_agent
    • The system instruction mentioning this tool
  2. If the tool doesn't appear in the prompt, this is likely model hallucination - the LLM is generating function calls for tools that don't exist in its available tool list.

Recommended Solutions:

  1. Use ReflectAndRetryToolPlugin (available since v1.16.0) to automatically handle tool hallucinations:

    from google.adk.plugins.reflect_retry_tool_plugin import ReflectAndRetryToolPlugin
    # Add to your app configuration
    
  2. Strengthen agent instructions - Explicitly list available tools in each agent's instruction:

    action_agent.instruction = """
    You have access to ONLY these tools: tool_a, tool_b, tool_c.
    Do NOT attempt to call any other tools.
    """
    
  3. Provide examples - Show the agent correct tool usage patterns in the instruction.

This matches what @reyolivo found - adding tool-specific instructions reduces the error frequency by helping the model stay focused on its available tools.

Let us know if the debug logging shows the unavailable tool in the prompt - that would indicate a different issue.

Jacksunwei avatar Oct 27 '25 03:10 Jacksunwei

This issue has been automatically marked as stale because it has not had recent activity for 7 days after a maintainer requested clarification. It will be closed if no further activity occurs within 7 days.

adk-bot avatar Dec 03 '25 20:12 adk-bot

This has been automatically closed because it has been marked as stale for over 7 days.

adk-bot avatar Dec 12 '25 03:12 adk-bot