ripe-autumn-23624
08/09/2025, 6:58 AMtall-airline-16756
08/09/2025, 6:58 AMtall-airline-16756
08/09/2025, 6:59 AMJOINING
, JOINED
, and ACTIVE
.
3. Agent Creation and Joining: Agents can be sent into the room either automatically or on purpose. When they arrive, they join the room and start interacting with the participants.
About your second question—it’s definitely possible to spot when someone joins a call and use their info to give context to an agent’s system prompt before the agent is created. Here’s how you can do it:
1. Use ctx.wait_for_participant()
to catch when a participant joins the room.
2. Grab the participant’s details, like their identity or any custom attributes they have.
3. Feed that info into the agent’s system prompt to set up the agent with all the right context.
This way, your agent starts off with exactly the info it needs, based on who’s in the room. Pretty handy, right?
Sources: Room & Participant Management | livekit/livekit_composite | DeepWiki | Anatomy of an Agent | LiveKit Docsripe-autumn-23624
08/09/2025, 7:01 AMtall-airline-16756
08/09/2025, 7:01 AMctx.wait_for_participant()
to notice when someone joins and then pass their details to an agent’s system prompt:
async def entrypoint(ctx: JobContext):
# Connect to the room
await ctx.connect(auto_subscribe=AutoSubscribe.AUDIO_ONLY)
# Wait for the first participant to join
participant = await ctx.wait_for_participant()
<http://logger.info|logger.info>(f"Participant joined: {participant.identity}")
# Create a system prompt with participant information
system_prompt = f"""
You are an assistant for {participant.identity}.
Your purpose is to provide personalized support based on their attributes: {participant.attributes}.
"""
# Initialize agent with the customized system prompt
agent = MyAgent(
instructions=system_prompt,
tools=[...], # Your tools here
)
# Start the agent session
session = AgentSession(
llm=..., # Your LLM configuration
agent=agent,
)
await session.start(
room=ctx.room,
room_input_options=RoomInputOptions(...),
)
Here’s what’s happening step-by-step:
1. Wait for Participant: The function patiently waits for someone to join using ctx.wait_for_participant()
.
2. Access Participant Information: Once they join, it grabs their identity and any attributes they have.
3. Customize System Prompt: It then uses that info to craft a personalized system prompt just for them.
4. Initialize and Start Agent: Finally, the agent is set up with that custom prompt and kicked off in the room.
This way, the agent tailors its responses based on who’s there, making the experience feel just right for each participant.