Skip to content

Tool name concatenation issue during LLM function calling causes JSONDecodeError #984

@Ladun

Description

@Ladun

Describe the bug
When using AgentTool and FunctionTool together in tools, the tool name during function calling is concatenated, causing an error.
Example:

tools = [AgentTool(agent1), FunctionTool(function1)]
The function name becomes agent1function1 instead of just function1, and arguments are passed like this:
{'request': ~~~}{'function1_arg': ~~~}

This results in an error during JSON parsing because the arguments are not valid JSON.

To Reproduce
Steps to reproduce the behavior:

Define tools = [AgentTool(agent1), FunctionTool(function1)]

Let the LLM call a function

Observe the tool name and arguments passed to the function call

See the JSONDecodeError

Expected behavior
The function name should be passed as function1, not agent1function1. Arguments should be valid JSON (e.g., merged into a single object) to avoid JSONDecodeError.

If needed, here's the error trace:

  File "---/.venv/lib/python3.11/site-packages/google/adk/models/lite_llm.py", line 461, in _message_to_generate_content_response
    args=json.loads(tool_call.function.arguments or "{}"),
  File ".../lib/python3.11/json/__init__.py", line 346, in loads 
    return _default_decoder.decode(s)
  File ".../lib/python3.11/json/decoder.py", line 340, in decode
    raise JSONDecodeError("Extra data", s, end)

Desktop (please complete the following information):

OS: Ubuntu 22.04 (WSL)

Python version: Python 3.11.12

ADK version: google-adk 1.0.0

Additional context
The function and agent names above are simplified for clarity. The key issue is that concatenated tool names and malformed argument structures lead to a JSONDecodeError. This may require internal separation of namespaces or clearer serialization logic.

Metadata

Metadata

Assignees

Labels

tools[Component] This issue is related to tools

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions