Skip to content

How to handle 'Function is not found in the tools_dict' Error #2933

@kxcode

Description

@kxcode

sometimes Gemini calls function with wrong tool name, will cause a ValueError, how can I handle this Error

line 447, in _run_one_step_async
    async for event in agen:
  File "/python3.12/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 539, in _postprocess_async
    async for event in agen:
  File "/python3.12/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 632, in _postprocess_handle_function_calls_async
    if function_response_event := await functions.handle_function_calls_async(
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python3.12/site-packages/google/adk/flows/llm_flows/functions.py", line 198, in handle_function_calls_async
    return await handle_function_call_list_async(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python3.12/site-packages/google/adk/flows/llm_flows/functions.py", line 246, in handle_function_call_list_async
    function_response_events = await asyncio.gather(*tasks)
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python3.12/site-packages/google/adk/flows/llm_flows/functions.py", line 280, in _execute_single_function_call_async
    tool, tool_context = _get_tool_and_context(
                         ^^^^^^^^^^^^^^^^^^^^^^
  File "/python3.12/site-packages/google/adk/flows/llm_flows/functions.py", line 651, in _get_tool_and_context
    raise ValueError(
ValueError: Function add_-plan_step is not found in the tools_dict

Metadata

Metadata

Assignees

No one assigned

    Labels

    question[Component] This issue is asking a question or clarification

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions