-
Notifications
You must be signed in to change notification settings - Fork 457
Validate the input must be a struct when creating tools #331
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
Conversation
Summary of ChangesHello @git-hulk, 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 enhances the Highlights
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this 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 a validation check to ensure that function tool inputs are structs. The reflection-based implementation in function.go is solid and correctly handles pointers. The tests are also well-updated, with new cases in TestNew_InvalidInputType to cover the new validation.
I found a minor copy-paste error in a new test case that would cause a compilation failure, and I've provided a suggestion to fix it.
Additionally, it appears tool/tool_test.go was not updated and contains a test that will now fail. You'll likely need to update it to use a struct-based tool to get the build to pass.
|
@mazas-google Thanks for your review. I have applied the review suggestions. |
mazas-google
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
kdroste-google
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
16fc557
kdroste-google
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
a6117da
a6117da to
82973ad
Compare
|
Sorry for missing the lint error in CI, I have enabled the CI on my side and confirmed it works well: https://github.com/git-hulk/adk-go/actions/runs/19690326139/job/56404514448. By the way, is it possible to enable CI on every push operation instead of only for the |
|
|
@dpasiukevich I also considered this situation while fixing this issue. But it seems |
|
For example if we have this go func This will generate the following jsonschema for input
It all depends on the LLM instruction. For example if there's such instruction Then LLM will define both fields/keys and values. I agree, using structs is more straightforward as it defines a concrete schema. IMO we should restrict the functiontool Args to types which can be converted to json |
|
@dpasiukevich Aha, I see. It did work if we explicitly specified the key-value pairs in the instruction. It looks reasonable, but it should be hard to use from the user side. So, should I relax the input validation by allowing the map type? |
Yes, we should allow anything which jsonschema-go converts to json object (only maps and structs come to my mind, but if we missed anything, we can expand validation until there's a proper solution for other json types).
Just to understand your perspective -- why would it be hard to use from the user side? This instruction does the whole thing: Maps are the only option is the keys/fields are not known in the instruction and LLM has to infer them. |
|
@dpasiukevich Thanks for your clarification.
No problem.
Yes, my point is user must know what field name and type can be used in the instruction, or the LLM may infer the wrong type for this field. |
|
@dpasiukevich Could have a look again. |
|
@dpasiukevich Could you please take a look at it to see if anything else needs to be addressed? |
kdroste-google
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
d1b82ae
dpasiukevich
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Co-authored-by: Dmitry Pasiukevich <[email protected]>
@dpasiukevich Done, sorry for didn't notice this format issue. |
kdroste-google
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM


This may partially resolve #330 by checking if the input is a struct type.