Automatic Function Calling doesn't support parametric generics within union type function argument #22
Labels
priority: p1
Important issue which blocks shipping the next release. Will be fixed prior to next release.
type: bug
Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
I found that the library is unable to parse a function tool parameter if it's a union type and contains a parametrized generic. The example type in my case was
Optional[list[str]]
. The error occurs when using the automatic function calling functionality.When iterating over the union types,
isinstance(value, arg)
is called, I believe the fix is to modify this toisinstance(value, get_origin(arg))
on this line:python-genai/google/genai/_extra_utils.py
Line 141 in cf3c476
The function tool worked correctly after making this modification.
Environment details
Steps to reproduce
When I run this snippet, the library catches the error
'isinstance() argument 2 cannot be a parameterized generic'
and the full output is:The text was updated successfully, but these errors were encountered: