lively-horse-90722
12/16/2025, 9:14 AMawait self._agent_session.say()
throws RuntimeError("AgentSession isn't running").
How to put a checktall-airline-16756
12/16/2025, 9:14 AMtall-airline-16756
12/16/2025, 9:15 AMawait self._agent_session.say(). To avoid that, you can either ensure the session is started before calling say() or handle the error when it occurs. Two safe patterns:
1) Await start and track state
self._session_started = False
await self._agent_session.start()
self._session_started = True
# before saying
if self._session_started:
await self._agent_session.say("Hello")
else:
# handle not-started case
2) Catch the RuntimeError
try:
await self._agent_session.say("Hello")
except RuntimeError as e:
if str(e) == "AgentSession isn't running":
# handle gracefully (log, retry, start session, etc.)
else:
raise
Which approach fits your code flow better — do you prefer ensuring start completes before calls or handling transient missing-starts with retries?
Sources: Turn detection and interruptions | LiveKit Docs | Agent session | LiveKit docs