Originate Failed. Cause: UNALLOCATED_NUMBER if i ...
# ask-ai
b
Originate Failed. Cause: UNALLOCATED_NUMBER if i tried using micro sip where as originate sofia/external/+15183171307@5njkgqf81lp.sip.livekit.cloud:5060;transport=tcp &park() if i tried like this it working why it happen lke this?
t
Thanks for reaching out, Vishnu. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — you're seeing this because LiveKit expects calls to arrive via a configured SIP trunk/gateway, not as a direct peer-to-peer SIP UA call. Why MicroSIP fails (UNALLOCATED_NUMBER) • A direct call from MicroSIP to the LiveKit SIP address doesn't match an inbound trunk/dispatch rule in LiveKit, so LiveKit treats the dialed number as unprovisioned and returns UNALLOCATED_NUMBER. Why the FreeSWITCH originate works • FreeSWITCH (
sofia/external/...
) is acting as a SIP gateway/trunk that dials LiveKit on behalf of the caller. That call comes from a configured trunk/gateway and matches LiveKit’s routing, so it succeeds. What you can do • Route calls through a SIP trunk or PBX (FreeSWITCH, Twilio, Telnyx, etc.) that is configured to send calls to your LiveKit SIP endpoint. • Ensure you have an inbound trunk and appropriate dispatch rules in LiveKit that match the called number so LiveKit knows how to route the call (e.g., to a room or flow). • If you want MicroSIP to reach LiveKit, have MicroSIP register to or send calls through a PBX/trunk that is authorized to call your LiveKit SIP gateway — not directly to the LiveKit SIP URI. If you’d like, tell me: • which SIP trunk or provider you’re using (or if you control FreeSWITCH), and • the LiveKit routing you expect (direct to room, IVR, etc.), and I’ll suggest the exact trunk/dispatch configuration steps. Sources: SIP APIs | LiveKit docs | Accepting inbound calls | LiveKit docs | SIP inbound trunk | LiveKit docs | Make outbound calls | LiveKit docs
b
We fix this but now !! If we dial 8888 in microsip it will route the call to livekit , as of now the call routed successfully but the AI agent is not responding in microsip !!! Where as if we call the number through phone it's working
t
Thanks — I’m looking into why the AI agent answers calls from a phone but not from MicroSIP even though 8888 reaches LiveKit. A few likely causes and quick checks to narrow this down: What I’m responding to: MicroSIP calls connect to LiveKit but the AI agent doesn’t respond; phone-originated calls do. Quick checks (please confirm these): • Is the same LiveKit phone number / trunk and dispatch rule used when you call from MicroSIP and from the phone? • Is the agent registered and running (dev/start) and able to receive jobs when a phone call arrives? • Can you check the agent logs for a JobContext when a MicroSIP call arrives? Does the agent show any incoming job or error? Likely causes and what to inspect • Dispatch rule mismatch: Ensure the dispatch rule applied to the inbound number includes the agent name exactly as the agent is registered. If phone calls match but MicroSIP differs in signaling headers or dialed digits, the rule may not match for MicroSIP. • Agent not dispatched / wrong room: Verify the call from MicroSIP lands in the same room/prefix the agent watches. Compare the room name or
JobContext
between phone and MicroSIP calls. • SIP signaling / headers differences: MicroSIP INVITE headers or Caller ID format may differ and cause trunk/dispatch evaluation to pick a different route. Capture and compare SIP INVITES for phone vs MicroSIP. • Media/SDP negotiation: MicroSIP’s SDP or codecs might prevent proper media setup so the agent can’t detect audio. Check SDP in the INVITE/200 OK and confirm supported codecs match the agent/LiveKit. • Agent-side errors: Look for errors in the AI agent process (failed media, no job received, or rejected job). Next diagnostic steps I can guide you through (pick one): • How to check agent logs and JobContext for MicroSIP vs phone calls. • How to capture and compare SIP INVITE/SDP for both call types. • How to verify and update your dispatch rule to force dispatch to the agent. Which of the above would you like to try first? If you share: • a snippet of the dispatch rule (redact secrets) and • a SIP INVITE log for the MicroSIP call (or confirm you can capture it), I’ll point to exactly what to change or look for. Sources: SIP dispatch rule | LiveKit docs | Agents telephony integration | LiveKit docs | Voice AI quickstart | LiveKit docs | Agent dispatch | LiveKit docs | SIP participant | LiveKit docs
b
{   "sipTrunkId": "ST_UE2fnCs4yxSo",   "name": "My inbound trunk AgnoX",   "numbers": [     "+15183171307"   ],   "allowedAddresses": [     "0.0.0.0/0"   ],   "krispEnabled": true } This is my inbound trunk I'd !! And this is dispatch rule : { "dispatch_rule": { "name": "agnox-15183171307", "rule": { "dispatchRuleIndividual": { "roomPrefix": "call-" } }, "roomConfig": { "agents": [ { "agentName": "AgnoX-AI-Agent" } ] }, "metadata": "{\"source_number\": \"+15183171307\", \"service\": \"customer_service\"}" } }
t
Thanks — I see your inbound trunk and dispatch rule. I’ll focus on why the agent may not be dispatched or able to interact when the call comes from MicroSIP. Quick validation of what you’ve shown • Trunk accepts all addresses and has krisp enabled — fine. • Dispatch rule dispatches to room prefix
call-
and an agent named
AgnoX-AI-Agent
— name must exactly match the agent registration. Short checklist and next diagnostics to run (pick one or more) 1. Confirm agent registration ◦ Is the AI agent process connected to LiveKit with agentName exactly
AgnoX-AI-Agent
? Check the agent logs for a successful registration event. 1. Verify the call lands in the expected room ◦ When MicroSIP dials 8888, capture the created room name (should start with
call-
). Compare the room created for a phone call vs MicroSIP. If MicroSIP lands in a different room, the agent won’t get dispatched. 1. Check JobContext arrival ◦ When MicroSIP calls, does the agent log show a JobContext or incoming job? If not, dispatch rule matching may be failing. If yes, inspect why the agent isn’t answering that job. 1. Compare SIP INVITE headers and Caller ID ◦ Capture INVITEs for MicroSIP and phone calls. Compare To/From/Request-URI and any P-Asserted-Identity or Diversion headers. Differences can cause dispatch mismatches or trunk routing differences. 1. Inspect SDP / media negotiation ◦ Confirm MicroSIP and phone calls negotiate compatible codecs and that media is flowing. If SDP from MicroSIP lacks supported codecs or uses direct media that blocks media relaying, the agent may receive no audio and appear unresponsive. 1. Confirm dispatch rule association with your phone number ◦ Ensure the number +15183171307 is associated with the dispatch rule in LiveKit so inbound from that number triggers the rule. If you prefer, I can guide you through capturing logs. Please provide one of these: • The agent log snippet around an attempted MicroSIP call (redact secrets), or • SIP INVITE/200OK SDP snippets for both MicroSIP and phone calls, or • The room name created for a MicroSIP call and for a phone call. Which would you like to share?
b
this is the log
t
Thanks — I see the session dashboard image, but it doesn't show the agent logs or SIP signaling we need. Please provide one of these (redact any secrets): • Agent log snippet around a MicroSIP call attempt showing registration and JobContext events. • SIP INVITE and 200/ACK (full headers and SDP) for a MicroSIP call and for a working phone call so we can compare. • The exact room name created when you dial 8888 from MicroSIP and the room name from a phone call. Any of those will let me pinpoint whether the dispatch rule matched, whether a JobContext was delivered, or whether SDP/media differences are preventing the agent from responding. Which can you share?
b
2025-12-02 125003,007 - livekit.agents - INFO - received job request {"level": "INFO", "name": "livekit.agents", "message": "received job request", "job_id": "AJ_jC27hUvk5JeK", "dispatch_id": "AD_7VbLhoNDqpVf", "room": "call-_+15183171307_9RMYGzfCGUG4", "room_id": "RM_8R3i3kNXDfv5", "agent_name": "AgnoX-AI-Agent", "resuming": false, "enable_recording": true, "timestamp": "2025-12-02T072003.007755+00:00"} 2025-12-02 125003,103 - livekit.agents - INFO - initializing job runner {"level": "INFO", "name": "livekit.agents", "message": "initializing job runner", "tid": 3272, "timestamp": "2025-12-02T072003.103024+00:00"} 2025-12-02 125003,110 - livekit.agents - INFO - job runner initialized {"level": "INFO", "name": "livekit.agents", "message": "job runner initialized", "tid": 3272, "elapsed_time": 0.0, "timestamp": "2025-12-02T072003.110066+00:00"} 2025-12-02 125004,033 - app.services.queue_manager - INFO - QueueManager initialized {"level": "INFO", "name": "app.services.queue_manager", "message": "QueueManager initialized", "timestamp": "2025-12-02T072004.033865+00:00"} 2025-12-02 125004,034 - main - INFO - Database and services initialized successfully {"level": "INFO", "name": "__main__", "message": "Database and services initialized successfully", "timestamp": "2025-12-02T072004.034863+00:00"} 2025-12-02 125004,719 - main - INFO - Connected to room: call-_+15183171307_9RMYGzfCGUG4 {"level": "INFO", "name": "__main__", "message": "Connected to room: call-_+15183171307_9RMYGzfCGUG4", "timestamp": "2025-12-02T072004.719437+00:00"} 2025-12-02 125004,723 - main - INFO - Processing inbound call from unknown {"level": "INFO", "name": "__main__", "message": "Processing inbound call from unknown", "timestamp": "2025-12-02T072004.723226+00:00"} 2025-12-02 125004,724 - main - INFO - Fetching customer context for unknown {"level": "INFO", "name": "__main__", "message": "Fetching customer context for unknown", "timestamp": "2025-12-02T072004.724234+00:00"} 2025-12-02 125004,806 - app.services.customer_service - INFO - 📊 Customer found: ID=1, Calls=135, Last Call=2025-12-01 200453.729488 {"level": "INFO", "name": "app.services.customer_service", "message": "📊 Customer found: ID=1, Calls=135, Last Call=2025-12-01 200453.729488", "timestamp": "2025-12-02T072004.806573+00:00"} 2025-12-02 125004,814 - main - INFO - Returning customer: Customer-nown (ID: 1, 135 previous calls) {"level": "INFO", "name": "__main__", "message": "Returning customer: Customer-nown (ID: 1, 135 previous calls)", "timestamp": "2025-12-02T072004.814593+00:00"} 2025-12-02 125004,842 - app.services.customer_service - INFO - 📜 Retrieved 3 call history records for customer 1 {"level": "INFO", "name": "app.services.customer_service", "message": "📜 Retrieved 3 call history records for customer 1", "timestamp": "2025-12-02T072004.842768+00:00"} 2025-12-02 125004,878 - app.services.customer_service - INFO - ✅ Call session created: ID=136, Customer=1, Room=call-_+15183171307_9RMYGzfCGUG4 {"level": "INFO", "name": "app.services.customer_service", "message": "✅ Call session created: ID=136, Customer=1, Room=call-_+15183171307_9RMYGzfCGUG4", "timestamp": " 2025-12-02T072004.878699+00:00"} 2025-12-02 125004,883 - main - INFO - Session ID: 136 {"level": "INFO", "name": "__main__", "message": "Session ID: 136", "timestamp": "2025-12-02T072004.883988+00:00"} 2025-12-02 125004,921 - app.services.queue_manager - INFO - Added to queue: 131 for customer 1 from unknown with priority 2 {"level": "INFO", "name": "app.services.queue_manager", "message": "Added to queue: 131 for customer 1 from unknown with priority 2", "timestamp": "2025-12-02T072004.921072+00:00"} 2025-12-02 125004,926 - main - INFO - Queue ID: 131 {"level": "INFO", "name": "__main__", "message": "Queue ID: 131", "timestamp": "2025-12-02T072004.926849+00:00"} 2025-12-02 125004,929 - main - INFO - OpenAI RealtimeModel created {"level": "INFO", "name": "__main__", "message": "OpenAI RealtimeModel created", "timestamp": "2025-12-02T072004.929848+00:00"} 2025-12-02 125005,110 - main - INFO - Built 1 function tools {"level": "INFO", "name": "__main__", "message": "Built 1 function tools", "timestamp": "2025-12-02T072005.110184+00:00"} 2025-12-02 125005,117 - main - INFO - Voice Agent created with tools {"level": "INFO", "name": "__main__", "message": "Voice Agent created with tools", "timestamp": "2025-12-02T072005.117094+00:00"} 2025-12-02 125005,117 - main - INFO - Event handlers configured {"level": "INFO", "name": "__main__", "message": "Event handlers configured", "timestamp": "2025-12-02T072005.117626+00:00"} 2025-12-02 125005,124 - livekit.agents - WARNING - RoomInputOptions and RoomOutputOptions are deprecated, use RoomOptions instead {"level": "WARNING", "name": "livekit.agents", "message": "RoomInputOptions and RoomOutputOptions are deprecated, use RoomOptions instead", "timestamp": "2025-12-02T072005.124627+00:00"} 2025-12-02 125005,187 - main - INFO - Agent session started and conversation completed {"level": "INFO", "name": "__main__", "message": "Agent session started and conversation completed", "timestamp": "2025-12-02T072005.187840+00:00"} 2025-12-02 125005,197 - app.services.customer_service - INFO - ✅ Session ended: ID=136, Duration=0s, Handled by=ai {"level": "INFO", "name": "app.services.customer_service", "message": "✅ Session ended: ID=136, Duration=0s, Handled by=ai", "timestamp": "2025-12-02T072005.197557+00 :00"} 2025-12-02 125005,204 - app.services.queue_manager - INFO - Marked queue entry 131 as completed {"level": "INFO", "name": "app.services.queue_manager", "message": "Marked queue entry 131 as completed", "timestamp": "2025-12-02T072005.204556+00:00"} 2025-12-02 125005,206 - main - INFO - Session 136 completed (resolved by AI) {"level": "INFO", "name": "__main__", "message": "Session 136 completed (resolved by AI)", "timestamp": "2025-12-02T072005.206553+00:00"} 2025-12-02 125006,308 - livekit.plugins.openai - ERROR - OpenAI Realtime API returned an error {"level": "ERROR", "name": "livekit.plugins.openai", "message": "OpenAI Realtime API returned an error", "error": "RealtimeError(message=\"Invalid value: 'Nova'. Supported values are: 'alloy', 'ash', 'ballad', 'coral', 'echo', 'sage', 'shimmer', 'verse', 'marin', and 'cedar'.\", type='invalid_request_error', code='invalid_value', event_id='session_update_300825626bc2', param='session.audio.output.voice')", "timestamp": "2025-12-02T072006.308463+00:00"} 2025-12-02 125006,315 - opentelemetry.attributes - WARNING - Attribute error: Invalid type RealtimeError for attribute value. Expected one of ['NoneType', 'bool', 'bytes', 'int', 'float', 'str', 'Sequence', 'Mapping'] or a sequence of those types {"level": "WARNING", "name": "opentelemetry.attributes", "message": "Attribute error: Invalid type RealtimeError for attribute value. Expected one of ['NoneType', 'bool', 'bytes', 'int', 'float', 'str', 'Sequence', 'Mapping'] or a sequence of those types", "timestamp": "2025-12-02T072006.315469+00:00"} 2025-12-02 125025,794 - livekit.agents - INFO - closing agent session due to participant disconnect (disable via
RoomInputOptions.close_on_disconnect=False
)
t
Thanks — I reviewed your logs and the issue is clear. What I’m responding to: the agent receives the job, connects to the room, then the session ends immediately and OpenAI Realtime returns an error. Root cause • The OpenAI Realtime API error shows the configured output voice value is invalid: "Invalid value: 'Nova'." That causes the agent session to fail immediately (0s duration). What you can do 1. Update the agent’s audio output voice to one of the supported voices: alloy, ash, ballad, coral, echo, sage, shimmer, verse, marin, cedar. 2. Redeploy/restart the agent so the new voice setting takes effect. 3. Re-test the MicroSIP call. Notes • Your trunk and dispatch rule look correct and the job is being delivered (the agent receives JobContext and connects to room
call-_+15183171307_9RMYGzfCGUG4
), so fixing the voice value should allow the agent to proceed. • If you want, tell me where the voice is configured (config file, env var, or code) and I’ll point to exactly what to change.
b
2025-12-02 125433,407 - livekit.agents - INFO - received job request {"level": "INFO", "name": "livekit.agents", "message": "received job request", "job_id": "AJ_qWWtfN2V5k2L", "dispatch_id": "AD_nXsZmPN6xUcy", "room": "call-_+15183171307_iHygizVQUfDR", "room_id": "RM_v8VVxVFmor93", "agent_name": "AgnoX-AI-Agent", "resuming": false, "enable_recording": true, "timestamp": "2025-12-02T072433.407393+00:00"} 2025-12-02 125433,570 - livekit.agents - INFO - initializing job runner {"level": "INFO", "name": "livekit.agents", "message": "initializing job runner", "tid": 22680, "timestamp": "2025-12-02T072433.570318+00:00"} 2025-12-02 125433,576 - livekit.agents - INFO - job runner initialized {"level": "INFO", "name": "livekit.agents", "message": "job runner initialized", "tid": 22680, "elapsed_time": 0.0, "timestamp": "2025-12-02T072433.576470+00:00"} 2025-12-02 125434,609 - app.services.queue_manager - INFO - QueueManager initialized {"level": "INFO", "name": "app.services.queue_manager", "message": "QueueManager initialized", "timestamp": "2025-12-02T072434.609796+00:00"} 2025-12-02 125434,612 - main - INFO - Database and services initialized successfully {"level": "INFO", "name": "__main__", "message": "Database and services initialized successfully", "timestamp": "2025-12-02T072434.612030+00:00"} 2025-12-02 125435,304 - main - INFO - Connected to room: call-_+15183171307_iHygizVQUfDR {"level": "INFO", "name": "__main__", "message": "Connected to room: call-_+15183171307_iHygizVQUfDR", "timestamp": "2025-12-02T072435.304488+00:00"} 2025-12-02 125435,308 - main - INFO - Processing inbound call from unknown {"level": "INFO", "name": "__main__", "message": "Processing inbound call from unknown", "timestamp": "2025-12-02T072435.308058+00:00"} 2025-12-02 125435,310 - main - INFO - Fetching customer context for unknown {"level": "INFO", "name": "__main__", "message": "Fetching customer context for unknown", "timestamp": "2025-12-02T072435.310059+00:00"} 2025-12-02 125435,363 - app.services.customer_service - INFO - 📊 Customer found: ID=1, Calls=136, Last Call=2025-12-02 125004.849346 {"level": "INFO", "name": "app.services.customer_service", "message": "📊 Customer found: ID=1, Calls=136, Last Call=2025-12-02 125004.849346", "timestamp": "2025-12-02T072435.363160+00:00"} 2025-12-02 125435,374 - main - INFO - Returning customer: Customer-nown (ID: 1, 136 previous calls) {"level": "INFO", "name": "__main__", "message": "Returning customer: Customer-nown (ID: 1, 136 previous calls)", "timestamp": "2025-12-02T072435.374163+00:00"} 2025-12-02 125435,395 - app.services.customer_service - INFO - 📜 Retrieved 3 call history records for customer 1 {"level": "INFO", "name": "app.services.customer_service", "message": "📜 Retrieved 3 call history records for customer 1", "timestamp": "2025-12-02T072435.395321+00:00"} 2025-12-02 125435,412 - app.services.customer_service - INFO - ✅ Call session created: ID=137, Customer=1, Room=call-_+15183171307_iHygizVQUfDR {"level": "INFO", "name": "app.services.customer_service", "message": "✅ Call session created: ID=137, Customer=1, Room=call-_+15183171307_iHygizVQUfDR", "timestamp": " 2025-12-02T072435.412454+00:00"} 2025-12-02 125435,418 - main - INFO - Session ID: 137 {"level": "INFO", "name": "__main__", "message": "Session ID: 137", "timestamp": "2025-12-02T072435.418751+00:00"} 2025-12-02 125435,433 - app.services.queue_manager - INFO - Added to queue: 132 for customer 1 from unknown with priority 2 {"level": "INFO", "name": "app.services.queue_manager", "message": "Added to queue: 132 for customer 1 from unknown with priority 2", "timestamp": "2025-12-02T072435.433942+00:00"} 2025-12-02 125435,438 - main - INFO - Queue ID: 132 {"level": "INFO", "name": "__main__", "message": "Queue ID: 132", "timestamp": "2025-12-02T072435.438893+00:00"} 2025-12-02 125435,442 - main - INFO - OpenAI RealtimeModel created {"level": "INFO", "name": "__main__", "message": "OpenAI RealtimeModel created", "timestamp": "2025-12-02T072435.442885+00:00"} 2025-12-02 125435,556 - main - INFO - Built 1 function tools {"level": "INFO", "name": "__main__", "message": "Built 1 function tools", "timestamp": "2025-12-02T072435.556319+00:00"} 2025-12-02 125435,558 - main - INFO - Voice Agent created with tools {"level": "INFO", "name": "__main__", "message": "Voice Agent created with tools", "timestamp": "2025-12-02T072435.558023+00:00"} 2025-12-02 125435,559 - main - INFO - Event handlers configured {"level": "INFO", "name": "__main__", "message": "Event handlers configured", "timestamp": "2025-12-02T072435.559022+00:00"} 2025-12-02 125435,573 - livekit.agents - WARNING - RoomInputOptions and RoomOutputOptions are deprecated, use RoomOptions instead {"level": "WARNING", "name": "livekit.agents", "message": "RoomInputOptions and RoomOutputOptions are deprecated, use RoomOptions instead", "timestamp": "2025-12-02T072435.573029+00:00"} 2025-12-02 125435,773 - main - INFO - Agent session started and conversation completed {"level": "INFO", "name": "__main__", "message": "Agent session started and conversation completed", "timestamp": "2025-12-02T072435.773288+00:00"} 2025-12-02 125435,790 - app.services.customer_service - INFO - ✅ Session ended: ID=137, Duration=0s, Handled by=ai {"level": "INFO", "name": "app.services.customer_service", "message": "✅ Session ended: ID=137, Duration=0s, Handled by=ai", "timestamp": "2025-12-02T072435.790175+00 :00"} 2025-12-02 125435,825 - app.services.queue_manager - INFO - Marked queue entry 132 as completed {"level": "INFO", "name": "app.services.queue_manager", "message": "Marked queue entry 132 as completed", "timestamp": "2025-12-02T072435.825178+00:00"} 2025-12-02 125435,837 - main - INFO - Session 137 completed (resolved by AI) {"level": "INFO", "name": "__main__", "message": "Session 137 completed (resolved by AI)", "timestamp": "2025-12-02T072435.837748+00:00"}
t
Thanks — I reviewed the new logs and session info you provided. What I’m responding to: the recent job logs showing the agent receives the job, connects to the room, then the session ends immediately with 0s duration and no published tracks. Findings (concise) • The agent receives JobContext and connects to room
call-_+15183171307_*
. • Session ends immediately (0s) and publishers show 0 tracks — the agent had no audio to process. • Earlier you had an OpenAI voice error ("Nova") which you should have fixed; current logs show no OpenAI error, so the remaining problem is likely media (audio) not reaching LiveKit from MicroSIP. Please check these, in order: 1) MicroSIP local audio • Confirm MicroSIP has microphone enabled and is sending audio (unmuted). • Verify MicroSIP is using a supported codec (preferably Opus or PCMU/PCMA). 2) SDP / codec negotiation • Capture the SIP INVITE and 200 OK for a MicroSIP call and compare the SDP to a working phone call. Look for missing codecs or a=sendrecv vs a=sendonly/recvonly differences. 3) RTP/media path (NAT / firewall) • Ensure RTP ports are open/forwarded and not blocked by NAT. MicroSIP behind strict NAT may fail to send media to LiveKit. • If using UDP RTP, check that RTP packets are received by LiveKit (packet counts in session analytics or by capturing on your PBX). 4) LiveKit session analytics & participant tracks • In the Session view, confirm the SIP participant shows a published audio track when you call from MicroSIP. If it shows 0 tracks, media isn’t negotiated or being published. • If a track appears for phone calls but not MicroSIP, that confirms client-side/SDP differences. 5) Trunk / proxy behavior • If MicroSIP calls are routed through a PBX (FreeSWITCH) ensure the PBX is bridging media correctly (not switching to direct media or dropping RTP). Try letting the PBX proxy RTP rather than direct endpoint-to-endpoint. What to capture and share (pick one) • SIP INVITE + 200 OK SDP for MicroSIP and for a working phone call (redact auth tokens). OR • A screenshot/snippet from Session analytics showing the SIP participant’s tracks for both MicroSIP and phone calls. OR • A short packet capture (RTP) showing whether audio packets arrive at LiveKit/your PBX. Next step I can guide: once you share one of the above, I’ll pinpoint whether the issue is codec mismatch, NAT/RTP blocking, or PBX media handling and give exact changes to make. Which would you like to provide?
b
2025-12-02 130521,218 - livekit.agents - INFO - received job request {"level": "INFO", "name": "livekit.agents", "message": "received job request", "job_id": "AJ_bgSWgoPYEsHK", "dispatch_id": "AD_D4dN8DnNqpZv", "room": "call-_+15183171307_jWagMRuEaD3w", "room_id": "RM_FPgBUw93gn4W", "agent_name": "AgnoX-AI-Agent", "resuming": false, "enable_recording": true, "timestamp": "2025-12-02T073521.218986+00:00"} 2025-12-02 130522,464 - app.services.queue_manager - INFO - QueueManager initialized {"level": "INFO", "name": "app.services.queue_manager", "message": "QueueManager initialized", "timestamp": "2025-12-02T073522.464527+00:00"} 2025-12-02 130522,465 - main - INFO - Database and services initialized successfully {"level": "INFO", "name": "__main__", "message": "Database and services initialized successfully", "timestamp": "2025-12-02T073522.465645+00:00"} 2025-12-02 130523,178 - main - INFO - Connected to room: call-_+15183171307_jWagMRuEaD3w {"level": "INFO", "name": "__main__", "message": "Connected to room: call-_+15183171307_jWagMRuEaD3w", "timestamp": "2025-12-02T073523.178836+00:00"} 2025-12-02 130523,181 - main - INFO - Processing inbound call from unknown {"level": "INFO", "name": "__main__", "message": "Processing inbound call from unknown", "timestamp": "2025-12-02T073523.181840+00:00"} 2025-12-02 130523,183 - main - INFO - Fetching customer context for unknown {"level": "INFO", "name": "__main__", "message": "Fetching customer context for unknown", "timestamp": "2025-12-02T073523.183831+00:00"} 2025-12-02 130523,229 - app.services.customer_service - INFO - 📊 Customer found: ID=1, Calls=137, Last Call=2025-12-02 125435.401786 {"level": "INFO", "name": "app.services.customer_service", "message": "📊 Customer found: ID=1, Calls=137, Last Call=2025-12-02 125435.401786", "timestamp": "2025-12-02T073523.229305+00:00"} 2025-12-02 130523,297 - main - INFO - Returning customer: Customer-nown (ID: 1, 137 previous calls) {"level": "INFO", "name": "__main__", "message": "Returning customer: Customer-nown (ID: 1, 137 previous calls)", "timestamp": "2025-12-02T073523.297496+00:00"} 2025-12-02 130523,358 - app.services.customer_service - INFO - 📜 Retrieved 3 call history records for customer 1 {"level": "INFO", "name": "app.services.customer_service", "message": "📜 Retrieved 3 call history records for customer 1", "timestamp": "2025-12-02T073523.358507+00:00"} 2025-12-02 130523,412 - app.services.customer_service - INFO - ✅ Call session created: ID=138, Customer=1, Room=call-_+15183171307_jWagMRuEaD3w {"level": "INFO", "name": "app.services.customer_service", "message": "✅ Call session created: ID=138, Customer=1, Room=call-_+15183171307_jWagMRuEaD3w", "timestamp": " 2025-12-02T073523.412028+00:00"} 2025-12-02 130523,439 - main - INFO - Session ID: 138 {"level": "INFO", "name": "__main__", "message": "Session ID: 138", "timestamp": "2025-12-02T073523.439677+00:00"} 2025-12-02 130523,487 - app.services.queue_manager - INFO - Added to queue: 133 for customer 1 from unknown with priority 2 {"level": "INFO", "name": "app.services.queue_manager", "message": "Added to queue: 133 for customer 1 from unknown with priority 2", "timestamp": "2025-12-02T073523.487146+00:00"} 2025-12-02 130523,522 - main - INFO - Queue ID: 133 {"level": "INFO", "name": "__main__", "message": "Queue ID: 133", "timestamp": "2025-12-02T073523.522624+00:00"} 2025-12-02 130523,649 - main - INFO - OpenAI RealtimeModel created {"level": "INFO", "name": "__main__", "message": "OpenAI RealtimeModel created", "timestamp": "2025-12-02T073523.649730+00:00"} 2025-12-02 130523,805 - main - INFO - Built 1 function tools {"level": "INFO", "name": "__main__", "message": "Built 1 function tools", "timestamp": "2025-12-02T073523.805768+00:00"} 2025-12-02 130523,807 - main - INFO - Voice Agent created with tools {"level": "INFO", "name": "__main__", "message": "Voice Agent created with tools", "timestamp": "2025-12-02T073523.807769+00:00"} 2025-12-02 130523,808 - main - INFO - Event handlers configured {"level": "INFO", "name": "__main__", "message": "Event handlers configured", "timestamp": "2025-12-02T073523.808772+00:00"} 2025-12-02 130523,821 - livekit.agents - WARNING - RoomInputOptions and RoomOutputOptions are deprecated, use RoomOptions instead {"level": "WARNING", "name": "livekit.agents", "message": "RoomInputOptions and RoomOutputOptions are deprecated, use RoomOptions instead", "timestamp": "2025-12-02T073523.821033+00:00"} 2025-12-02 130524,051 - main - INFO - Agent session started and conversation completed {"level": "INFO", "name": "__main__", "message": "Agent session started and conversation completed", "timestamp": "2025-12-02T073524.051172+00:00"} 2025-12-02 130524,060 - app.services.customer_service - INFO - ✅ Session ended: ID=138, Duration=1s, Handled by=ai {"level": "INFO", "name": "app.services.customer_service", "message": "✅ Session ended: ID=138, Duration=1s, Handled by=ai", "timestamp": "2025-12-02T073524.060300+00 :00"} 2025-12-02 130524,115 - app.services.queue_manager - INFO - Marked queue entry 133 as completed {"level": "INFO", "name": "app.services.queue_manager", "message": "Marked queue entry 133 as completed", "timestamp": "2025-12-02T073524.115832+00:00"} 2025-12-02 130524,167 - main - INFO - Session 138 completed (resolved by AI) {"level": "INFO", "name": "__main__", "message": "Session 138 completed (resolved by AI)", "timestamp": "2025-12-02T073524.167526+00:00"} check my agentic code is okay ?
t
Thanks — I reviewed the latest logs and your question about whether the agent code is okay. Short answer: the agent is receiving jobs and connecting correctly, but there are three likely issues in your setup to fix so the agent actually speaks and runs the conversation. What the logs show • Agent receives JobContext and connects to room (room names like
call-_+15183171307_*
). • Sessions start then immediately complete (0–1s) with no published tracks visible. • Earlier OpenAI error for voice ("Nova") was present; later runs show no OpenAI error, so that specific failure appears resolved. What to check/fix (prioritize in this order) 1. Ensure the agent publishes audio output and subscribes to caller audio ◦ Confirm your agent code explicitly publishes an output audio track (TTS) to the room after job start, and subscribes/consumes the SIP participant’s published audio track. If no output track is published, callers hear nothing and session may immediately finish. 1. Verify initial prompt / conversation flow ◦ Add a short initial greeting or prompt the agent speaks on job start (e.g., “Hello, how can I help today?”). If your flow immediately considers the job completed without sending audio or waiting for user audio, it will exit fast. 1. Confirm OpenAI Realtime audio config ◦ Make sure the OpenAI RealtimeModel audio output voice is set to a supported value (one of: alloy, ash, ballad, coral, echo, sage, shimmer, verse, marin, cedar). Use that exact string in your agent config. ◦ Ensure the model is actually invoked to synthesize audio (check for successful TTS events in logs). Additional improvements • Replace deprecated RoomInputOptions/RoomOutputOptions with RoomOptions to avoid unexpected behavior in future releases (log shows a deprecation warning). • Verify codec/SDP: agent and caller must agree on codecs (Opus/PCMU/PCMA). If LiveKit shows 0 tracks for the SIP participant in Session analytics, the media negotiation failed. • Keep agent lifecycle open while waiting for audio: don’t auto-complete the job until you confirm audio exchanged or a silence timeout has elapsed. What to share if you want me to review code line-by-line • The agent startup snippet that creates the room connection and OpenAI RealtimeModel config (redact keys). • The part of code that handles JobContext and triggers TTS publishing. • Any TTS/audio publish calls and their parameters (voice name, sample rate, codecs). Which snippet would you like me to review first?
b
check the code now i use prefer not to attach a TTS plugin, use session.generate_reply(instructions="...") to have the Realtime model produce the reply content directly.
t
You’re right to call this out — using
session.generate_reply(...)
returns text only. That text is not automatically sent as audio into the LiveKit room, so a caller (MicroSIP or phone) will be silent unless you convert and publish audio. What to do next • After
session.generate_reply(...)
, convert the returned text to audio and publish it to the room as an output audio track. Options: ◦ Re-enable a TTS plugin that publishes audio for you. ◦ Use OpenAI Realtime TTS (ensure
session.audio.output.voice
is set to a supported voice) to synthesize audio and publish the track. ◦ Generate TTS yourself (any service) and publish the resulting PCM/Opus audio to LiveKit. Checklist to verify in your code • You call
session.generate_reply(...)
and capture the reply text. • You synthesize that text to audio (or use RealtimeModel TTS) and obtain an audio stream or file. • You publish the audio to the LiveKit room as an output track with compatible codec/sample rate. • You keep the job/session open until audio finishes playing or a silence timeout elapses. If you’d like, paste the job-handling snippet that calls
session.generate_reply(...)
(redact keys). I’ll show the minimal code changes to synthesize and publish audio back into the room.