Skip to content

Gemini 2.5 Flash returns empty streaming responses intermittently , error generating content no response generated #4706

@ZafeerKhan

Description

@ZafeerKhan

Bug Description

Gemini 2.5 Flash intermittently returns complete streaming responses where every chunk has either no candidates or empty candidate.content.parts. The stream completes without producing any content, and finish_reason stays None. This causes google/llm.py:493 to raise APIStatusError("no response generated").

The issue is intermittent — it occurs on roughly 50% of first-turn requests in our testing, but can also occur mid-session.

Expected Behavior

Gemini 2.5 Flash should return at least one chunk with non-empty content

Reproduction Steps

1. Create an AgentSession with google.LLM(model="gemini-2.5-flash") as primary LLM in a FallbackAdapter
2. Start a voice agent session (or console test with python main.py dev --mode console)
3. Send the first user message (triggers ~10,500 token context: system prompt + greeting + user turn)
4. Observe that the streaming response contains zero usable chunks — all chunks hit continue at google/llm.py:449 (not response.candidates) or google/llm.py:459 (not candidate.content or not candidate.content.parts)

  livekit.agents._exceptions.APIConnectionError: gemini llm: error generating content 
    no response generated
...
- Sample code snippet, or a GitHub Gist link -

Operating System

macOS

Models Used

Primary LLM: gemini-2.5-flash (via livekit-plugins-google). Fallback LLM: gpt-4.1-mini (via livekit-plugins-openai)

Package Versions

livekit-agents==1.3.12
livekit-plugins-google==1.3.12
google-genai==1.55.0

Session/Room/Call IDs

No response

Proposed Solution

Additional Context

No response

Screenshots and Recordings

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions