Title: Gemini 2.5 Pro file_search and function_declarations

I encountered unexpected behavior with the generateContent endpoint in Gemini 2.5 Pro.

I sent a request including: file_search tool and a list of function_declarations

Instead of performing file_search, the model returned:

“functionCall”: { “name”: “query”, … }

Note that “query” is not in my list of function_declarations.

Interestingly, when I send the same request without function_declarations, the model executes file_search correctly.

My questions:

  1. Why does the model return a function_call (query) that I did not define in my request - function_declarations, instead of using the file_search tool?

  2. Currently, Code Execution is not supported together with function_declarations in a single request. Will this be supported in the future?

Hi @user3399
This could be a form of tool hallucination. As a workaround, you can use Prompt Engineering to guide the model’s routing, like adding a system instruction or modifying your prompt to clearly define how the model should operate. Alternatively, if your workflow supports it, you can separate the turns first, retrieve the necessary context using only a file_search request, and then send a second request that incorporates both the retrieved context and your function_declarations.

Could you also please try using the gemini-3-pro-preview model to see if this issue still persists in your code?