SDK: livekit-agents~=1.5.1 with livekit-plugins-go...
# ask-ai
c
SDK: livekit-agents~=1.5.1 with livekit-plugins-google Model: Gemini 3.1 Flash Live (speech-to-speech) Problem: When my agent hibernates due to inactivity (scale-to-zero), it never wakes up for new sessions. The agent logs show "The agent has shut down due to inactivity. It will automatically start again when a new session begins" - but it doesn't. What I've tried: 1. Token-based dispatch via RoomConfiguration({ agents: [{ agentName: "Discovery-Agent" }] }) in the participant JWT - agent doesn't join 2. Explicit server-side dispatch via AgentDispatchClient.createDispatch() before the client connects - dispatch is created successfully but agent doesn't join 3. CLI dispatch via lk dispatch create --room test-wake-room --agent-name Discovery-Agent - dispatch created (ID: AD_yr5sjDBfxUCu) but agent stays hibernated Evidence: - Room is created successfully (confirmed via lk room list, SID visible in dashboard) - Dispatch is created successfully (confirmed via lk dispatch list, dispatch ID returned) - Client connects and publishes audio track (1 participant visible in dashboard) - Agent process never starts - lk agent logs still shows "shut down due to inactivity" - Dispatch sits in the queue with no worker picking it up What does work: - Running lk agent deploy wakes the agent, and subsequent calls work perfectly while the agent is warm - All calls succeed when the agent is already running (tested multiple 5-10 minute discovery calls successfully) Agent registration: cli.run_app( WorkerOptions( entrypoint_fnc=entrypoint, prewarm_fnc=prewarm, agent_name=os.getenv("AGENT_NAME", "Discovery-Agent"), ) ) Question: Is createDispatch supposed to trigger auto-wake from scale-to-zero? If not, what's the correct way to ensure the agent wakes up when a new room needs it? Is there a way to set minimum replicas to 1 to prevent hibernation entirely?
t
Thanks for reaching out, Ahmed. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I’ve reviewed your logs and steps. You’re asking whether createDispatch should wake an agent from hibernation and how to keep an agent available (or set minimum replicas). Short answer • No — creating a dispatch does not wake an agent that has scaled to zero. Dispatches can be created, but no worker will pick them up if the agent runtime is hibernated. • There’s no way on the free/build tier to set minimum replicas to 1. Paid plans keep agents warm (prevent scale-to-zero), which is the supported way to ensure agents are always available. Why this is happening • When the agent process has scaled to zero there are no running workers to accept dispatches. The dispatch sits in the queue until a worker is running. • The message in the agent logs is misleading in the free-tier case: automatic start on new sessions only reliably happens when the runtime is kept warm (paid plans) or when a worker process is already running. What you can do now • If you need guaranteed wake/instant availability: upgrade to a paid plan so agents do not scale to zero. • For development on the free tier: ◦ Manually wake the agent before expected traffic with
lk agent deploy
. ◦ Monitor agent status with
lk agent status
and only start sessions once a worker is reported running. • There is no API/dispatch/token trick that will reliably wake a hibernated agent from scale-to-zero. If you want, I can: • Help verify your plan tier and confirm whether your project is on the free/build plan. • Walk through using
lk agent status
and a small warm-up script or CI job to keep an agent running during expected hours. Which would you prefer? Sources: Understand and Improve Agent Latency | LiveKit | Agent dispatch | LiveKit Documentation | Server lifecycle | LiveKit Documentation | Pricing | LiveKit | examples/drive-thru | livekit/livekit_composite | DeepWiki, with interactive elements