Skip to content

fix: warn when function calling mode is ANY with automatic function calling enabled - #2888

Open
adi-IL wants to merge 1 commit into
googleapis:mainfrom
adi-IL:fix/afc-warning-mode-any
Open

fix: warn when function calling mode is ANY with automatic function calling enabled#2888
adi-IL wants to merge 1 commit into
googleapis:mainfrom
adi-IL:fix/afc-warning-mode-any

Conversation

@adi-IL

@adi-IL adi-IL commented Aug 20, 2026

Copy link
Copy Markdown

Summary

Fixes #2839.

When tool_config.function_calling_config.mode is set to ANY, 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 until maximum_remote_calls is exhausted. This returns an empty response without warning the user.

Changes

  • Added a warning check in should_disable_afc in google/genai/_extra_utils.py when AFC is active and tool_config.function_calling_config.mode is ANY (or FunctionCallingConfigMode.ANY).
  • Added unit tests in google/genai/tests/afc/test_should_disable_afc.py testing warning behavior when mode="ANY", when mode="ANY" with AFC disabled (no warning), and when mode="AUTO" (no warning).

Testing

Ran pytest suite:

  • google/genai/tests/afc/test_should_disable_afc.py: 21 passed.
  • google/genai/tests/common/: 71 passed.

@Venkaiahbabuneelam Venkaiahbabuneelam self-assigned this Aug 20, 2026
@Venkaiahbabuneelam Venkaiahbabuneelam added the size:L Code changes between 40-100 lines label Aug 20, 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.

tool_config mode="ANY" with automatic function calling exhausts maximum_remote_calls and returns empty text, with no warning

2 participants