bulky-byte-27418
04/03/2026, 12:07 PMtall-airline-16756
04/03/2026, 12:07 PMtall-airline-16756
04/03/2026, 12:07 PMmax_call_duration and want to know why. Below are the most common reasons this happens and quick checks you can run to narrow it down.
Likely causes (and what to check)
• Inactivity / user-away timeout
◦ Reason: The agent may mark the participant as “away” after a short inactivity window and then shut down the session.
◦ Check: Look for a user_away_timeout or similar setting in your AgentSession/config. Verify its value and any background task that marks users as away.
• Voice / silence detection logic
◦ Reason: A background task may detect no speech for a threshold (e.g., 5–10s) and disconnect callers (used for voicemail or to drop unresponsive calls).
◦ Check: Search your agent logic for “silence”, “no speech”, “speech detection”, or timers that trigger disconnects. Inspect any VAD (voice activity detection) settings.
• Explicit end-call tool or API call from the agent
◦ Reason: The agent can call an EndCallTool or directly invoke end_call / session.shutdown() when it decides the call is complete.
◦ Check: Look for calls to end_call, EndCallTool, session.shutdown(), or any LLM tool invocation that would terminate the session. Review the conditions that lead to those calls.
• Error or exception in the agent runtime
◦ Reason: Unhandled or fatal errors (e.g., inference API failures) can trigger session shutdown as part of error handling.
◦ Check: Inspect agent logs around the time of the disconnect for exceptions, stack traces, or retries. Look for repeated errors just before the call ends.
• Greeting / retry logic reaching a limit
◦ Reason: If the agent attempts greeting/verification a few times and fails, it may end the session early by design.
◦ Check: Review any greeting or retry counters and the logic that decides to abort after N failed attempts.
Next diagnostic steps I recommend
1. Check agent logs for the exact timestamp of the disconnect. Look for messages mentioning “shutdown”, “end_call”, “away”, “silence”, or any errors.
2. Correlate the disconnect time with any detection thresholds (user_away_timeout, silence threshold, greeting attempts).
3. Temporarily disable or lengthen inactivity/silence timeouts and see if the early terminations stop.
4. If the agent uses LLM tools, add logging around tool invocations so you can see whether EndCallTool (or similar) was triggered.
5. Reproduce in a controlled test with verbose logging enabled so you can capture the sequence that leads to the hang-up.
If you’d like, tell me:
• the names/values of any timeouts you see (user_away_timeout, silence thresholds, greeting retry limits),
• whether you see any `end_call`/`session.shutdown()` calls in logs, and
• one or two log snippets around a disconnect timestamp.
With that I can help pinpoint which logic is ending the call and suggest precise fixes.
Sources: How to implement call greeting retries in voice agents | LiveKit | examples/frontdesk | livekit/livekit_composite | DeepWiki | examples/voice_agents | livekit/livekit_composite | DeepWiki | Agents Framework | livekit/livekit_composite | DeepWiki | EndCallTool | LiveKit Documentation, with interactive elementsbulky-byte-27418
04/03/2026, 12:11 PMtall-airline-16756
04/03/2026, 12:12 PMend_call only when user requests it or process is done, you set max_call_duration = 10 minutes, user_away_timeout = 30s, but calls still end early (5–9 minutes) while the user is speaking and there’s no explicit end_call trace. Let’s narrow this down and find the root cause.
Quick summary of most likely causes given what you shared
• Some part of the agent runtime is still invoking end_call (or session.shutdown()) indirectly — for example an LLM tool, a background task, or error handling — even though you don’t see a direct user-triggered call.
• A silence / VAD detection component may be mis-detecting speech (false negatives) and triggering shutdown logic that calls end_call.
• An intermittent error (e.g., inference API timeout or other exception) may be hitting error-handling code that calls end_call.
• A retry/limit in the greeting or other flow could be reached at different durations depending on conversation events and cause an early shutdown.
Targeted diagnostics to run (in order)
1. Capture verbose logs around a disconnect event
◦ Include timestamps, full stack traces, and all log lines that mention end_call, session.shutdown, EndCallTool, error, exception, away, silence, and any VAD or speech-detection components.
◦ Ensure logs show which code path invoked end_call (caller function / stack trace) so you can see whether it was user code, an LLM tool, or error handling.
1. Add instrumentation around end_call to log the call source and context
◦ Before end_call executes, log: caller stack trace, value of any flags/conditions (e.g., user_state, last_speech_timestamp, greeting_attempts), and recent events (last 30s of detected speech events).
◦ If you can’t modify end_call directly, wrap it with a small wrapper that logs this metadata then calls the real function.
1. Verify VAD / silence detection behavior
◦ Log raw VAD/speech-detection decisions (speech vs silence) with timestamps. Confirm that speech is actually being detected when the user is talking.
◦ Temporarily relax or disable silence thresholds to confirm whether mis-detected silence is the cause.
1. Check for LLM/tool-driven shutdowns
◦ If the agent uses tools (like an EndCallTool) or LLM reasoning that can call tools, add logging for tool invocations and model outputs right before any shutdown. The model may be deciding to end the call.
1. Correlate external API calls / errors
◦ Look for inference API timeouts, rate-limit responses, or other transient errors in the logs just before shutdown. Add retries or more robust error handling if shutdown is triggered by an error path.
1. Reproduce with verbose tracing in a controlled test
◦ Create a short test call where the user speaks continuously and you reproduce the scenario while recording all logs and events. This will expose race conditions or intermittent checks (e.g., a background task reading outdated timestamps).
What I can help you run/check next
• If you can share a log snippet showing the 30–60 seconds before an early disconnect (redact any sensitive content), I’ll read it and point to the exact place that triggered end_call.
• If you prefer to instrument first, I can provide a minimal wrapper snippet to add around end_call that captures caller stack and last-events log. Tell me the language/runtime you’re using and I’ll draft it.
Short checklist to try immediately
• Add logging/wrapper around end_call to capture caller stack.
• Log VAD outputs and temporarily disable silence-based disconnects.
• Search logs for exceptions or tool invocations that precede the shutdown.
• Run an isolated test with continuous speech and verbose logs.
If you send one recent log snippet (the last 60–90s before the hang-up) or tell me your runtime language, I’ll give an exact wrapper snippet and show what lines to look for to identify the source of end_call.
, with interactive elements