Fix: Correctly remove 'additionalProperties' from function schemas for Gemini API
Description
This pull request addresses an issue where the AutoAgent fails when using the Google Gemini API due to its strict handling of function declaration schemas. The Gemini API does not recognize the additionalProperties field, and the existing logic to remove this field was not functioning as intended.
This issue appears to be the same as or very similar to the one described in #51.
This patch updates the schema cleaning utility in utility.py to correctly and recursively remove the additionalProperties field from all levels of the tool function schemas before they are sent to the Gemini API.
Type of Change
- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] This change requires a documentation update
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce.
- Test A: Ran the AutoAgent with a Google Gemini model.
-
Test B: Ensured that a tool with
additionalPropertiesin its function definition now works correctly without raising an API error.
Test Configuration:
- LLM: Google Gemini Pro
- OS: Sequoia 15.5
- Python Version: 3.12.11