Two agents joining the same outbound telephony room

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

I’m running into an issue with my outbound-only telephony agent where two agents end up connecting to the room.

I have two agents in LiveKit Cloud - one is explicit dispatch (for telephony), one is automatic dispatch. When I create a room and dispatch the explicit agent, both agents end up joining.

I have an outbound trunk only and no dispatch rules.

The issue is that your automatic dispatch agent is joining the SIP room along with your explicit dispatch agent.

To fix this, use request_fnc in your automatic dispatch agent to reject SIP-related rooms:

async def request_fnc(ctx: JobRequest) -> None:
    # Reject telephony outbound rooms
    if ctx.room.name.startswith("sip-room-"):
        logger.info(f"Rejecting telephony room: {ctx.room.name}")
        await ctx.reject()
        return
    
    # Accept all other rooms
    await ctx.accept()

if __name__ == "__main__":
    cli.run_app(WorkerOptions(
        entrypoint_fnc=entrypoint,
        request_fnc=request_fnc,
    ))

This allows your automatic dispatch agent to skip rooms with a specific prefix (like sip-room-) that you use for telephony.