happy-dawn-98083
09/23/2025, 5:32 PMtall-airline-16756
09/23/2025, 5:32 PMtall-airline-16756
09/23/2025, 5:33 PMadd_participant_entrypoint function in LiveKit's Agents framework! This function lets you register an asynchronous function that runs whenever a new participant joins a room. It’s designed to also trigger for participants who are already in the room when your agent connects, so you can be sure all participants are handled smoothly and consistently.
Here are some key features to keep in mind:
• It accepts a coroutine with parameters for JobContext and rtc.RemoteParticipant, which means you can perform actions tailored to each participant.
• You can filter participants by type (like standard or SIP) using the kind parameter, giving you more control.
• To avoid confusion, it prevents duplicate entrypoints by raising an error if you try to add the same function more than once.
• Each participant gets its own task that’s automatically cleaned up once done, making resource management easier.
• Just a heads-up: make sure to register this before calling ctx.connect() so you don’t miss any join events.
Here’s a quick example to illustrate how it works:
async def participant_task(ctx: JobContext, p: rtc.RemoteParticipant):
<http://logger.info|logger.info>(f"Participant joined: {p.identity}")
async def entrypoint(ctx: JobContext):
ctx.add_participant_entrypoint(entrypoint_fnc=participant_task, kind=rtc.ParticipantKind.PARTICIPANT_KIND_STANDARD)
await ctx.connect(auto_subscribe=AutoSubscribe.SUBSCRIBE_ALL)
If you’re diving into more advanced scenarios, you can filter participants, manage stateful interactions, or even use room event listeners for even finer control. Please don’t hesitate to ask if you’d like me to explain any part in more detail or help you set things up!
Sources: complex-agents/ivr-agent/agent.py | examples/primitives/participant_entrypoint.py | Job lifecycle | LiveKit Docs | agents/src/job.ts | Building an Automated IVR Menu Caller | LiveKit Docshappy-dawn-98083
09/23/2025, 5:41 PMtall-airline-16756
09/23/2025, 5:42 PMparticipant_task defined in add_participant_entrypoint. This task gives you access to the JobContext and RemoteParticipant, which are just what you need to initialize and start an avatar session smoothly.
Here’s a friendly example for you:
async def participant_task(ctx: JobContext, participant: rtc.RemoteParticipant):
session = AgentSession(
# Configure STT, LLM, TTS, etc.
)
avatar = hedra.AvatarSession(
avatar_id="...", # Specify avatar ID
)
await avatar.start(session, room=ctx.room)
await session.start(
room=ctx.room,
# Additional options
)
# Register the entrypoint
ctx.add_participant_entrypoint(entrypoint_fnc=participant_task)
This method works well because the avatar session setup relies on the JobContext and room, both of which you can easily access within the task. If you have any questions or want me to walk you through any part of this, just let me know—I’m here to help!
Sources: livekit-plugins/livekit-plugins-simli/livekit/plugins/simli/avatar.py | Virtual avatar integrations | LiveKit Docshappy-dawn-98083
09/24/2025, 4:48 AMBVCTelephony instead for best results
noise_cancellation=noise_cancellation.BVC(),
),
)
await session.generate_reply(
instructions="Greet the user and offer your assistance."
)
# Do something with p.attributes, p.identity, p.metadata, etc.
# my_stuff = await fetch_stuff_from_my_db(p)
# Do something
# await asyncio.sleep(60)
print(f"participant task done for {p.identity}")
ctx.add_participant_entrypoint(entrypoint_fnc=participant_task_1)
print("\n--------------GREETED --------------------\n")
if name == "__main__":
agents.cli.run_app(agents.WorkerOptions(entrypoint_fnc=entrypoint))
will this code work?tall-airline-16756
09/24/2025, 4:49 AMadd_participant_entrypoint function is meant to register asynchronous tasks for participants, and creating an AgentSession within the participant task is totally supported.
Here are a few important things to keep in mind:
• Make sure to call ctx.add_participant_entrypoint before ctx.connect().
• The AgentSession.start() method needs a valid room reference and agent instance, both of which you have in your code.
• The framework is designed to handle dynamic session creation for each participant, just like in the official examples.
If you run into any specific challenges or have questions while running your code, please don’t hesitate to reach out—I’m here to help!
Sources: evaluating-agents/agent_to_test.py | Job lifecycle | LiveKit Docs | examples/voice_agents/realtime_joke_teller.py