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

Agent calling tool without required arguments

Open gwbischof opened this issue 1 year ago • 1 comments

Describe the bug The agent is calling roll_die with no args. I am getting this error:

user: Can you roll a die?
Traceback (most recent call last):
...
TypeError: roll_die() missing 1 required positional argument: 'sides'

Here is my code:

def roll_die(sides: int):
    return random.randint(1, 6)

root_agent = Agent(
    name="die_agent",
    model="gemini-2.0-flash",
    description=(
        "Agent to roll a die."
    ),
    instruction=(
        "You are a helpful agent that can roll a die for a user"
    ),
    tools=[roll_die],
)

Expected behavior I know the tool should have a docstring, and adding the docstring may fix the problem. But I think the agent should know the function signature and that it can't call the tool without providing the required arguments.

Desktop (please complete the following information):

  • OS: macos
  • Python version(python -V): 3.13
  • ADK version(pip show google-adk): 0.3.0

gwbischof avatar Apr 27 '25 00:04 gwbischof

Fixed in https://github.com/google/adk-python/commit/f872577f683cf7644d4d7fac31c687b023953b3c

Please reopen if you have any follow up questions.

ankursharmas avatar Apr 28 '25 20:04 ankursharmas