fix: warn when function calling mode is ANY with automatic function calling enabled - #2888
Open
adi-IL wants to merge 1 commit into
Open
fix: warn when function calling mode is ANY with automatic function calling enabled#2888adi-IL wants to merge 1 commit into
adi-IL wants to merge 1 commit into
Conversation
…alling enabled Fixes googleapis#2839
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2839.
When
tool_config.function_calling_config.modeis set toANY, the model is forced to emit a function call on every turn and cannot generate a final natural language answer. When combined with automatic function calling (AFC), AFC iteratively executes the tool and sends the response back to the model, which must emit another function call untilmaximum_remote_callsis exhausted. This returns an empty response without warning the user.Changes
should_disable_afcingoogle/genai/_extra_utils.pywhen AFC is active andtool_config.function_calling_config.modeisANY(orFunctionCallingConfigMode.ANY).google/genai/tests/afc/test_should_disable_afc.pytesting warning behavior whenmode="ANY", whenmode="ANY"with AFC disabled (no warning), and whenmode="AUTO"(no warning).Testing
Ran pytest suite:
google/genai/tests/afc/test_should_disable_afc.py: 21 passed.google/genai/tests/common/: 71 passed.