Skip to content

fix: skip automatic function calling code path and warning when tools are absent - #2934

Open
adi-IL wants to merge 1 commit into
googleapis:mainfrom
adi-IL:fix/afc-skip-when-no-callables
Open

fix: skip automatic function calling code path and warning when tools are absent#2934
adi-IL wants to merge 1 commit into
googleapis:mainfrom
adi-IL:fix/afc-skip-when-no-callables

Conversation

@adi-IL

@adi-IL adi-IL commented Sep 2, 2026

Copy link
Copy Markdown

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 when config was None or contained no callable tools.

Checking whether function_map is populated before entering the AFC routine in generate_content and generate_content_stream ensures that when no callables or MCP adapters are present, AFC is bypassed and _generate_content is invoked directly.

Verification

… 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
@Venkaiahbabuneelam Venkaiahbabuneelam self-assigned this Sep 3, 2026
@Venkaiahbabuneelam Venkaiahbabuneelam added the size:L Code changes between 40-100 lines label Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L Code changes between 40-100 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

generate_content and generate_content_stream show afc warning for empty config or config with empty tools

2 participants