livekit / agents

Build real-time multimodal AI applications 🤖🎙️📹
https://docs.livekit.io/agents
Apache License 2.0
1.07k stars 212 forks source link

How to Assign Specific Rooms to Different Agents in LiveKit #767

Closed martinnedenn closed 2 hours ago

martinnedenn commented 2 days ago

Hello,

I'm using LiveKit Agents to enable real-time conversation experiences. I’ve successfully deployed a worker for Agent A with its specific settings, and it connects to the room I created in LiveKit Cloud without any issues.

Now, I want to deploy a different worker for Agent B, which has different settings (such as voice and language model). However, when I deploy the worker for Agent B, it also joins the same room as Agent A, instead of being limited to a specific room.

Issue: I need to configure each worker or agent to join only the rooms I specify, rather than automatically connecting to all available rooms. ?

anupriya17 commented 1 day ago

We've had a similar use case. We are using room metadata to identify and control which agents can join specific rooms. Each worker checks the room's metadata and then accepts or rejects joining the room based on this information.

Our use case is different This way work for you. Checkout Namepsace, i've no idea how to use them.

This way, you can specify different rooms for Agent A and Agent B without them automatically connecting to all available rooms.

martinnedenn commented 1 day ago

Hello,

Thank you for sharing your approach. How can we implement a system to selectively accept or reject agents joining specific rooms?

anupriya17 commented 1 day ago

Checkout this for creating room with MetaData: https://github.com/livekit/agents/issues/774

Room Metadata: You can use the room metadata to determine whether a worker should join or reject a job. This can be particularly useful when certain conditions (like model, permissions, or other criteria) are required for the worker to proceed.

Custom Request Function (req_func): You can pass a custom req_func to the worker and use this along with room metadata to make the decision on whether the worker should join the room or not. This gives more flexibility in controlling the worker's behavior based on specific room metadata.

https://github.com/livekit/agents/blob/main/livekit-agents/livekit/agents/worker.py#L134

https://github.com/livekit/agents/blob/main/livekit-agents/livekit/agents/job.py#L275

martinnedenn commented 2 hours ago

Thank you for help 👌