Skip to content

fix: use Optional[str] instead of str | None for Google ADK function parameters #515

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

jonigl
Copy link

@jonigl jonigl commented May 13, 2025

Fix Google ADK Python Sample

Summary

Fixed automatic function calling errors in the Google ADK agent by replacing str | None type hints with Optional[str] in function signatures. This makes the function signatures compatible with automatic function calling parsers.

The error

This error happens when trying to use the google adk agent from the python samples https://github.com/google/A2A/tree/main/samples/python/agents/google_adk .

When requesting a reimbursement in a conversation the agent tries to handle the form but it fails throwing the following error:

ERROR:task_manager:An error occurred while streaming the response: Failed to parse the parameter date: str | None = None of function create_request_form for automatic function calling. Automatic function calling works best with simpler function signature schema,consider manually parse your function declaration for function create_request_form.
  • Also check the screenshots below.

Changes

  • Updated type annotations in create_request_form function
  • Updated type annotations in return_form function
  • Added proper import of Optional from typing module

Testing

Verified that the agent now properly handles function calls without parsing errors.

Some screenshots

  • Running agent and demo ui
    Screenshot 2025-05-13 at 11 38 20
  • Adding the agent
    Screenshot 2025-05-13 at 11 38 38
  • Requesting a reimbursement makes agent to fail
    Screenshot 2025-05-13 at 11 39 59
  • Here it is the error
    Screenshot 2025-05-13 at 11 40 12
ERROR:task_manager:An error occurred while streaming the response: Failed to parse the parameter date: str | None = None of function create_request_form for automatic function calling. Automatic function calling works best with simpler function signature schema,consider manually parse your function declaration for function create_request_form.
  • Once applying the fix it is working as expected
    Screenshot 2025-05-13 at 11 54 10
  • Form is shown and correctly handled by the agent
    Screenshot 2025-05-13 at 11 54 17

Description

Thank you for opening a Pull Request!
Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

Fixes #457 , #422 🦕

jonigl added 2 commits May 13, 2025 11:56
…parameters

Fixes automatic function calling errors in the Google ADK agent implementation.
@jonigl
Copy link
Author

jonigl commented May 13, 2025

this was fixed some hours ago by this PR #510 thanks @swapydapy 🙌

@jonigl
Copy link
Author

jonigl commented May 13, 2025

closing this PR now

@jonigl jonigl closed this May 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant