ValueError: Function json_tool_call is not found in the tools_dict (Azure OpenAI GPT-4.1-mini)
Description
The ADK web server encounters a ValueError when the LLM attempts to call a function named json_tool_call that doesn't exist in the tools_dict. This appears to be a case where the model hallucinates a non-existent function name.
Error Message
ERROR:google_adk.google.adk.cli.adk_web_server:Error in event_generator: Function json_tool_call is not found in the tools_dict.
Stack Trace
Traceback (most recent call last):
File "/path/to/user/.venv/lib/python3.13/site-packages/google/adk/cli/adk_web_server.py", line 1066, in event_generator
async for event in agen:
...<7 lines>...
yield f"data: {sse_event}\n\n"
File "/path/to/user/.venv/lib/python3.13/site-packages/google/adk/runners.py", line 314, in run_async
async for event in agen:
yield event
File "/path/to/user/.venv/lib/python3.13/site-packages/google/adk/runners.py", line 310, in _run_with_trace
async for event in agen:
yield event
File "/path/to/user/.venv/lib/python3.13/site-packages/google/adk/runners.py", line 354, in _exec_with_plugin
async for event in agen:
...<8 lines>...
yield (modified_event if modified_event else event)
File "/path/to/user/.venv/lib/python3.13/site-packages/google/adk/runners.py", line 304, in execute
async for event in agen:
yield event
File "/path/to/user/.venv/lib/python3.13/site-packages/google/adk/agents/base_agent.py", line 248, in run_async
async for event in agen:
yield event
File "/path/to/user/.venv/lib/python3.13/site-packages/google/adk/agents/base_agent.py", line 238, in _run_with_trace
async for event in agen:
yield event
File "/path/to/user/.venv/lib/python3.13/site-packages/google/adk/agents/llm_agent.py", line 288, in _run_async_impl
async for event in agen:
self.__maybe_save_output_to_state(event)
yield event
File "/path/to/user/.venv/lib/python3.13/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 401, in run_async
async for event in agen:
last_event = event
yield event
File "/path/to/user/.venv/lib/python3.13/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 447, in _run_one_step_async
async for event in agen:
...<3 lines>...
yield event
File "/path/to/user/.venv/lib/python3.13/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 539, in _postprocess_async
async for event in agen:
yield event
File "/path/to/user/.venv/lib/python3.13/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 667, in _postprocess_handle_function_calls_async
async for event in agen:
yield event
File "/path/to/user/.venv/lib/python3.13/site-packages/google/adk/agents/base_agent.py", line 248, in run_async
async for event in agen:
yield event
File "/path/to/user/.venv/lib/python3.13/site-packages/google/adk/agents/base_agent.py", line 238, in _run_with_trace
async for event in agen:
yield event
File "/path/to/user/.venv/lib/python3.13/site-packages/google/adk/agents/sequential_agent.py", line 46, in _run_async_impl
async for event in agen:
yield event
File "/path/to/user/.venv/lib/python3.13/site-packages/google/adk/agents/base_agent.py", line 248, in run_async
async for event in agen:
yield event
File "/path/to/user/.venv/lib/python3.13/site-packages/google/adk/agents/base_agent.py", line 238, in _run_with_trace
async for event in agen:
yield event
File "/path/to/user/.venv/lib/python3.13/site-packages/google/adk/agents/loop_agent.py", line 63, in _run_async_impl
async for event in agen:
...<2 lines>...
should_exit = True
File "/path/to/user/.venv/lib/python3.13/site-packages/google/adk/agents/base_agent.py", line 248, in run_async
async for event in agen:
yield event
File "/path/to/user/.venv/lib/python3.13/site-packages/google/adk/agents/base_agent.py", line 238, in _run_with_trace
async for event in agen:
yield event
File "/path/to/user/.venv/lib/python3.13/site-packages/google/adk/agents/llm_agent.py", line 288, in _run_async_impl
async for event in agen:
self.__maybe_save_output_to_state(event)
yield event
File "/path/to/user/.venv/lib/python3.13/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 401, in run_async
async for event in agen:
last_event = event
yield event
File "/path/to/user/.venv/lib/python3.13/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 447, in _run_one_step_async
async for event in agen:
...<3 lines>...
yield event
File "/path/to/user/.venv/lib/python3.13/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 539, in _postprocess_async
async for event in agen:
yield event
File "/path/to/user/.venv/lib/python3.13/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(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
invocation_context, function_call_event, llm_request.tools_dict
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
):
^
File "/path/to/user/.venv/lib/python3.13/site-packages/google/adk/flows/llm_flows/functions.py", line 198, in handle_function_calls_async
return await handle_function_call_list_async(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...<5 lines>...
)
^
File "/path/to/user/.venv/lib/python3.13/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 "/path/to/user/.venv/lib/python3.13/site-packages/google/adk/flows/llm_flows/functions.py", line 280, in _execute_single_function_call_async
tool, tool_context = _get_tool_and_context(
~~~~~~~~~~~~~~~~~~~~~^
invocation_context,
^^^^^^^^^^^^^^^^^^^
...<2 lines>...
tool_confirmation,
^^^^^^^^^^^^^^^^^^
)
^
File "/path/to/user/.venv/lib/python3.13/site-packages/google/adk/flows/llm_flows/functions.py", line 651, in _get_tool_and_context
raise ValueError(
f'Function {function_call.name} is not found in the tools_dict.'
)
ValueError: Function json_tool_call is not found in the tools_dict
Environment
- Python: 3.13
- google-adk: 1.14.1
- Model: Azure OpenAI GPT-4.1-mini (via LiteLLM)
- Running via adk_web_server
Related Issues
This is similar to #2924, #2933, and #2346, but with a specific function name json_tool_call that appears to be hallucinated by the model when using Azure OpenAI.
Expected Behavior
The system should gracefully handle cases where the LLM attempts to call non-existent functions, either by:
- Returning an appropriate error event to the user
- Implementing a retry mechanism with corrected function names
- Providing a way to catch and handle these errors in plugins
Impact
This error causes the entire agent flow to stop, making the ADK web interface unusable until restarted.
Additional Context
This issue occurs when using Azure OpenAI's GPT-4.0-mini model through LiteLLM integration. The model appears to hallucinate a function called json_tool_call which doesn't exist in the defined tools.
Hi,
I had the same problem, but it’s not an issue with the adk library itself. Check which API version you’re setting in your model configuration—LiteLLM doesn’t configure structured outputs for anything below:
API_VERSION_YEAR_SUPPORTED_RESPONSE_FORMAT = 2024 API_VERSION_MONTH_SUPPORTED_RESPONSE_FORMAT = 8
see: GitHub link litellm/types/llms/azure.py
In my case, I just had to set the API version to the most recent one: 2025-04-01-preview.
Hope this helps!