will the ctx.room event participant-disconnected c...
# ask-ai
o
will the ctx.room event participant-disconnected catch the same events as using waitUntilAnswered when dispatching?
✅ 1
t
Thanks for reaching out, Lara. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — quick clarification on what you asked about. The
ctx.room
participant-disconnected
event fires whenever a participant leaves the room (connection loss, client-initiated disconnect, room deletion, duplicate identity, node migration, etc.). I cannot find any documented
waitUntilAnswered
option or method, so I can’t confirm it or compare its behavior. If by "waitUntilAnswered" you mean a flow that waits for a SIP/phone caller or agent to join, a comparable approach is to wait for the specific participant to arrive (e.g.,
ctx.wait_for_participant()
patterns described in telephony workflows). Do you mean that, or can you share where you saw
waitUntilAnswered
(code snippet or docs) so I can compare exact behavior? Sources: Tasks and task groups | LiveKit Documentation | Job lifecycle | LiveKit Documentation | Agent dispatch | LiveKit Documentation, with interactive elements
o
Participant options in createSipParticipant accept waitUntilAnswered, it says in the docs that if you set that to true you can catch disconnect reasons like USER_UNAVAILABLE and USER_REJECTED, which are reasons returned by the participant_disconnected events. i just want to make sure they are actually the same event that gets fired or if they’re separate and i should be catching errors when dispatching as well as reading every participant disconnectde event
t
Thanks — good detail. You're correct: when you set
wait_until_answered=true
on
createSipParticipant
, telephony failures like
USER_UNAVAILABLE
and
USER_REJECTED
are surfaced via the same
participant_disconnected
event (the reason appears in the event payload). So you can rely on a single flow: • Listen for
participant_disconnected
. • Inspect the
reason
field (e.g.,
USER_UNAVAILABLE
,
USER_REJECTED
,
CLIENT_INITIATED
, etc.) and handle each case. If you'd like, tell me which disconnect reasons you want to handle specially and I can suggest concise handling logic or a small snippet for your event handler. Sources: Understanding the STATE_MISMATCH Disconnect Reason | https://docs.livekit.io/agents/logic/sessions.md| | Why is my Agent insights data missing? | LiveKit | Job lifecycle | LiveKit Documentation, with interactive elements
o
I’m having issues with receiving the dispatched calls. I’ve done this before and it’s worked so I’m stumped, help me figure out what I’m missing. I’m dispatching calls like this:
Copy code
sip.createSipParticipant(call.trunk_id, call.phone_number, room_name, {
				participantIdentity: call.phone_number,
				participantName: `C-${call.call_id}`,
				participantAttributes: {
					...
				},
				krispEnabled: true,
			})
