Skip to content

generate_reply times out on first dialogue with gemini-3.1-flash-live-preview — works fine with gemini-2.5-flash- #5260

@acharan-tech-200037

Description

@acharan-tech-200037

Bug Description

When using gemini-3.1-flash-live-preview as the realtime model, the agent fails to generate the first reply immediately after joining the room. It times out waiting for the generation_created event. The exact same code with gemini-2.5-flash works without any issues.

Expected Behavior

Agent should generate and speak the first reply immediately after joining the room, same as it does with gemini-2.5-flash

Reproduction Steps

1.Create an AgentSession with google.realtime.RealtimeModel using model gemini-3.1-flash-live-preview
2.Start the session with session.start()
3.Call session.generate_reply() for the opening dialogue

Minimal Reproducible Example

from livekit import agents
from livekit.plugins import google, silero
from livekit.agents import AgentSession

@server.rtc_session(agent_name="my-agent")
async def my_agent(ctx: agents.JobContext):
    session = AgentSession(
        llm=google.realtime.RealtimeModel(
            model="gemini-3.1-flash-live-preview",  # ❌ fails
            voice="Puck",
        ),
        vad=silero.VAD.load(),
    )

    await session.start(ctx.room, participant=ctx.room.remote_participants)
    await session.generate_reply(
        instructions="Greet the user."
    )

Operating System

Windows11

Models Used

gemini-3.1-flash-live-preview

Package Versions

livekit-agents==1.5.1

Logs

ERROR… livekit.…ns.google  error in receive task: 1007 None.
                             Request contains an invalid argument.

websockets.exceptions.ConnectionClosedError:
  received 1007 (invalid frame payload data) Request contains an invalid argument.;
  then sent 1007 (invalid frame payload data) Request contains an invalid argument.

google.genai.errors.APIError: 1007 None. Request contains an invalid argument.

ERROR… livekit.agents  failed to generate a reply:
                        generate_reply timed out waiting for
                        generation_created event.

WARNI… livekit.…ns.google  received server content but no active generation.

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