Fix: Prevent integer to float conversion for tool parameters invoked via agent skills#2845
Conversation
Summary of ChangesHello, 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 addresses a critical bug in the agent skill invocation process where integer parameters were inadvertently converted to floats during JSON unmarshalling. This type mismatch caused tools requiring integer inputs to fail when called through agent skills. The fix involves updating the JSON decoding mechanism to correctly preserve integer types, ensuring robust tool execution. 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. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request refactors the JSON parameter decoding in the runInvoke function. It replaces the direct use of json.Unmarshal with a new util.DecodeJSON function, which processes the input from a strings.NewReader. This change likely aims to improve JSON parsing, potentially offering better error handling or more flexible input processing. No specific feedback was provided in the review comments.
|
Code changes committed and merged as part of this PR : #2847 |
Description
This PR addresses a bug where tools fail to execute due to a type mismatch error when integer parameters are provided. Crucially, this issue only occurs when the tool is invoked through agent skills; it does not happen when the tools are executed directly. When an agent skill routes a payload via the Gemini CLI, JSON integers are incorrectly unmarshalled as floats before being passed down to the underlying tool.
Steps to Reproduce:
Activate an agent skill (e.g., cloud-sql-postgres-data from the cloud-sql-postgresql extensions) via the Gemini CLI.
Invoke a tool that requires an integer parameter (like list_indexes) using a natural language prompt, such as:
"List all the indexes in the database, max limit of rows is 2"
The Gemini CLI agent internally constructs and executes the following command:
node /usr/local/google/home/pavanrampalli/.gemini/extensions/cloud-sql-postgresql/skills/cloud-sql-postgres-data/scripts/list_indexes.js '{"limit": 2}'The execution fails because the tool expects an integer for the limit parameter, but the agent's request parser has converted and passed it as a float.
Root Cause:
Upon investigation of the agent skill invocation path, the standard json.Unmarshal function defaults to parsing all JSON numbers as float64. When this parsed request is handed off to a tool that strictly enforces an integer type, it triggers a validation error.
Proposed Solution:
Replaced the standard json.Unmarshal with util.DecodeJSON specifically within the request unmarshalling logic for agent skills. This ensures that numeric types are decoded accurately and integers are preserved without being implicitly converted to floats before reaching the tools.
PR Checklist
CONTRIBUTING.md
bug/issue
before writing your code! That way we can discuss the change, evaluate
designs, and agree on the general idea
!if this involve a breaking change🛠️ Fixes #<issue_number_goes_here>