fix: skip automatic function calling code path and warning when tools are absent - #2934
Open
adi-IL wants to merge 1 commit into
Open
fix: skip automatic function calling code path and warning when tools are absent#2934adi-IL wants to merge 1 commit into
adi-IL wants to merge 1 commit into
Conversation
… are absent Direct calls to Models.generate_content, generate_content_stream, and their async equivalents entered the automatic function calling loop and logged the AFC recommendation warning even when config was None or contained no callable tools. Check whether function_map is populated before entering the AFC routine in generate_content and generate_content_stream. If no callables or MCP adapters are present, bypass AFC and invoke _generate_content directly. Fixes googleapis#2902
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.
Fixes #2902
Description
Direct calls to
Models.generate_content,Models.generate_content_stream, and their async equivalents entered the automatic function calling loop and logged the AFC recommendation warning even whenconfigwas None or contained no callable tools.Checking whether
function_mapis populated before entering the AFC routine ingenerate_contentandgenerate_content_streamensures that when no callables or MCP adapters are present, AFC is bypassed and_generate_contentis invoked directly.Verification
configis None,config={'tools': None}, orconfig={'tools': []}.test_generate_content_skips_afc_when_no_toolsingoogle/genai/tests/afc/test_generate_content_stream_afc.py.pytest google/genai/tests/afc/test_generate_content_stream_afc.py(12 passed).