Generate_reply Times Out on First Dialogue with gemini-3.1-flash-live-preview

Summary

When using gemini-3.1-flash-live-preview, the agent fails to generate the first reply right after joining the room — timing out on generation_created. The exact same code works perfectly with gemini-2.0-flash-live-001 with no issues.

Environment

Component Details
Model (broken) gemini-3.1-flash-live-preview
Model (working) gemini-2.5-flash
SDK livekit-agents (Version : 1.5.1)
Plugin livekit-plugins-google

Code

python

@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",  # ❌ breaks here
            # model="gemini-2.5-flash",    # ✅ works fine
            voice="Puck",
        ),
        vad=silero.VAD.load(),
    )

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

Error Log

00:38:57.873 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.

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

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

00:39:03.967 WARNI… livekit.…ns.google  received server content but no active generation.
1 Like

Thanks for raising, I believe this should be addressed by fix(google realtime): support gemini-3.1-flash-live-preview by Hormold · Pull Request #5251 · livekit/agents · GitHub

Thanks for your reply , i worked on that , can you please review my pr that i raised to solve this issue , along with the support for update_chat_ctx and update_instructions also

fix(google): support gemini-3.1-flash-live-preview realtime API for g… by acharan-tech-200037 · Pull Request #5262 · livekit/agents · GitHub

1 Like