narrow-engineer-85614
10/05/2025, 6:47 PMtall-airline-16756
10/05/2025, 6:47 PMtall-airline-16756
10/05/2025, 6:48 PMnarrow-engineer-85614
10/05/2025, 6:51 PMtall-airline-16756
10/05/2025, 6:52 PMsession.history to look through the entire conversation history, which includes messages from all agents involved.
• Use Event Listeners: Listening for the conversation_item_added event lets you capture messages as they come in and tag them with agent details right away.
These approaches will help make sure it's always clear who said what in your chat history. If you'd like, I’m here to provide more details or examples to make implementation easier for you. Just let me know!
Sources: complex-agents/personal_shopper/personal_shopper.py | examples/voice_agents/realtime_load_chat_history.py | Session recording and transcripts | LiveKit Docs | Events and error handling | LiveKit Docsnarrow-engineer-85614
10/05/2025, 6:54 PMconversation_item_added?tall-airline-16756
10/05/2025, 6:55 PMconversation_item_added event:
• Set and Update Attributes: You can easily use set_attributes() on a LocalParticipant instance to set key-value pairs. For example:
await room.local_participant.set_attributes({"user_language": "es", "user_role": "agent"})
• Access Attributes in `conversation_item_added`: Whenever a new message comes in, you can access the participant’s attributes through item.participant.attributes. Here’s how:
@session.on("conversation_item_added")
async def on_conversation_item_added(item):
participant = item.participant
attrs = participant.attributes
logger.info("Current attributes: %s", attrs)
• Listen to Attribute Changes: You can also listen for the participant_attributes_changed event to stay updated on any changes in real time:
@room.on("participant_attributes_changed")
def on_participant_attributes_changed(changed_attributes, participant):
logger.info("Attributes changed for %s: %s", participant.identity, changed_attributes)
These attributes sync across all participants, making it super handy to customize responses or keep track of agent roles. If you have any questions or want me to walk you through more examples, just let me know—I’m here to help!
Sources: Participant attributes and metadata | LiveKit Docs | livekit-rtc/livekit/rtc/_proto/participant_pb2.pyi | Text and transcriptions | LiveKit Docs | basics/label_messages.py | SIP participant | LiveKit Docsnarrow-engineer-85614
10/05/2025, 6:59 PMtall-airline-16756
10/05/2025, 7:00 PMJobContext object provided to the agent's entrypoint function. Here's how:
• Direct Access: The room is accessible via ctx.room. However, some properties become available only after calling ctx.connect(). For example:
async def entrypoint(ctx: JobContext):
await ctx.connect()
room = ctx.room
print(f"Connected to room: {room.name}")
• Using UserData: You can pass the JobContext to a UserData class to keep access consistent across your agent's functions:
@dataclass
class MyUserData:
ctx: JobContext
# Access the room through UserData
room = userdata.ctx.room
• Participant Management: Once connected, you can interact with participants like this:
# Wait for a specific participant
participant = await ctx.wait_for_participant(identity="user123")
# Access existing participants
for remote_participant in ctx.room.remote_participants.values():
print(f"Participant: {remote_participant.identity}")
If you'd like, I'm here to help with more details or examples tailored to your specific needs—just let me know!
Sources: rpc/rpc_agent.py | Connecting to LiveKit | LiveKit Docs | livekit-agents/livekit/agents/voice/agent_session.pynarrow-engineer-85614
10/05/2025, 7:32 PMconversation_item_addedtall-airline-16756
10/05/2025, 7:33 PM