is there a way to check if an agent is currently d...
# ask-ai
f
is there a way to check if an agent is currently dispatch to a particular room via roomId? Also, is there any way to increase the departure_timeout after a room has created?
t
Thanks for reaching out, Mok. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I'd love to help you with this! Could you please clarify what you mean by "check if an agent is currently dispatch to a particular room via roomId"? Are you asking about verifying if a participant is present in a room, or is it something different? Your details will really help me assist you better. Sources: packages/livekit-server-sdk/src/RoomServiceClient.ts | lib/livekit/proto/livekit_room_pb.rb | livekit-api/src/services/room.rs | cmd/lk/room.go | livekit/livekit_room.pb.go
I understand that you’re looking to increase the
departure_timeout
setting for a room in LiveKit. Just a heads-up, this setting can’t be changed after the room is created—it needs to be set right when the room is first made. So, if you want a longer timeout, you’ll want to specify it during the initial
CreateRoom
request using the SDK or CLI you’re working with. If you’d like, I’m here to help! Just let me know which SDK or tool you’re using, and I can walk you through some examples to make the process easier. Sources: packages/livekit-server-sdk/src/RoomServiceClient.ts | lib/livekit/proto/livekit_room_pb.rb | livekit-api/src/services/room.rs | cmd/lk/room.go | livekit/livekit_room.pb.go
f
What I meant would be, if a participant has joined a room, and then left the room, but the room is not yet closed, would the agent still be in the room waiting during the departure timeout? or would it be something like sleep mode? Would this duration of departure timeout be added to the cost of active time agent is in a room? Also, if there is a way for me to see if the room is currently active even though there is no one inside the room yet, where it is currently in the status of departure_timeout, waiting to close the room?
t
I understand it can be a bit tricky, so let me walk you through this. During the
departure_timeout
period, participants who have left the room are no longer considered active. Their status changes to
DISCONNECTED
, which means they don't count towards the active participant metrics or any costs related to active time in the room. The good news is, the room stays open during this timeout, giving a chance for participants to reconnect or for new ones to join. Right now, there isn’t a direct way to check if a room is active specifically during the
departure_timeout
period. But here’s a helpful approach: you can keep an eye on how many participants are in the room and note the time since the last person left. By comparing that time with your set
departure_timeout
value, you can get a good idea if the room is still within that timeout window. If you’d like, I’m here to help you implement this logic or assist with a particular SDK or API you’re working with. Just let me know, and we can figure it out together! Sources: protobufs/livekit_models.proto | livekit-ffi/protocol/room.proto | livekit-rtc/livekit/rtc/room.py | pkg/rtc/room.go | livekit-protocol/livekit/protocol/room.pyi
f
When the room stays open during this timeout, what are the costs to it? Am i paying for the room or the agent that is staying in the room?
t
Thanks for reaching out with your question! From what the sources show, there aren’t any costs linked to a room during the
departure_timeout
period. Usually, in LiveKit, charges are based on active participants and media usage. Since participants are in a
DISCONNECTED
state during this timeout, they’re not counted as active, so there shouldn’t be any extra costs for the agent or participants during this time. If you’re worried about pricing or resource usage, I’d be happy to help! You might also find it useful to check out LiveKit’s pricing documentation, or feel free to share more details about your setup so I can assist you further. Sources: livekit-api/src/services/room.rs | protobufs/livekit_room.proto
f
but what about the agent? if the room is disconnected, is the agent still in the room? only will the agent only rejoin if the participant enters the room?
t
During the
departure_timeout
period, the agent stays in the room and is still considered active. The room will remain open until the timeout finishes or the room is explicitly deleted. If a participant happens to re-enter the room during this time, the agent won’t need to rejoin since it’s already there. If you'd like to make sure the agent doesn’t stay in the room, you can simply delete the room when the participant leaves. I hope this helps clarify things for you! Sources: livekit/livekit_models.pb.go | pkg/rtc/room.go
f
is there a way i can list the rooms where agent is active in? or at least how do i list all active rooms? will the room still be considered active during the departure_timeout period?
t
I'd be happy to help you with listing all active rooms, including those in the
departure_timeout
period. You can use the
ListRooms
API for this—it returns all rooms that are currently open. To check if a room is active during the
departure_timeout
period, here’s a simple way to do it: • First, use
ListRooms
to get the list of active rooms. • Then, look at the
num_participants
field in the room details. If it shows
0
but the room still appears in the list, that means it’s within the
departure_timeout
period. • Just so you know, the
departure_timeout
value (measured in seconds) is part of the room's configuration and tells you how long the room stays open after the last participant leaves. If you’d like, I’m here to help you implement this using a specific SDK or tool—just let me know, and I can share some examples to make it easier for you. Sources: protobufs/livekit_models.proto | packages/livekit-server-sdk/src/RoomServiceClient.ts | src/main/kotlin/io/livekit/server/RoomServiceClient.kt | autocomplete/fish_autocomplete
f
RoomService.list_rooms() missing 1 required positional argument: 'list' Why am i getting this error? Currently i am doing it like this
Copy code
async with LiveKitAPI() as lkapi:
                res = await lkapi.room.list_rooms()
i thought the positional argument is optional?
t
It looks like the error is happening because the
list_rooms()
method in the LiveKit Python SDK expects a
ListRoomsRequest
object as an argument, even if you just want to list all rooms without any filters. This argument is required, so it can’t be left out. No worries though! To fix this, you can simply pass an empty
ListRoomsRequest
object like this:
Copy code
from livekit import api
from livekit.protocol.room import ListRoomsRequest

# Initialize the SDK
lkapi = api.LiveKitAPI()

# List all rooms
rooms_response = await lkapi.room.list_rooms(ListRoomsRequest())
print(rooms_response.rooms)
If you’d like to filter by specific room names, you can include them inside the
ListRoomsRequest
object like this:
Copy code
rooms_response = await lkapi.room.list_rooms(ListRoomsRequest(names=["room1", "room2"]))
print(rooms_response.rooms)
Please feel free to reach out if you have any more questions or need a hand with anything else—I’m here to help! Sources: examples/api.py