This question originally came up in our Slack community and the thread has been consolidated here for long-term reference.
Hi! Could you please clarify the order and necessity of using session.start and ctx.connect in the AI agent code?
I have seen example where the session.start goes first and ctx.connect second, reverse order and with the ctx.connect missing. I checked the guides and the docs but it’s still not clear for me; they are quite short: docs on JobContext.connect is quite short “Connect to the room. […]” (ref) and the docs on the AgentSession.start say “Start the voice agent. […]” (ref). I’m talking about the usage in the entrypoint function with @server.rtc_session() decorator.
Could you clarify what these methods do/refer to the relevant pages, so the order and the necessity of using them is more clear?