And livekit receives the call but no participant ever connects, no call gets to my phone or anything. here’s the logs I see:
Copy code
19:13:40.069 INFO livekit.agents received job request
{"job_id": "AJ_2PTKNgVeiQi3",
"dispatch_id": "AD_4H5maaQnTfCp", "room":
"out-call-00000000-0000-4000-8000-00000000ac01", "room_id": "RM_MjAAbp2JdDTw",
"agent_name": "", "resuming": false, "enable_recording": false}
19:13:40.080 DEBUG livekit.agents received assignment
{"agent_name": "", "room_id":
"RM_MjAAbp2JdDTw", "room": "out-call-00000000-0000-4000-8000-00000000ac01",
"job_id": "AJ_2PTKNgVeiQi3", "dispatch_id": "AD_4H5maaQnTfCp",
"enable_recording": false}
WARNING livekit.agents no warmed process available for
job, waiting for one to be
created
{"job_id": "AJ_2PTKNgVeiQi3"}
19:13:40.085 INFO livekit.agents initializing process {"pid": 75}
19:13:40.357 INFO livekit.agents process initialized
{"pid": 75, "elapsed_time": 0.27}
DEBUG asyncio Using selector: EpollSelector
{"pid": 75, "job_id": "AJ_2PTKNgVeiQi3",
"room_id": "RM_MjAAbp2JdDTw"}
t
Thanks — I’ll help troubleshoot. A few quick clarifying questions and checks to narrow this down: 1. Has this exact trunk/phone number worked before? If yes, what changed (credentials, trunk config, IPs)? 2. Is
wait_until_answered
set for these calls? If not, set it to true to surface telephony failure reasons via
participant_disconnected
. 3. Can you confirm the
sip_trunk_id
is correct and the trunk is healthy (credentials, IP whitelist, transport)? 4. Is the destination number formatted in E.164 (e.g. +12223334444)? 5. Do you see any SIP signaling from your provider (INVITE / 1xx / 2xx / 4xx / 5xx) in provider logs when the dispatch happens? 6. Are you listening for
participant_joined
/
participant_disconnected
in the room and logging the
reason
field? (Check for
USER_UNAVAILABLE
,
USER_REJECTED
, etc.) 7. Try these quick diagnostics: ◦ Temporarily enable verbose signaling/logging on the SIP trunk and inspect whether the INVITE leaves LiveKit and what response returns. ◦ Use a known-working test number or SIP softphone as the target to verify call path. ◦ Ensure
participantIdentity
is unique per call to avoid collisions. If you can share: • The
createSipParticipant
call including whether
wait_until_answered
was used, • Any SIP provider signaling logs (INVITE/response codes), • Whether
participant_joined
or
participant_disconnected
events ever appear, I’ll walk through the next steps and pinpoint likely causes. Sources: https://docs.livekit.io/agents/start/telephony.md| | Making calls overview | LiveKit Documentation | https://docs.livekit.io/agents/prebuilt/tasks/warm-transfer.md| | Preserving Caller ID During SIP Transfers in LiveKit Agents | Job lifecycle | LiveKit Documentation, with interactive elements
o
1. no, it’s a new livekit project, new trunk, new phone, new everything. but i’ve configured it how i’ve configured other projects before that have worked fine. 2. it is set for these calls 3. the trunk is correct, haven’t set any blockers. i can see the session in the livekit platform, but they don’t show up on twilio and don’t get to my phone. 4. yes it is, i’ve made calls on other projects to it before 5. nothing shows up in twilio 6. i’m listening for and logging participant_disconnected but that doesn’t trigger. i get “room disconnected while waiting for participant” after a while
t
Thanks — helpful details. Let’s narrow this down quickly. Because LiveKit shows the job/room but Twilio sees no INVITE and you get “room disconnected while waiting for participant,” the problem is likely that LiveKit never sent the outbound SIP INVITE to your trunk. Please run these checks and share the results: 1. Confirm SDK/API params ◦ Share the exact
createSipParticipant
call (redact secrets). Include
sip_trunk_id
,
sip_call_to
, and the full options object (you already said
wait_until_answered: true
— confirm). ◦ Ensure
participantIdentity
is unique for this call. 1. LiveKit agent / process readiness ◦ The logs show a warmed process being initialized. After that, do you see any log lines indicating the SIP call attempt (INVITE) or a SIP client creation? Search LiveKit logs for “INVITE”, “SIP”,
createSipParticipant
, or any telephony-related debug messages around the job_id. 1. Trunk configuration & connectivity ◦ Verify the trunk’s outbound settings (authentication, transport, destination, IP ACLs). Even if no explicit blockers exist, confirm the trunk is provisioned/active in the provider console. ◦ Confirm LiveKit’s outbound IPs (or host) are permitted by the trunk provider if IP restriction is required. 1. Provider visibility ◦ Twilio shows nothing — check the provider’s SIP logs/console for any requests or blocked attempts at the exact timestamp of dispatch. If Twilio truly has nothing, LiveKit didn’t reach Twilio. 1. Increase debug logging ◦ Enable verbose signaling/logs on LiveKit agents (or set log level to DEBUG) and re-dispatch. Capture logs from job start through process initialization to see any telephony call attempt lines. 1. Quick functional test ◦ Try calling a known-working test SIP endpoint or softphone as
sip_call_to
to rule out trunk-to-destination issues. ◦ Alternatively, try a second trunk/provider if available. 1. Share these artifacts ◦ The exact
createSipParticipant
call (redact tokens) ◦ LiveKit agent logs (full lines) from job start → ~30s after (include job_id) ◦ Any provider logs for the same timestamps (Twilio console or SIP provider) If you share those three items, I’ll inspect the flow and point to the exact failure (no INVITE, auth failure, transport issue, etc.) and give the exact next steps. , with interactive elements
o
1.
{"trunk":"ST_4hhUEZPHwKeD","phone":"<tel:+51982347605|+51982347605>","room_name":"out-call-00000000-0000-4000-8000-00000000ac01","options":{"participantIdentity":"<tel:+51982347605|+51982347605>","participantName":"C-00000000-0000-4000-8000-00000000ac01","participantAttributes":{"call_id":"00000000-0000-4000-8000-00000000ac01","org_slug":"test","service_key":"..."},"krispEnabled":true}}
2. no logs mentioning an invite 3. it’s provisioned and active. i saw call logs in livekit said invite return anuthorized so i changed the authUsername and authPassword in the outbound trunk but i’m getting the same thing now 4. twilio shows absolutely nothing, nothing in the logs
{"pid": 32, "job_id":
"AJ_eD3fVsbbGovz", "room_id": "RM_frpfeW5k2H3A"}
16:11:44.052 INFO livekit.agents received job request
{"job_id": "AJ_zYfbsaaFYui8",
"dispatch_id": "AD_xTjdXRy3yg7C", "room": "test-dev-_+40770801933_r7xZgrYSTaib",
"room_id": "RM_LJtk3suapwXc", "agent_name": "", "resuming": false,
"enable_recording": false}
16:11:44.063 DEBUG livekit.agents received assignment
{"agent_name": "", "room_id":
"RM_LJtk3suapwXc", "room": "test-dev-_+40770801933_r7xZgrYSTaib", "job_id":
"AJ_zYfbsaaFYui8", "dispatch_id": "AD_xTjdXRy3yg7C", "enable_recording": false}
16:11:44.064 WARNING livekit.agents no warmed process available for
job, waiting for one to be
created
{"job_id": "AJ_zYfbsaaFYui8"}
16:11:44.069 INFO livekit.agents initializing process {"pid": 52}
16:11:44.345 INFO livekit.agents process initialized
{"pid": 52, "elapsed_time": 0.28}
DEBUG asyncio Using selector: EpollSelector
{"pid": 52, "job_id": "AJ_zYfbsaaFYui8",
"room_id": "RM_LJtk3suapwXc"}
16:11:44.765 ERROR omnicare Unexpected error starting web
session: [Errno -2] Name or
service not known
{"pid": 52, "job_id": "AJ_zYfbsaaFYui8",
"room_id": "RM_LJtk3suapwXc"}
16:11:44.766 DEBUG livekit.agents http_session(): creating a new
httpclient ctx
{"pid": 52, "job_id":
"AJ_zYfbsaaFYui8", "room_id": "RM_LJtk3suapwXc"}
16:11:45.603 DEBUG livekit.agents shutting down job task
{"reason": "room disconnected",
"user_initiated": false, "pid": 52, "job_id": "AJ_zYfbsaaFYui8", "room_id":
"RM_LJtk3suapwXc"}
16:11:45.604 INFO livekit.agents process exiting
{"reason": "room disconnected", "pid":
52, "job_id": "AJ_zYfbsaaFYui8", "room_id": "RM_LJtk3suapwXc"}
16:11:45.603 DEBUG livekit.agents http_session(): closing the
httpclient ctx
t
Thanks — this is helpful. From the logs and symptoms the key clue is this error: 161144.765 ERROR omnicare Unexpected error starting web session: [Errno -2] Name or service not known That indicates LiveKit’s worker failed DNS/name resolution or couldn’t reach the SIP provider endpoint, so LiveKit never sent an INVITE to Twilio. Steps to check and next actions: 1. DNS / host reachability ◦ From the machine(s) running your LiveKit agents, run: ▪︎ ping sip-domain ▪︎ dig/nslookup sip-domain ▪︎ curl/sips/telnet to the SIP host: e.g.,
telnet sip.example.com 5060
(or
curl
to the provider’s SIP API host). ◦ If name resolution fails, fix DNS for those hosts or use the provider’s IPs/hosts. 1. Confirm trunk endpoint/URL ◦ Verify the trunk’s configured outbound domain/host is correct (no typo, correct port and transport). The name error often comes from an incorrect host string in the trunk config. 1. Check agent network egress ◦ Ensure your LiveKit agent processes can egress to the internet and to the provider host (no proxy, firewall, or NAT blocking). ◦ If your environment requires a proxy or specific routes, ensure agents are configured accordingly. 1. Re-check auth only after connectivity is fixed ◦ You mentioned previously seeing “invite returned unauthorized” — that was after a DNS/host was reachable. Right now there’s no INVITE reaching Twilio, so fix connectivity first, then re-test. Once INVITE reaches the provider, an auth failure will appear in provider logs. 1. Increase agent logging & reproduce ◦ Set agent log level to DEBUG and reproduce. Capture logs from job start → failure. Look for lines mentioning SIP host, INVITE attempts, or HTTP session creation successes/failures. 1. Quick functional tests ◦ Replace
trunk
with a known-working trunk or a public test SIP endpoint (softphone SIP URI) to check if the issue is trunk-specific or network/DNS-related. ◦ Try using the trunk host IP (if provider supports) to confirm DNS is the blocker. What I need from you to confirm the root cause: • The SIP trunk outbound host/domain as configured (redact creds). • Results of a DNS lookup (dig/nslookup) from the agent host at the timestamp you run a test. • A short snippet of DEBUG logs (job start → error) after you enable debug logging. If you share those three items I’ll point to the exact fix (DNS entry, host typo, network rule) and the next steps to get INVITEs flowing. , with interactive elements
o
143714.205 INFO livekit.agents registered worker {“agent_name”: “”, “id”: “AW_xDSpRHBWFygP”, “url”: “wss://omnicaredev-686sweov.livekit.cloud”, “region”: “Brazil”, “protocol”: 17} 143725.831 INFO livekit.agents received job request {“job_id”: “AJ_rpgz3ff2bkep”, “dispatch_id”: “AD_NVB646QNrQZn”, “room”: “out-call-00000000-0000-4000-8000-00000000ac01”, “room_id”: “RM_wGnqXLHaVk3g”, “agent_name”: “”, “resuming”: false, “enable_recording”: false} 143725.950 DEBUG livekit.agents received assignment {“agent_name”: “”, “room_id”: “RM_wGnqXLHaVk3g”, “room”: “out-call-00000000-0000-4000-8000-00000000ac01”, “job_id”: “AJ_rpgz3ff2bkep”, “dispatch_id”: “AD_NVB646QNrQZn”, “enable_recording”: false} 143725.953 WARNING livekit.agents no warmed process available for job, waiting for one to be created {“job_id”: “AJ_rpgz3ff2bkep”} 143725.960 INFO livekit.agents initializing process {“pid”: 10448} 143727.079 INFO livekit.agents process initialized {“pid”: 10448, “elapsed_time”: 1.12} 143727.078 DEBUG asyncio Using selector: KqueueSelector {“pid”: 10448} 143759.542 ERROR omnicare room disconnected while waiting for participant {“pid”: 10448, “job_id”: “AJ_rpgz3ff2bkep”, “room_id”: “RM_wGnqXLHaVk3g”} 143759.544 INFO livekit.agents process exiting {“reason”: “”, “pid”: 10448, “job_id”: “AJ_rpgz3ff2bkep”, “room_id”: “RM_wGnqXLHaVk3g”} 143759.542 DEBUG livekit.agents shutting down job task {“reason”: “”, “user_initiated”: false, “pid”: 10448, “job_id”: “AJ_rpgz3ff2bkep”, “room_id”: “RM_wGnqXLHaVk3g”} 143759.543 DEBUG livekit.agents http_session(): closing the httpclient ctx {“pid”: 10448, “job_id”: “AJ_rpgz3ff2bkep”, “room_id”: “RM_wGnqXLHaVk3g”}
t
Thanks — this is very clear and helpful. Summary of what’s happening (from your logs): • The job starts, a worker process is created, then the job times out with “room disconnected while waiting for participant.” • Earlier you saw a DNS/host resolution error; current logs show no INVITE attempts and no Twilio activity. • That means the agent process never successfully reached your SIP trunk to send an INVITE (network/DNS or trunk host misconfiguration), so the call never leaves LiveKit. Next steps to diagnose and fix (please run and share results where indicated): 1) Verify trunk host is correct • Confirm the exact outbound host/domain configured on the trunk (redact credentials). A typo or wrong port/transport will prevent DNS resolution or connection. 2) From the machine running LiveKit agents, test reachability to the trunk host (run and paste results) • nslookup trunk-host • dig +short trunk-host • ping -c 3 trunk-host • curl -v telnet trunk-host port (or:
nc -vz <trunk-host> <port>
) Share outputs and timestamps. 3) Confirm agent egress & DNS settings • Ensure the agent host(s) can egress to the internet and are using a working DNS resolver (no internal DNS override that can’t resolve provider hosts). • If your environment requires a proxy, ensure agents are configured to use it. 4) Re-enable verbose agent logging and reproduce • Set agent logs to DEBUG, then dispatch the call. Capture logs from job start → process initialization → until failure (include job_id). Look for lines referencing SIP host, SIP client creation, INVITE, or DNS errors. 5) Quick functional tests • Replace your trunk with a known-working test SIP target (softphone SIP URI or public SIP echo) as
sip_call_to
. If that connects, problem is trunk/provider-specific. • If possible, test using the trunk’s IP (if provider supports) to bypass DNS. 6) If you previously saw “INVITE returned unauthorized” after fixing creds: • Wait until connectivity is fixed first. After that, an AUTH failure will show in the provider logs — then re-check authUsername/authPassword and transport (TCP/UDP/TLS) and caller ID policies. What I need from you next to pinpoint the root cause: • The trunk outbound host/domain as configured (redact creds). • Outputs of the reachability tests (nslookup/dig/ping/telnet) from the agent host. • DEBUG agent logs for one failed attempt (job_id included). Share those three items and I’ll identify whether it’s DNS, network egress, trunk host typo, or an auth/transport issue and give exact fix steps. , with interactive elements
o
1. the trunk and everything is correct. i’ve double checked. even created new credentials just for this 2. all those are successful 3. no proxy 4. they are at debug level, nothing shows up
t
Thanks — I know this is frustrating. You’ve shown that trunk, DNS, and network are OK and agents run at DEBUG, but the job still times out with no INVITE and no participant events. A few targeted checks that often catch this specific symptom: 1) Confirm API field name and SDK usage • Share the exact code (including imports) where you call
sip.createSipParticipant
. In your payload you used
trunk
— the API expects the trunk identifier field name used by your SDK version (e.g.,
sip_trunk_id
vs
trunk
). Please paste the call site so I can verify the right param name. 2) Ensure telephony/SIP plugin is present in the worker image • Some worker images require the telephony/SIP plugin or package included. Confirm your agent runtime includes the telephony plugin (or show your worker/agent image/runtime details). 3) Enable TRACE for telephony components and reproduce once • With DEBUG showed nothing, enable TRACE or the most verbose logging for SIP/omnicare/telephony components, reproduce, and send the logs (job_id). Look for any lines about SIP client initialization, SIP host resolution, or "creating SIP client" — absence of these indicates the SIP path never initialized. 4) Check for early exceptions suppressing SIP init • You previously saw DNS errors; now you see only “room disconnected while waiting for participant.” Search earlier logs (a few seconds before init) for any exception stacktrace or "unexpected error starting web session" — share those lines if present. 5) Quick local test to prove INVITE path • From an environment where you can run the SDK call (or from the agent host), replace
trunk
with a known public SIP target (softphone SIP URI) or another working trunk and see if an INVITE shows up in provider logs. If INVITE appears for the test target but not for your trunk, it narrows to trunk config or plugin mapping. What I need now to proceed: • The exact
createSipParticipant
call code (including imports) you’re executing. • The worker/agent runtime/image details (how the agent is run). • TRACE/DEBUG log dump for one reproduce (include job_id). Share those three items and I’ll pinpoint whether it’s a wrong param name, missing plugin, suppressed exception, or another runtime issue and give the exact fix. Sources: Agent dispatch | LiveKit Documentation | Why is my Agent insights data missing? | LiveKit | Why is my Agent insights data missing? | LiveKit, with interactive elements