Skip to content

Fix: Correctly remove 'additionalProperties' from function schemas for Gemini API#59

Open
patchen0518 wants to merge 2 commits intoHKUDS:mainfrom
patchen0518:main
Open

Fix: Correctly remove 'additionalProperties' from function schemas for Gemini API#59
patchen0518 wants to merge 2 commits intoHKUDS:mainfrom
patchen0518:main

Conversation

@patchen0518
Copy link

@patchen0518 patchen0518 commented Jun 24, 2025

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

  • 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 additionalProperties in 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant