google / google/adk-docs

Allow modern Union type for FunctionTool

Open
#854 2 comments 0 reactions 2 assignees Claimed by @klateefa View on GitHub
tools
Dominant language
Shell
Stars
1.5k
Forks
1.3k
Avg merge
7d 1h
Merged PRs (30d)
34

Description

** Please make sure you read the contribution guide and file the issues in the right place. **
[Contribution guide.](https://google.github.io/adk-docs/contributing-guide/)

**Describe the bug**
Version 1.13.0, 1.14.0

The documentation describes that FunctionTool is capable of using parameters with the modern python Union type i.e. `| None` (see https://google.github.io/adk-docs/tools/function-tools/#required-parameters).

Yet it doesn't seem to work:
```
ValueError: Failed to parse the parameter name: str | None = None of function say_hello for automatic function calling. Automatic function calling works best with simpler function signature schema, consider manually parsing your function declaration for function say_hello.
```

**To Reproduce**
Use the following tool with an LLMAgent
```
from google.adk.tools import FunctionTool

def say_hello(name:str|None=None):
if name:
return f"Hello {name}!"
else:
return "Hello!"

def say_hello_tool():
return FunctionTool(say_hello)
```

**Expected behavior**
No ValueError and correct type identification

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.