https://retellai.com/?utm_source=discord&utm_medium=seo logo
In the Retell agent architecture, who owns the tim...
# ❓・ai-evy-support
c
@AI Evy In the Retell agent architecture, who owns the timing of tool execution after the LLM generates a response? For example, if the model says it will transfer a caller but the transfer tool is not invoked immediately, is there a way for our backend to detect that delay and intervene (inject speech or execute the transfer)? We're trying to prevent dead air during tool latency and are looking for a way to implement a timeout/watchdog pattern around transfers. Is this supported via: • Custom LLM WebSocket mode • Agent reminder/response events • Or some other mechanism?
a
Thanks for tagging me @Codyx. I'll look through relevant sources and get back to you shortly.
### Answer In Custom LLM WebSocket mode, your backend owns the timing of tool execution after the LLM generates a response. Retell sends events to your server, and you control when and how to respond—including executing tools and sending speech content. [(1) ]() [(2) ]() ## Detecting Delays and Intervening Yes, you can implement a timeout/watchdog pattern. Here's how: 1. Agent Interrupt Event If you detect a delay (e.g., tool latency) , you can proactively inject speech using the
agent_interrupt
event: [(1) ]()
Copy code
json
{
  "response_type": "agent_interrupt",
  "interrupt_id": 1,
  "content": "One moment while I transfer you...",
  "content_complete": true,
  "no_interruption_allowed": true
}
This immediately interrupts both agent and user to speak content, preventing dead air during tool execution. 2. Turntaking Events The
update_only
events include a
turntaking
field that indicates when speaker changes occur (
agent_turn
or
user_turn
) . This field can be helpful for determining when to call functions in the call. 3. Transfer Execution When ready to execute the transfer, include
transfer_number
in your response event:
Copy code
json
{
  "response_type": "response",
  "response_id": 5,
  "content": "Transferring you now.",
  "content_complete": true,
  "transfer_number": "+12137771234"
}
## Implementing a Watchdog Pattern Your backend can: 1. Track when the LLM decides to transfer (from your own logic) 2. Start a timer 3. If the transfer hasn't completed within your threshold, send an
agent_interrupt
with filler speech or force the transfer via a response event Note: The
reminder_trigger_ms
and
reminder_max_count
parameters exist but are designed for when the user is silent, not for tool execution delays. [(3) ]()
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
​ To learn more, see the sources I considered: [[1] LLM WebSocket](https://docs.retellai.com/api-references/llm-websocket) [[2] Custom LLM Overview](https://docs.retellai.com/integrate-llm/overview) [[3] [CRITICAL] Inbound calls have dead air due to LLM timeout(Failed to get response from any LLM provider – Operation timed out )](https://community.retellai.com/t/critical-inbound-calls-have-dead-air-due-to-llm-timeout-failed-to-get-response-from-any-llm-provider-operation-timed-out/722) ​
c
@SaintDilly read the above
@mastrproductions