Play a message instead of dead air when the AI can't take a call #80

Merged
Patrick merged 3 commits from patrick/ai-failure-fallback into main 2026-11-10 02:49:19 -05:00 AGit
Owner

Callers no longer get dead air when the AI can't help. They hear "We're sorry, we're having trouble connecting your call right now. Please try calling back in a few minutes. Goodbye." and the call ends.

Covered failures

Failure Before After
Worker can't load its persona (Orbital down, none configured) 120s silence message, hang up
Session can't start (bad provider key, etc.) silence message, hang up
LLM / speech / voice fails mid-call past retries silence message, hang up
Asterisk can't reach the AI call drops message, hang up

How

  • Worker: fallback.py sends the caller to Asterisk's ai-unavailable extension with a SIP REFER, the same mechanism the operator handoff uses. If the REFER fails, it deletes the room so the call ends rather than going silent.
  • Faster failure: LLM and TTS retry once with an 8s timeout, and the first unrecoverable error triggers the fallback. The old defaults meant up to minutes of silence.
  • Asterisk: [orbital-ai-unavailable] plays the rendered message, else the stock prompts "Sorry. Please try your call again later. Goodbye." (confirmed present in the asterisk image), then hangs up. Every Dial to the AI falls through to it if it doesn't connect.
  • The message: editable in Platform Settings → When the AI Can't Take a Call (wording, provider, voice). It's rendered with the platform's TTS as 8 kHz signed linear, and re-rendered only when it changes: on save, and every 15 minutes, which also retries a failed render.

Not covered: no worker running at all, since nothing is there to send the REFER. The worker-down alert is the answer there.

