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

TypeError: transfer_to_agent() got an unexpected keyword argument 'parameters'

Open woosung1223 opened this issue 1 year ago • 6 comments

 File "/.venv/lib/python3.12/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 417, in _postprocess_handle_function_calls_async
    if function_response_event := await functions.handle_function_calls_async(
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.venv/lib/python3.12/site-packages/google/adk/flows/llm_flows/functions.py", line 165, in handle_function_calls_async
    function_response = await __call_tool_async(
                        ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.venv/lib/python3.12/site-packages/google/adk/flows/llm_flows/functions.py", line 430, in __call_tool_async
    return await tool.run_async(args=args, tool_context=tool_context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.venv/lib/python3.12/site-packages/google/adk/tools/function_tool.py", line 82, in run_async
    return self.func(**args_to_call) or {}
           ^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: transfer_to_agent() got an unexpected keyword argument 'parameters'

I'm getting an error like this in a rare case when calling a subagent (about 1 out of 20 times).

I've only modified the tool and sub-agent configuration, so I don't think there's anything I need to change. How do I fix this? thanks.

woosung1223 avatar Jun 25 '25 06:06 woosung1223

I Have the exact same problem.

When transferring, in your case, it's passing "parameters". In my case it as passing "query" and sometimes "questions"

I've solved this by explicitly mentioning not to add any parameters when transferring, in the prompt (I know, I know, it's not the fix, but it works)

Apollovishwas avatar Jun 25 '25 09:06 Apollovishwas

I haven't encountered this since they closed this issue #458. But, for a workaround, you may want to add **kwargs to transfer_to_agent or change the docstring there yourself.

cschmidterNBTC avatar Jun 25 '25 12:06 cschmidterNBTC

@woosung1223 thanks for reporting this.

Could you share the error log(what function returned by model)?

Could you share a minimal example to reproduce it?

hangfei avatar Jun 26 '25 03:06 hangfei

@hangfei

Content(parts=[
Part(video_metadata=None, thought=None, code_execution_result=None, executable_code=None, file_data=None, 
function_call=FunctionCall(id='adk-4774fbcc-d6b8-4eee-b3b1-64f082e8f9d0', 
args={'parameters': {'key1': 'value1', 'key2': 'value2'}, 'agent_name': 'product_extractor_agent'}, 
name='transfer_to_agent'), function_response=None, inline_data=None, text=None)], role='model')"

I modified the internal values ​​of the parameters because there were parts that should not be shown.

The code is structured as a general subagent call structure. No separate detailed settings are provided.

# sub agent
product_extractor_agent = Agent(
    name="product_extractor_agent",
    model="gemini-2.5-flash",
    description="Extract product information from the email",
    instruction=INSTRUCTION,
)

# parent agent
email_analysis_agent = Agent(
    name="email_analysis_agent",
    model="gemini-2.5-flash",
    description="Analyze the intention and take appropriate action",
    tools=[load_top_n_emails, get_email_details],
    sub_agents=[product_extractor_agent],
    instruction=INSTRUCTION,
)

thanks.

woosung1223 avatar Jun 27 '25 00:06 woosung1223

It's fixed and should be in next release. thanks!

hangfei avatar Jul 02 '25 00:07 hangfei

hi, there, thank you so much for fixing this issue. may i ask when it will be released?

xiaodantiancolacopilot avatar Jul 23 '25 08:07 xiaodantiancolacopilot