Skip to content

transfer_to_agent tool fails with unexpected kwarg #458

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
cschmidterNBTC opened this issue Apr 29, 2025 · 3 comments · May be fixed by #466
Open

transfer_to_agent tool fails with unexpected kwarg #458

cschmidterNBTC opened this issue Apr 29, 2025 · 3 comments · May be fixed by #466
Assignees
Labels
core Issues related to the core interface and implementation

Comments

@cschmidterNBTC
Copy link

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.

AlankritVerma01 added a commit to AlankritVerma01/adk-python that referenced this issue Apr 30, 2025
transfer_to_agent now takes **kwargs to swallow unexpected keyword args
Added integration tests covering single and multiple extra kwargs.
Fixes google#458.
@AlankritVerma01
Copy link
Contributor

@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!

@Jacksunwei
Copy link
Collaborator

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?

AlankritVerma01 added a commit to AlankritVerma01/adk-python that referenced this issue May 2, 2025
…usage

Revert the earlier **kwargs change so transfer_to_agent again only accepts
(agent_name, tool_context).  Improve the doc-string to make clear that no
other parameters should be passed to this tool.

Fixes google#458
@AlankritVerma01
Copy link
Contributor

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

@hangfei hangfei added the core Issues related to the core interface and implementation label May 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Issues related to the core interface and implementation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants