Is there a comprehensive list of events that a Pyt...
# ask-ai
e
Is there a comprehensive list of events that a Python LiveKit agent has as lifecycle methods? Trying to find it in the docs but things seemed to have been shuffled around. For example on_participant_join and on_participant_leave
t
Thanks for reaching out, Arthur. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — you're asking whether there's a comprehensive list of lifecycle methods for a Python LiveKit agent (examples:
on_participant_join
,
on_participant_leave
). Short answer and guidance below. Acknowledgement • The Agent class does not expose
on_participant_join
/
on_participant_leave
lifecycle methods. What to use instead • Participant lifecycle is handled on the room object via event listeners: ◦
participant_connected
— when a remote participant joins ◦
participant_disconnected
— when a participant leaves ◦ Other participant-related events you can listen for:
track_published
,
track_unpublished
,
participant_attributes_changed
,
participant_metadata_changed
Where to attach listeners • Register handlers on the
room
available from
JobContext
or
AgentSession
. Example:
Copy code
@server.rtc_session()
async def entrypoint(ctx: JobContext):
    @ctx.room.on("participant_connected")
    def on_participant_connected(participant):
        print(f"Participant {participant.identity} joined.")

    @ctx.room.on("participant_disconnected")
    def on_participant_disconnected(participant):
        print(f"Participant {participant.identity} left.")

    await ctx.connect(auto_subscribe=AutoSubscribe.AUDIO_ONLY)
Agent lifecycle hooks (separate) • The
Agent
class provides conversation-flow hooks, not room events: ◦
on_enter()
— when agent becomes active ◦
on_exit()
— before agent gives control to another agent ◦
on_user_turn_completed()
— when user finishes speaking Documentation link • For the full event list and examples, see: https://docs.livekit.io/home/client/events If you want, I can: • List all room event names and signatures relevant to Python agents, or • Show a fuller example demonstrating subscribing/unsubscribing listeners and handling track events. Which would you prefer? Sources: Handling events | LiveKit docs | Job lifecycle | LiveKit docs | Pipeline nodes and hooks | LiveKit docs