Gemini live API error -Error in receive loop: 1007 None. Unexpected function call

260210 01:14:47[0.8.3_gemini_live][GeminiLive]-ERROR-Error in receive loop: 1007 None. Unexpected function call: Please make sure you declare the function call definitions in the setup message, in addition to t
260210 01:14:47[0.8.3_gemini_live][GeminiLive]-ERROR-Traceback: Traceback (most recent call last):
File “/opt/ai-box.vn/env/lib/python3.10/site-packages/google/genai/live.py”, line 535, in _receive
raw_response = await self._ws.recv(decode=False)
File “/opt/ai-box.vn/env/lib/python3.10/site-packages/websockets/asyncio/connection.py”, line 322, in recv
raise self.protocol.close_exc from self.recv_exc
websockets.exceptions.ConnectionClosedError: received 1007 (invalid frame payload data) Unexpected function call: Please make sure you declare the function call definitions in the setup message, in addition to t; then sent 1007 (invalid frame payload data) Unexpected function call: Please make sure you declare the function call definitions in the setup message, in addition to t

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/opt/ai-box.vn/xiaozhi_server_new/core/providers/gemini_live/session_manager.py”, line 350, in receive_loop
async for response in self.provider.session.receive():
File “/opt/ai-box.vn/env/lib/python3.10/site-packages/google/genai/live.py”, line 454, in receive
while result := await self._receive():
File “/opt/ai-box.vn/env/lib/python3.10/site-packages/google/genai/live.py”, line 545, in _receive
errors.APIError.raise_error(code, reason, None)
File “/opt/ai-box.vn/env/lib/python3.10/site-packages/google/genai/errors.py”, line 163, in raise_error
raise cls(status_code, response_json, response)
google.genai.errors.APIError: 1007 None. Unexpected function call: Please make sure you declare the function call definitions in the setup message, in addition to t

2 Likes

Hi @The_Anh_Cao

Could you provide me with what was the prompt used, the Model used , System instructions . This would help me debug/reproduce the issue

Having a similar issue here. We have the grounding tool enabled in the config and noticed that this specific 1007 error was occurring every time after Gemini hallucinates and sends a ghost “search_google” tool call to the client.

1 Like

Have you found a fix gemini is hallucinating a function call called search_google which isnt declared. We added grounding which works but sometimes it calls the fake function and throws a 1007

1 Like

HI @Kris_Leungwattanakij @Andrew_Nguyen

Would you be able to share which model you were using and what was the prompt you used ,also if possible a code snipptet - this would help me better debug the issue

My team is using models/gemini-live-2.5-flash-native-audio with Gemini Live API via Vertex AI.

Injection code

// Inject native Google Search grounding tool

const hasGoogleSearch = setupPayload.tools.some(toolBlock => toolBlock && toolBlock.googleSearch !== undefined);

if (!hasGoogleSearch) {

  setupPayload.tools.push({ googleSearch: {} });

  logger.info('Injected Google Search grounding tool into setup');

}

Prompt

  <!-- ───────────── SECTION 4: GROUNDING SEARCH ───────────── -->

  <groundingSearchGuidelines>

    <howGroundingSearchWorks>

      You have BUILT-IN Google Search grounding that works AUTOMATICALLY as part of your response generation.

      You do NOT need to call any function to search. There is NO function called "search_google" — that name is deprecated and does nothing.

      Simply decide to search and the grounding system handles it natively. If you find yourself about to call a function to search, STOP — you already have grounding built in.

    </howGroundingSearchWorks>




    <whenToUseGroundingSearch>

      Use grounding search PROACTIVELY and OFTEN.

      Do NOT wait for the user to ask. Search when:

      

      <trigger>User mentions ANY term, name, or concept you're not 100% certain about - look it up FIRST before responding</trigger>

      <trigger>User mentions a technique, term, or concept they might not fully understand</trigger>

      <trigger>User describes something but doesn't know the name for it</trigger>

      <trigger>User shares an interest or hobby - search for recent news, events, or cool facts</trigger>

      <trigger>You want to share a fun fact about something they mentioned</trigger>

      <trigger>You want to add nuance, context, or depth to what the user said</trigger>

      <trigger>Early in conversation - use search to gather context you can share throughout</trigger>

      

      <criticalRule>

        NEVER PRETEND TO UNDERSTAND something you don't fully know.

        If the user mentions a specific character, player, game mechanic, technique, event, or ANY domain-specific term:

        • ALWAYS look it up to learn about it BEFORE responding

        • Do NOT fake familiarity or give vague/generic responses

        • Do NOT say things like "Oh yeah, that's cool!" without actually knowing what it is

        • Look it up FIRST, then respond with genuine, informed engagement

        

        BAD: User says "I love Pikachu" → "Oh Pikachu is great!" (vague, no real knowledge shown)

        GOOD: User says "I love Pikachu" → [look up Pikachu Pokemon] → "Pikachu's so iconic! Did you know it wasn't originally going to be the mascot? Clefairy almost got that spot. What do you like most about Pikachu?"

      </criticalRule>

      

      <example>

        User: "I've been practicing this thing where I throw the [item] right when the circle is smallest"

        → Look up "[game] excellent throw technique timing"

        → Then explain: "Oh, you're talking about [technique name]! That's when you hit inside the smallest circle. Did you know the catch rate bonus stacks with curveballs? If you combine both, you get like a 2x multiplier."

      </example>

      

      <example>

        User: "I like [hobby]"

        → Look up "[hobby] news [current month/year]" or trends from credible sources

        → Use this to fuel the conversation with interesting, timely content

      </example>

    </whenToUseGroundingSearch>

    

    <teacherMindset>

      Think like a teacher/guide, not just a responder:

      • When the user mentions something, ask yourself: "What might they NOT know about this that would be interesting?"

      • Search to fill knowledge gaps they don't even know they have

      • Provide the "why" and "how" behind things, not just acknowledgment

      • Surface related context that makes the topic richer

    </teacherMindset>

    

    <sourceSelection>

      PRIORITIZE sources in this order:

      1. Official team/league/organization websites

      2. Major news outlets (ESPN, BBC, NYT, etc.)

      3. Verified social media accounts

      4. Well-known specialty publications for the topic

      AVOID: Fan blogs, forums, outdated articles, unverified sources

    </sourceSelection>

    

    <recencyRules>

      • ALWAYS check the date of the information

      • Prefer results from the last 7 days when discussing "recent" or "latest" events

      • If multiple results exist, choose the MOST RECENT from a trustworthy source

      • Do NOT reference events that happened months or years ago as if they are current

      • If the search results seem outdated, acknowledge that or skip mentioning it

    </recencyRules>

    

    <verification>

      • Cross-check facts if possible - don't trust a single obscure source

      • If unsure about the accuracy or recency, don't mention it

      • Better to share nothing than to share outdated or incorrect information

    </verification>

  </groundingSearchGuidelines>

Notes:
This was working perfectly for us when we were using the September and December preview models on the raw live API but we’re suddenly running into this issue after we swapped to Vertex AI.

EDIT:
We have not declared “search_google” as a tool anywhere. Gemini seems to intermittently choose to call this ghost tool as opposed to the native grounding search tool which we do explicitly inject.

1 Like

I have a similar setup as above. Worked on raw live API but now failing after a swap to vertex AI.

1 Like

@Mustan_lokhand Just wanted to follow up on this since it’s been around a week and see if there are any updates regarding this issue you could share with us.