A caller disconnecting ends their participation, but it does not establish whether an appointment or customer update completed. Treat conversation lifecycle and business-action lifecycle as separate state machines.
LiveKit's job-lifecycle documentation describes job termination and shutdown hooks for cleanup. Hooks are bounded execution opportunities, not a durable guarantee that every external operation will finish. Persist consequential work before relying on end-of-session processing.
Decide what may continue after hangup
For each action, define whether it should be cancelled before commitment, continue if already authorized, or require human review. The decision depends on business meaning. A pending availability lookup differs from a booking request that may already have reached the destination.
Store request identity, authorized scope, current action status, remote identifier when available, and follow-up owner outside the session process. Mark explicit rejection, confirmed completion, and unknown outcome differently.
Rehearse a fictional booking disconnect
A caller agrees to a visit and hangs up while the calendar request is in flight. The application has already persisted the booking intent. The remote response is lost during session shutdown.
The action becomes uncertain. A recovery worker or operator checks the destination under the approved reconciliation policy before another create request. The final record can show that the call ended while the customer commitment still needed resolution.
| Disconnect point | Expected behavior |
|---|---|
| Before action authorization | No abandoned request committed |
| After durable intent, before submission | Approved continuation or cancellation policy |
| During remote write | Unknown outcome reconciled |
| After verified remote success | Confirmed action retained |
| During cleanup failure | Durable recovery item remains |
Keep cleanup small and observable
Use shutdown processing for bounded finalization and references to already-persisted work. Avoid placing the only copy of a customer's request in a final summary that may never be written after abrupt failure.
Persisting early adds storage and requires cleanup of abandoned intents. Persisting only at hangup is simpler but risks losing the request. A small action ledger can preserve the important evidence without retaining every conversation detail indefinitely.
Test normal hangup, sudden connection loss, process termination, and a deliberately slow destination. Verify the actual action outcome rather than assuming a clean session close means success. Review uncertain remote writes for recovery mechanics.
Questions about disconnect handling
Should every backend task stop immediately?
Use an explicit business policy. Stopping a task locally may not undo a remote operation already accepted.
Can cleanup promise a customer callback?
Only if the callback request is durably recorded, owned, and supported by the operating process.
What should operators see?
The disconnect time, authorized action, last verified state, remote evidence, uncertainty, and next owner. Keep a completed call distinct from completed customer work.