Skip to content

Conversation

@SOORAJTS2001
Copy link
Contributor

@SOORAJTS2001 SOORAJTS2001 commented Oct 3, 2025

Ran the whole unittests
image

For unittests/tools
image

Test result for test_build_function_declaration.py
image

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @SOORAJTS2001, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a significant enhancement by enabling the use of Python Enum types as arguments for function tools. This change improves the robustness and expressiveness of tool definitions by allowing developers to specify a fixed set of valid choices for parameters, which is then correctly reflected in the generated tool schemas. The update ensures that Enum values are properly converted to string types with enumerated options, providing a more structured and error-resistant way to define tool interfaces.

Highlights

  • Enum Support for Function Tools: Added comprehensive support for using Python Enum types as arguments for function tools, enhancing type safety and clarity in tool definitions.
  • Automated Schema Generation: The function parameter parser (_function_parameter_parse_util.py) has been updated to correctly interpret Enum parameters, mapping them to STRING types in the generated tool schemas and populating the enum field with the value of each enum member.
  • Default Value Handling: Logic has been included to properly handle and validate default values for Enum parameters during schema generation.
  • New Unit Tests: A new unit test (test_enums) has been added to test_build_function_declaration.py to verify the accurate parsing and schema generation for functions utilizing Enum parameters.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@adk-bot adk-bot added bot triaged tools [Component] This issue is related to tools labels Oct 3, 2025
@adk-bot adk-bot requested a review from seanzhou1023 October 3, 2025 21:09
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for using enums as parameters in function tools. The implementation correctly identifies enum types and extracts their values for the schema. However, there is a bug in handling default values for enum parameters, which will cause an exception. I've provided a code suggestion to fix this. Additionally, the unit tests for this new feature could be expanded to cover cases with default values to prevent such issues in the future. I've included examples of test cases that should be added.

SOORAJTS2001 and others added 2 commits October 4, 2025 15:16
fix: Add more test cases inside `test_build_function_declaration.py` for passing Enums as arguments
@SOORAJTS2001
Copy link
Contributor Author

@seanzhou1023 please take a look at this

@surajksharma07 surajksharma07 self-assigned this Oct 6, 2025
@SOORAJTS2001
Copy link
Contributor Author

Hi @surajksharma07 !
Anything to be done from my side?

@surajksharma07
Copy link
Collaborator

Hi @SOORAJTS2001,

Thank you for your contribution to the ADK project.

The changes in src/google/adk/tools/_function_parameter_parse_util.py to correctly parse Enum values and handle their defaults in the schema generation look correct now.

Before we proceed with the final review and merge, could you please address the following points?

  1. Unit Test Enhancement: As noted in the review comments, robust testing is crucial. Please expand the unit tests in test_build_function_declaration.py to cover all scenarios for Enum parameters, including:

    • A case with a valid default value (e.g., param: MyEnum = MyEnum.VALUE).
    • A case that should fail when an invalid default value is provided.
  2. Code Style: The code looks good and generally aligns with our style guide. Please just give it a final check to ensure all new code, including the tests, fully adheres to the project's formatting and linting rules.

Once these adjustments are made, we can proceed with the final testing and merge. Let us know if you have any questions.

@surajksharma07 surajksharma07 added the request clarification [Status] The maintainer need clarification or more information from the author label Oct 7, 2025
@SOORAJTS2001
Copy link
Contributor Author

image

Hi @surajksharma07
I have already added the test case for checking default value and invalid value as show here

@surajksharma07 surajksharma07 requested a review from hangfei October 7, 2025 18:50
@surajksharma07 surajksharma07 added need attention [Status] This issue is important but the maintainers haven't started working on it wip [Status] This issue is being worked on. Either there is a pending PR or is planned to be fixed labels Oct 7, 2025
@boyangsvl boyangsvl linked an issue Oct 8, 2025 that may be closed by this pull request
@SOORAJTS2001
Copy link
Contributor Author

@surajksharma07 @hangfei @seanzhou1023 any update on this?

@SOORAJTS2001
Copy link
Contributor Author

@surajksharma07 @hangfei @seanzhou1023 @polong-lin
Anything to be done by my side?

@SOORAJTS2001
Copy link
Contributor Author

Oh sorry, will fix the formatting issue

@yyyu-google
Copy link
Collaborator

thank you, alternatively, i can co contribute to the fix if you like. let me know

@yyyu-google yyyu-google merged commit 240ef5b into google:main Oct 28, 2025
10 checks passed
@Jacksunwei Jacksunwei added this to the 10/27 ADK Week milestone Oct 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

need attention [Status] This issue is important but the maintainers haven't started working on it request clarification [Status] The maintainer need clarification or more information from the author tools [Component] This issue is related to tools wip [Status] This issue is being worked on. Either there is a pending PR or is planned to be fixed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for enums as arguments for function tool

6 participants