The End Call function (type: "end_call") lets the LLM hang up. Add it to almost every agent: without it, the call only ends when the caller hangs up, the silence timeout fires or the maximum duration is reached.
When the agent uses it#
The LLM calls end_call when the description tells it to. The dashboard pre-fills the description "End the call when the user has nothing else to discuss." If you leave the description empty, the worker uses "End the call. Say goodbye before calling this."
Typical description rules:
- "End the call after you have confirmed the booking and the caller has no other questions."
- "End the call if the caller asks you to stop calling, after confirming you will remove their number."
What happens when it runs#
Finish speaking#
The worker waits for anything the agent is still saying to play out.
Goodbye if needed#
If the agent has not spoken since the caller's last turn, it says "Thanks for calling. Goodbye!" and waits for that to finish. If the agent already said goodbye in the same turn, nothing extra is spoken.
Hang up#
The call ends with disconnection_reason: "agent_hangup". The LLM is not asked for another reply.
The While it runs options are hidden for End Call: there is no execution message and no reply after it runs.
Configure in the dashboard#
- Open the agent and expand Functions.
- Click Add and choose End Call.
- Set Name and Description.
- Optional: add Custom SIP headers on hang-up.
- Click Save.
Fields#
| Field | Type | Required | Description |
|---|---|---|---|
type |
"end_call" |
Yes | |
name |
string | Yes | ^[a-zA-Z0-9_-]{1,64}$ |
description |
string | No | When to hang up. Default "" |
custom_sip_headers |
object of string to string | No | Headers added to the SIP BYE. Values can use {{variables}} |
{
"type": "end_call",
"name": "end_call",
"description": "End the call once the caller confirms they have nothing else to ask.",
"custom_sip_headers": { "X-Disposition": "{{outcome}}" }
}Custom SIP headers on hang-up#
Needs keys BYE headers need LiveKit SIP and a real trunk.
Custom SIP headers on hang-up puts headers on the SIP BYE, for example a disposition code your PBX or contact centre reads. Values are rendered with dynamic variables at hang-up time, so you can send values the agent collected during the call.
Only header names that the SIP trunk maps can reach the wire. The API provisions trunks with the names in the BYE_HEADER_NAMES environment variable, which defaults to:
X-DispositionX-Call-OutcomeX-Transfer-ReasonX-Tried-Call-Id
Headers with other names are ignored. Web calls have no BYE.
End nodes in flows#
Conversation flows usually end with an end node instead of an end_call tool. The end node speaks its instruction and hangs up when the flow reaches it. In flex mode, end nodes are compiled into an end_call tool.
Gotchas#
- Give the agent an explicit rule for when to hang up. A vague description makes the model end calls early or never.
end_callis offered on every turn of a single prompt agent. In multi-prompt agents, put it ingeneral_toolsor in the states where ending is allowed.- Hanging up is final. If you want a last confirmation, ask for it in the prompt before the rule that calls
end_call.