Also stops tracking agent-worker/__pycache__/*.pyc, a separate commit.

Tests: 8 new; the full suite has 492 passed, 8 skipped. The worker fallback was exercised with a fake job context: REFER sent, a failed REFER hangs up, an absent caller hangs up, a repeat trigger is ignored.

🤖 Generated with Claude Code

Callers no longer get dead air when the AI can't help. They hear "We're sorry, we're having trouble connecting your call right now. Please try calling back in a few minutes. Goodbye." and the call ends. **Covered failures** | Failure | Before | After | |---|---|---| | Worker can't load its persona (Orbital down, none configured) | 120s silence | message, hang up | | Session can't start (bad provider key, etc.) | silence | message, hang up | | LLM / speech / voice fails mid-call past retries | silence | message, hang up | | Asterisk can't reach the AI | call drops | message, hang up | **How** - **Worker:** `fallback.py` sends the caller to Asterisk's `ai-unavailable` extension with a SIP REFER, the same mechanism the operator handoff uses. If the REFER fails, it deletes the room so the call ends rather than going silent. - **Faster failure:** LLM and TTS retry once with an 8s timeout, and the first unrecoverable error triggers the fallback. The old defaults meant up to minutes of silence. - **Asterisk:** `[orbital-ai-unavailable]` plays the rendered message, else the stock prompts "Sorry. Please try your call again later. Goodbye." (confirmed present in the asterisk image), then hangs up. Every Dial to the AI falls through to it if it doesn't connect. - **The message:** editable in Platform Settings → When the AI Can't Take a Call (wording, provider, voice). It's rendered with the platform's TTS as 8 kHz signed linear, and re-rendered only when it changes: on save, and every 15 minutes, which also retries a failed render. **Not covered:** no worker running at all, since nothing is there to send the REFER. The worker-down alert is the answer there. Also stops tracking `agent-worker/__pycache__/*.pyc`, a separate commit. **Tests:** 8 new; the full suite has 492 passed, 8 skipped. The worker fallback was exercised with a fake job context: REFER sent, a failed REFER hangs up, an absent caller hangs up, a repeat trigger is ignored. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
When the worker couldn't load its persona, a provider failed past its
retries, or Asterisk couldn't reach the AI, the caller sat in silence
until the 120s media timeout. Now they hear "we're having trouble,
please call back" and the call ends.

- Worker (fallback.py): any failure to start the call, and a session
  that closes on error, REFERs the caller to Asterisk's ai-unavailable
  extension. If the REFER fails too, the room is deleted so the call
  ends rather than going silent. LLM and TTS now retry once with an 8s
  timeout, and the first unrecoverable error triggers the fallback
  (the default 3 x 3 retries meant minutes of silence).
- Asterisk: [orbital-ai-unavailable] plays the rendered message, or the
  stock "Sorry. Please try your call again later. Goodbye." until one
  exists, then hangs up. Every Dial to the AI that doesn't connect falls
  through to it.
- The message (Platform Settings: When the AI Can't Take a Call) is
  rendered ahead of time with the platform's TTS, as 8 kHz signed linear
  (Asterisk's .wav reader rejects TTS services' 16/24 kHz audio), and
  re-rendered only when the wording or voice changes: on settings save,
  and every 15 minutes, which retries a failed render.

Still uncovered: no worker running at all (nothing to send the REFER);
monitoring's worker-down alert is the answer there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Stop tracking the agent worker's Python bytecode
Some checks failed
Application Tests / frontend (pull_request) Successful in 29s
Application Tests / php (pull_request) Failing after 4m16s
Application Tests / security-audit (pull_request) Successful in 8m59s
Application Tests / tag (pull_request) Has been skipped
Application Tests / publish-images (., Dockerfile, laravel) (pull_request) Has been skipped
Application Tests / publish-images (agent-worker, Dockerfile, agent-worker) (pull_request) Has been skipped
Application Tests / publish-images (docker/asterisk, Dockerfile, asterisk) (pull_request) Has been skipped
Application Tests / publish-images (docker/asterisk-config-sync, Dockerfile, asterisk-config-sync) (pull_request) Has been skipped
Application Tests / publish-images (docker/haraka, Dockerfile, haraka) (pull_request) Has been skipped
Application Tests / publish-images (docker/whisper-local, Dockerfile, whisper-local) (pull_request) Has been skipped
Application Tests / scan-images (agent-worker) (pull_request) Has been skipped
Application Tests / scan-images (asterisk) (pull_request) Has been skipped
Application Tests / scan-images (asterisk-config-sync) (pull_request) Has been skipped
Application Tests / scan-images (haraka) (pull_request) Has been skipped
Application Tests / scan-images (laravel) (pull_request) Has been skipped
Application Tests / scan-images (whisper-local) (pull_request) Has been skipped
Application Tests / publish-helm (pull_request) Has been skipped
Application Tests / publish-archives (pull_request) Has been skipped
cd35d42086
Compiled .pyc files were committed under agent-worker/__pycache__ and
changed whenever the worker was run locally.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Don't let a broken prompts disk fail a Platform Settings save
All checks were successful
Application Tests / frontend (pull_request) Successful in 24s
Application Tests / security-audit (pull_request) Successful in 13m48s
Application Tests / php (pull_request) Successful in 24m58s
Application Tests / tag (pull_request) Has been skipped
Application Tests / publish-images (docker/whisper-local, Dockerfile, whisper-local) (pull_request) Has been skipped
Application Tests / publish-images (., Dockerfile, laravel) (pull_request) Has been skipped
Application Tests / publish-images (agent-worker, Dockerfile, agent-worker) (pull_request) Has been skipped
Application Tests / publish-images (docker/asterisk, Dockerfile, asterisk) (pull_request) Has been skipped
Application Tests / publish-images (docker/asterisk-config-sync, Dockerfile, asterisk-config-sync) (pull_request) Has been skipped
Application Tests / publish-images (docker/haraka, Dockerfile, haraka) (pull_request) Has been skipped
Application Tests / scan-images (agent-worker) (pull_request) Has been skipped
Application Tests / scan-images (asterisk) (pull_request) Has been skipped
Application Tests / scan-images (asterisk-config-sync) (pull_request) Has been skipped
Application Tests / scan-images (haraka) (pull_request) Has been skipped
Application Tests / scan-images (laravel) (pull_request) Has been skipped
Application Tests / scan-images (whisper-local) (pull_request) Has been skipped
Application Tests / publish-helm (pull_request) Has been skipped
Application Tests / publish-archives (pull_request) Has been skipped
168e12bafc
CI failed four Platform Settings tests: saving runs the AI-unavailable
render (inline on the sync queue), and the prompts disk's root
(/var/spool/asterisk/prompts) can't be created there. The same would
break a save on any install with an unusable prompts disk.

The render now reports failure instead of throwing (Asterisk keeps its
stock prompts), and the settings tests use a fake prompts disk.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
calltheory/orbital!80
No description provided.