Issue & Seemingly Effective Workaround: Gemini Mistakes Function Calling for Code Execution via Live API Voice Input

Hi everyone,

I wanted to report an issue I’ve encountered with Gemini regarding Function Calling when using voice input via the Live API. It seems that Gemini sometimes incorrectly interprets Function Calling requests as Code Execution, even when Code Execution is supposedly turned off.

I discovered that this problem appears to happen specifically when an example of the function call is included directly in the prompt, like function_defined_by_function_call(). Gemini seems to mistake this format for a request to execute code.

However, I found a workaround. If you format the example differently, for instance, like print(default_api.function_defined_by_function_call), Gemini seems to correctly understand it as Function Calling and behaves as expected.

I thought this information might be useful to others facing similar issues, so I wanted to share my findings.

Separately, I also believe the inability to explicitly disable Code Execution functionality is a concern that should perhaps be addressed.

Thanks.

Below is an example where it’s mistakenly treated as Code Execution (Note: Code Execution setting is off)

Example of successful Function Calling after adding default_api. to the code example (no other changes made):