Running multiple named agents with explicit dispatching in a single container

This question originally came up in our Slack community and the thread has been consolidated here for long-term reference.

Am I right in understanding that with Explicit Dispatching, each Agent must run in its own AgentServer process?

I have 2 agents with distinct entrypoints, and I tried to run them together under a single AgentServer. It seems I would have to introduce agent routing based on room metadata to support having a single entrypoint handle the routing, since explicit dispatching doesn’t work with automatic dispatching.

Yes, that’s correct. Explicit dispatching works on the agent name, and each agent type must run its own agent process. The agent registers itself with LiveKit using the agent name, which is then used by the dispatch API.

If you want to run multiple agents in a single container, each one needs its own entrypoint. A working approach is to create an image that uses supervisor to spawn the separate agent processes.

However, the idiomatic approach is to run each agent worker in its own container. Each agent worker then spawns a separate process for every “agent” that gets dispatched.

If your infrastructure isn’t ready for multiple containers yet, the supervisor approach will work as a stopgap solution. Just be aware you may need to allocate more container resources since you’re running multiple agent processes.