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

transfer_to_agent tool fails with unexpected kwarg

Open cschmidterNBTC opened this issue 1 year ago • 3 comments

Describe the bug transfer_to_agent tool fails with unexpected kwarg.

The root agent called the transfer_to_agent tool with a keyword argument query which raised a TypeError.

To Reproduce Steps to reproduce the behavior:

  1. Use a multi-agent framework
  2. Let the root agent call the transfer_to_agent tool
  3. The agent may pass in an unexpected keyword argument to the tool call.

Expected behavior Ideally, an agent should never call a tool with unexpected keyword args. A bandage solution would be to pass kwargs through the function:

def transfer_to_agent(agent_name: str, tool_context: ToolContext, **kwargs):
  """Transfer the question to another agent."""
  tool_context.actions.transfer_to_agent = agent_name

Desktop:

  • OS: Windows 11
  • Python version: 3.13
  • ADK version: 0.3.0

Additional context This error was encountered using gemini-2.5-pro-preview-03-25 and gemini-2.0-flash-001.

cschmidterNBTC avatar Apr 29 '25 17:04 cschmidterNBTC

@Jacksunwei @hangfei Can you please review the issue + PR and assign me the issue? Additionally if the PR is fine, start the process to merge it? Thanks!

AlankritVerma01 avatar Apr 30 '25 23:04 AlankritVerma01

As I mentioned in the PR.

I think the better approach could be improving the docstring, which will be in the prompt.

I guess the question in the docstring might cause model to fill query as arg.

Could you try adding docstring for agent_name argument will work?

Jacksunwei avatar May 01 '25 07:05 Jacksunwei

Hey @Jacksunwei Thanks for the feedback! i have updated the docstring as suggested. Please let me know if its fine now! Thank you!

AlankritVerma01 avatar May 02 '25 02:05 AlankritVerma01