wooden-librarian-60399
12/12/2025, 3:21 AMtall-airline-16756
12/12/2025, 3:21 AMtall-airline-16756
12/12/2025, 3:21 AM@server.rtc_session()
async def my_agent(ctx: JobContext):
participant = await ctx.wait_for_participant()
session = AgentSession(...)
await session.start(room=ctx.room, agent=Assistant())
Downsides to watch for:
• Increased startup latency: the agent only initializes after the participant joins, so users may see a delay before the agent responds.
• Cold starts: if the agent has been scaled down, joining can trigger a cold start (extra seconds to spin up).
• Missed early audio: if the user speaks immediately on join, audio before session start may be lost.
• Potential indefinite wait: if no one joins, you should implement a timeout to avoid waiting forever.
• Less benefit from pre‑warmed resources: waiting saves resources but may forfeit quicker response times available on paid/warmed instances.
Recommendation: for best responsiveness, you can connect the agent (keep it warmed) but defer agent behavior (greeting/processing) until wait_for_participant() returns — this balances latency and resource use. Would you like an example with a timeout or a pattern that preloads models while still waiting?
Sources: Job lifecycle | LiveKit docs | Agents telephony integration | LiveKit docs | Quotas and limits | LiveKit docs | Deploy and scale agents on LiveKit Cloud | External data and RAG | LiveKit Docs