i have an agent that dispatches via RoomAgentDispa...
# ask-ai
k
i have an agent that dispatches via RoomAgentDispatch on a individual dispatch rule when an inbound call is received on a number associated with an inbound trunk. occasionally when an invite is sent to the trunk, From livekit I'm getting 100 processing then 180 ringing every second until I get 408 hangup reason. no agent was ever dispatched
t
Thanks for reaching out, Ethan. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I’m looking into the issue where you see repeated
100 Processing
/
180 Ringing
then a
408
without an agent being dispatched. I’ll focus on what can be changed to get dispatch to complete. What I’m responding to: the SIP INVITE to your inbound trunk gets acknowledged (100/180) but no agent joins and the call times out with 408. Quick checklist you can run now • Confirm the
agent_name
in your agent code exactly matches
agentName
in the dispatch rule (case-sensitive). • Verify the dispatch rule applies to the trunk receiving the INVITE (either includes that trunk’s ID in
trunk_ids
or leaves
trunk_ids
empty). • Ensure the agent process is running, connected, and has available workers (
lk agent status
or agent logs). • Increase the trunk’s
ringing_timeout
(try 30–45s) so LiveKit waits longer for the agent to join. • Test with a minimal agent that logs on
session.start
to confirm the dispatch entrypoint is reached. • Check LiveKit server logs around the INVITE for dispatch attempts or errors and for messages like “no room context” which indicate session setup delays. What I need from you to diagnose further • The exact dispatch rule JSON. • The agent code snippet that includes
@server.rtc_session(agent_name=...)
. • LiveKit server and agent logs spanning the INVITE → repeated 180s → 408. • Whether this is consistent or intermittent. If you share those, I’ll look for mismatched names, trunk-rule mismatches, agent health/registration issues, or timing problems and give targeted next steps. Sources: SIP dispatch rule | LiveKit docs | Agents telephony integration | LiveKit Docs | Using Wavix to accept and make calls | LiveKit docs | SIP Integration & Telephony | livekit/livekit_composite | DeepWiki | SIP APIs | LiveKit docs
k
these all work fine 99% of the time. the last 1% i get 30s of ringing
t
Thanks — I hear that this is intermittent (~1% of calls) and usually works but occasionally rings ~30s before timing out. To pinpoint the cause I need a few targeted details from one or two failing calls. Please provide: • The exact dispatch rule JSON used for the inbound trunk. • The agent code snippet that includes
@server.rtc_session(agent_name=...)
. • LiveKit server logs and agent logs covering the INVITE → repeated 180s → 408 for a failing call (timestamps help). • Whether these failures correlate with higher call concurrency or CPU/memory spikes on the agent or LiveKit servers. • Your inbound trunk
ringing_timeout
value and whether 30s matches it. • Whether this happens for specific calling numbers or trunks only, or truly random. With those artifacts I’ll look for mismatched
agent_name
, trunk-rule mismatches, agent registration/worker availability, or timing/resource contention and give concrete next steps. Would you like instructions for pulling the exact logs if you need them?
k
the agent name is correct, and these failures don't correlate with higher call concurrency. there are no rule mismatches
t
Thanks — I appreciate you confirming agent name, rules, and concurrency. Since config and load look fine, intermittent 30s ringing + 408 points to a timing or network/registration hiccup when dispatching. To narrow it down I still need one failing call trace. Please provide the following for a recent failure (timestamps help): • LiveKit server logs covering INVITE → repeated 180 → 408 (include any "dispatch" / "room" entries). • Agent logs for the same timeframe (session start, registration, errors/warnings). • The inbound trunk's
ringing_timeout
value. • The exact dispatch rule JSON and the agent code snippet with
@server.rtc_session(agent_name=...)
. • Output of
lk agent status
taken near the failure (if available). • Note: any recent network or firewall changes, NAT flaps, or restarts around that time. If you prefer, share one call's SIP trace (INVITE/ responses) and I’ll correlate SIP timing with LiveKit/agent logs to identify whether the agent never received the dispatch, received it but failed to join, or joined too late. Which log file(s) would you like instructions for extracting?
k
is it possible the livekit sip -> agent dispatch isn't perfectly reliable?
t
Short answer: LiveKit’s SIP→agent dispatch is designed to be reliable, but intermittent failures can still occur. A 30s ringing then 408 typically means LiveKit accepted the INVITE and rang the call but no agent joined the room in time. Why this can happen (common causes) • Agent registration/availability blip — the agent process is briefly not registered or has no free worker when dispatch occurs. • Timing/latency — signaling or WebSocket setup completes slower for that call (logs like “no room context” show this can occur). • Network or NAT hiccups between LiveKit and the agent (delayed or dropped dispatch notification). • Agent-side errors on session start that prevent joining/publishing. • Trunk ringing_timeout reached before the agent finishes joining or publishing audio. Concrete steps to improve reliability • Increase the trunk’s
ringing_timeout
to 30–45s to give more headroom for slow joins. • Add lightweight health checks and ensure agents stay continuously connected and have spare workers. • Add logging on the agent entrypoint (e.g., log immediately on
session.start
) to confirm whether dispatch requests reached the agent. • Correlate SIP traces with LiveKit and agent logs for failing calls to see whether dispatch was sent, received, or dropped. • Consider redundancy: run multiple agent workers with the same
agent_name
so one can pick up dispatch if another is transiently unavailable. • Monitor agent registration and WebSocket reconnects so transient disconnects are visible and alerted. If you’d like, I can: • Analyze one failing call if you share the SIP trace + LiveKit server logs + agent logs for that call. • Suggest specific config values for
ringing_timeout
and health-check intervals based on your current settings. Which would you prefer?