bitter-analyst-30633
03/18/2026, 8:39 AMtall-airline-16756
03/18/2026, 8:39 AMtall-airline-16756
03/18/2026, 8:39 AMuser_12345_20250318T150405Z or user_12345_ab12cd34. This guarantees separate Room IDs and avoids ambiguity.
• If you must reuse names: add a delay before recreating the same name. Wait at least 1–2 minutes after deleting or after all participants leave so the sweeper finishes cleanup.
• Review SIP outbound logic: ensure the agent dispatch / CreateSIPParticipant code creates a new unique room per outbound call (rather than reusing a static name) or explicitly calls DeleteRoom and waits before recreating.
If you want, I can help with next steps
• If you’d like, share how your SIP trigger currently constructs room names (example format) and whether you call DeleteRoom explicitly. I can suggest a safe naming pattern and where to add delays.
• If you prefer, I can outline code-level approaches to generate unique names or add a short retry/backoff before recreating a room.
Would you like me to review your naming/creation flow or propose a specific naming pattern for your use case?
Sources: Avoiding Room ID Reuse When Re-Creating Rooms With the Same Name | Outbound Calling Script | LiveKit Documentation | Agents telephony integration | LiveKit Documentation | Building an Automated IVR Menu Caller | LiveKit Documentation, with interactive elementsbitter-analyst-30633
03/18/2026, 8:44 AMtall-airline-16756
03/18/2026, 8:44 AMCreateSIPParticipant or CreateRoom without a uniqueness guard, two nearly-simultaneous calls will both succeed and create separate sessions that look identical by name and start time.
Practical fixes you can apply now
• Make room names unique per call (recommended): Append a short unique suffix (UUID, timestamp, or call-id). This fully prevents collisions even for concurrent requests. Example: user_12345_20260318T150405Z or user_12345_ab12.
• Add a creation guard in your SIP flow: Before creating a room, check for an in-progress create for the same logical call ID and block duplicate create attempts for a short window (e.g., 1–2 seconds).
• Deduplicate incoming triggers: If your SIP provider or orchestration can send duplicate webhooks, deduplicate by call-id or webhook-id at the edge before calling LiveKit.
• Use an atomic server-side create: If possible, route all CreateRoom requests through a single server-side service that can enforce uniqueness (for example, by using a lock or checking a datastore key) before sending the LiveKit create call.
If you’d like, I can help with either:
• A suggested room-name pattern (UUID vs timestamp vs call-id) for your flow, or
• A short example approach to deduplicate create requests (pseudo-code or sequence steps) that you can implement in your SIP trigger service.
Which would you prefer me to draft for you?
, with interactive elementsbitter-analyst-30633
03/18/2026, 8:54 AMtall-airline-16756
03/18/2026, 8:54 AMbitter-analyst-30633
03/18/2026, 8:57 AMtall-airline-16756
03/18/2026, 8:58 AMorder_12345_7f3b or call-<callid>.
• Add a server-side idempotency/lock (recommended for full protection): Before calling LiveKit, set a short-lived lock keyed by your logical call identifier (call-id, phone number + time window). If the lock exists, skip the create. Use Redis, a DB row with unique constraint, or any central store. This prevents duplicate create attempts reaching LiveKit even if internal retries or duplicate webhooks occur.
• Short dedupe window after create: After you receive the create response, monitor for a second room with the same call identifier within a small window (a few seconds). If a duplicate appears, programmatically DeleteRoom for the unwanted one and continue with the correct room.
• Improve observability: Emit a unique request-id with your CreateSIPParticipantRequest and log it both at your edge and include it when you call LiveKit (if possible). That makes correlating any dual-creation in LiveKit logs deterministic.
Tradeoffs — why choose each option
• Unique names: Quick to implement, prevents confusion, doesn’t mask the underlying bug but avoids operational impact.
• Idempotency/locks: Strong protection that prevents duplicates entirely at the source, slightly more engineering (store + lock logic).
• Dedup & cleanup: Works as a fallback if duplicates still appear; allows automatic correction after the fact.
If you’d like, I can:
• Draft a small idempotency pseudocode example (Redis or DB) you can drop into your SIP trigger path.
• Propose a naming pattern that fits your workflow (short vs verbose suffixes).
• Help analyze specific timestamps/room IDs if you paste the create response(s) and the LiveKit room IDs you observed.
Which do you want next — a short idempotency code snippet or a suggested naming pattern tailored to your flow?
, with interactive elementsbitter-analyst-30633
03/18/2026, 9:02 AMtall-airline-16756
03/18/2026, 9:02 AMbitter-analyst-30633
03/18/2026, 9:11 AMtall-airline-16756
03/18/2026, 9:11 AMroom_name, you should instead determine the correct room_id (via ListRooms or the room_started webhook) and use that ID to select the session to record or to call any egress API that accepts room identity (or use the room’s metadata to pick the right name-to-id mapping before calling egress).
What to do step-by-step
1. Identify the correct room_id for this call
◦ Use ListRooms (or an equivalent API) filtered by the visible room name and pick the right instance:
▪︎ Prefer the room whose started_at or creation_time matches when your agent/participant joined.
▪︎ Prefer the room that has the participant or agent currently present (check participants list).
◦ Or, subscribe to the room_started webhook and cache the latest room_id for each logical call. Webhooks include both room_name and room_id, which gives an authoritative mapping at start time.
1. Use that room_id to pick the single correct session
◦ If you get two matches from ListRooms, choose the one with:
▪︎ the agent and participant present, or
▪︎ the latest creation/started timestamp that corresponds to your call, or
▪︎ the room_id you received earlier from the create response or webhook.
1. Start egress for that room/session
◦ If your SDK or API supports passing room_id directly to start egress, pass the found room_id.
◦ If the SDK currently accepts only room_name, call the higher-level egress API or an admin endpoint that accepts room_id, or use the room_name only after you’ve ensured only one active room_name -> room_id mapping (by deleting/stopping any duplicate).
◦ As a fallback, once you have the correct room_id, programmatically DeleteRoom for any other room_id with the same name (if it’s safe to do so) so room_name resolves to a single session before calling start_room_composite_egress.
Practical examples (patterns)
• Preferred (if API supports room_id):
a. Call ListRooms or listen to room_started and get room_id = RM_xxx.
b. Call egress.start with that room_id.
• If SDK only has `room_name`:
a. Use ListRooms to get all rooms with that name.
b. Select the correct room_id by timestamps or participant presence.
c. If possible, use an admin API to start egress by room_id; otherwise:
• Delete the other room(s) you know are duplicates (DeleteRoom by room_id) so the room_name maps to the right session.
• Then call start_room_composite_egress with room_name.
Observability and selection rules (to pick the right instance reliably)
• Match by participant list: prefer the room that currently shows the participant/agent as connected.
• Match by timestamp: select the room whose start time is closest to when your participant or agent joined.
• Use call metadata: include a unique call-id in participant metadata and use that to locate the right room instance.
Safety notes
• Only DeleteRoom duplicates when you are certain they are orphaned, otherwise you may interrupt a legitimate session.
• If you choose automatic cleanup, add a short cooldown so you don’t remove a session still in use.
Offer to help
• I can draft a short pseudocode snippet for:
◦ Listing rooms and selecting the correct room_id by participant presence/timestamps, and
◦ Starting egress using that chosen room_id (or deleting duplicates then calling your existing room_name-based egress).
• If you paste a sample of your ListRooms response or two room objects (room_id, started_at, participants), I can point out exactly which one to choose and show the API calls in code.
Which would you like — a pseudocode example for ListRooms + select + egress, or a webhook-based approach that caches room_id at start time?
Sources: Avoiding Room ID Reuse When Re-Creating Rooms With the Same Name | Python SDKs | livekit/livekit_composite | DeepWiki | server-sdk-js | livekit/livekit_composite | DeepWiki, with interactive elementsbitter-analyst-30633
03/18/2026, 9:13 AMtall-airline-16756
03/18/2026, 9:14 AM