echoing-lamp-18687
12/05/2025, 6:14 AMCreating room: ${roomName});
await roomServiceClient.createRoom({ name: roomName, emptyTimeout: 60 });
// Create agent dispatch
console.log(Creating dispatch for agent "${agentName}" in room ${roomName});
const dispatch = await agentDispatchClient.createDispatch(
roomName,
agentName,
{
metadata: metadata || phoneNumber,
},
);
console.log(Created dispatch: ${dispatch.id});
// Create SIP participant to initiate the call
console.log(Dialing ${phoneNumber} to room ${roomName});
try {
const sipParticipant = await sipClient.createSipParticipant(
sipOutboundTrunkId,
phoneNumber,
roomName,
{
participantIdentity,
participantAttributes: {
...(agentId && { agent: agentId }),
}
},
);
console.log(Created SIP participant: ${sipParticipant.participantId});
return {
roomName,
dispatchId: dispatch.id,
participantId: sipParticipant.participantId,
sipParticipant
};
} catch (e) {
console.error(Error creating SIP participant: ${e instanceof Error ? e.message : e});
throw e;
}
}tall-airline-16756
12/05/2025, 6:14 AMtall-airline-16756
12/05/2025, 6:15 AMoutbound-call_<timestamp>_<rand>.
• Verify agent worker registration so you don’t have multiple workers (processes) registering the same agent name.
• Prevent auto-speaking on agent join: ensure your agent logic waits for caller audio / user-started-speaking before generating replies.
• Optionally, restrict the agent to process only the SIP caller by targeting a specific participant (RoomIO/participant filtering).
If you want, run these debugging steps and share the outputs
• Room participant list (room name) — show participant identities and roles.
• Agent logs around the time of the call (look for multiple job/context starts or multiple generate_reply calls).
• Whether any SIP dispatch rules match your room prefix (list active rules).
Tell me which of the above you can check and share the room participant list or agent logs; I’ll help interpret them and give exact changes to your code/config to stop the duplicate agent audio.
Sources: How to set a fixed participant for agent audio processing | SIP dispatch rule | LiveKit docs | Agents Framework | livekit/livekit_composite | DeepWiki | Agent dispatch | LiveKit docs | Agents telephony integration | LiveKit docsechoing-lamp-18687
12/05/2025, 6:17 AMtall-airline-16756
12/05/2025, 6:17 AMoutbound-call_<timestamp>_<rand>) so dispatch rules for inbound flows don’t accidentally match.
If you’d like, tell me which approach you prefer (SIP dispatch rule vs. agent joining directly) and I’ll give exact code or config steps.echoing-lamp-18687
12/05/2025, 6:19 AMtall-airline-16756
12/05/2025, 6:19 AMcreateSipParticipant(...), the SIP trunk dials the number; when answered, the SIP participant joins the room and audio/video tracks for that caller appear as a participant.
How they interact in your flow
• If you create a dispatch AND create a SIP participant for the same room, the SIP caller and the dispatched agent both join the room so they can communicate.
• If an additional agent (another dispatch, a SIP dispatch rule, or another registered worker) also joins the same room, you’ll see multiple agent voices — which explains the duplicate speaking you observed.
If you want, I can show:
• Code to skip manual dispatch and have an agent join directly, or
• How to use a SIP dispatch rule instead of manual dispatch. Which would you prefer?