transfer_to_agent tool fails with unexpected kwarg
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:
- Use a multi-agent framework
- Let the root agent call the transfer_to_agent tool
- 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.
@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!
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?
Hey @Jacksunwei Thanks for the feedback! i have updated the docstring as suggested. Please let me know if its fine now! Thank you!