Skip to content

feat(phone): GAIA texts or calls you for urgent alerts - #6790

Draft
kovtcharov wants to merge 90 commits into
amd:mainfrom
kovtcharov:kalin/phone-alerts
Draft

kovtcharov wants to merge 90 commits into
amd:mainfrom
kovtcharov:kalin/phone-alerts

Conversation

@kovtcharov

@kovtcharov kovtcharov commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

A notification is easy to miss. GAIA can now text or call your phone when something urgent happens: a scheduled job fails, a task waits on your approval, GAIA's model server won't start, or an agent you allowed needs you. It only ever reaches numbers in a phone book verified by a code. Calls and texts say a fixed sentence per alert type, never task, email or agent text, so injected content can't speak through GAIA and voicemail holds nothing private.

Design: docs/plans/phone-calls.mdx (#6491), reviewed twice before the build and once after. Stacked on #6789 (voice). Until that merges, this diff includes it.

  • Twilio, no public URL. Calls carry their script inline, and outcomes are read by polling. Answering-machine detection means voicemail doesn't count as reaching you. A Simulated phone lets you try every screen and rule before signing up.
  • The phone book is the security boundary. Every send reads the number from the phone book by id. Adding a second number also needs a code from the first, and changes are announced by a call. Numbers added under the Simulated phone are dropped when Twilio is set up. Emergency, short, premium and satellite numbers are refused.
  • Escalation you control: notify, text, call, redial, then the next number. Daily limits, a separate limit for agent alerts, cooldown merging and quiet hours. State persists, so a restart neither drops nor repeats a call. The PC is kept awake (not the display) on AC power while phone is on.
  • Talk with GAIA on the call, or call her. While mobile access is on, the call connects to the PC after the alert sentence. Enter your PIN on the keypad, then talk with GAIA: the same agent, tools and memory as a chat, through the same relay, with approvals by voice ("yes"/"no") or keypad (1/2). You can also call GAIA's number from a phone-book number. She points the Twilio number at the PC herself, checks Twilio's signature, and still asks for the PIN. Her voice is Kokoro "af_nicole", a younger female voice, and can be changed.
  • Both apps: Settings › Phone and an open-alert banner in the Agent UI (changes refused over mobile access), /phone and a banner in the TUI, each with PIN, voice and a "can calls talk?" status.

Test plan

  • pytest tests/unit/phone tests/unit/agents/test_alert_tools.py tests/unit/chat/ui/test_phone_router.py tests/unit/chat/ui/test_approval_alerts.py tests/unit/test_schedule_daemon.py
  • cd src/gaia/apps/webui && npm test && npm run test:rtl (phone scenes); cd tui && go test ./...
  • Simulated: Settings › Phone → Use the Simulated phone → add your number (the code is in the Simulated log) → turn on → Send test alert → the alert shows a text then an answered call
  • Twilio trial: follow docs/guides/phone-alerts.mdx, verify your number in Twilio and in GAIA, Send test alert, and your phone rings with the trial notice, then GAIA's sentence
  • With mobile access on and a PIN set: answer the test alert, enter the PIN, ask "how much space is left on my drive?", approve the command by saying "yes"; the call appears as a "Phone call" chat
  • Call GAIA's Twilio number from your phone: PIN, then talk; call from another number: rejected
  • Try to add 911, a +1 900 number, or a second number without the first number's code: all refused
🔍 Technical details
  • gaia.phone lives in the daemon (/daemon/v1/phone/*, client token). Agents use /host/v1/alerts with their own custody secret, and the alert_owner tool is registered only when "Agents may alert me" is on. The UI server is a pass-through that requires the PC for changes and for the Simulated log, which holds live codes.
  • Sources: schedule failures (gaia schedule hook), approval cards unanswered for N minutes (UI server watch), the embedded Lemonade failing to start for 5 minutes (owner health hook), and alert_owner.
  • The post-build review fixed: simulated numbers kept after switching to Twilio, a text-only rule placing a call after an unconfirmed text, and a non-phone exception stopping the loop. Also concurrent raises opening two alerts, a health alert surviving a restart, call-limit holds never retrying, and the Linux sleep inhibitor outliving a killed daemon.
  • Tests can't reach a running daemon: tests/conftest.py stubs gaia.phone.client.
  • Not verified against a real Twilio account; that needs your sign-up (see the test plan).

huong8373tt-beep and others added 30 commits October 31, 2026 16:49
Adding Kokoro to the talk profile also put it in `gaia init --profile all`,
whose model check sent every non-embedding model a chat request, so a clean
install reported the voice model as broken. Init now recognises TTS models
from the model registry, checks them by synthesizing one word, and labels
them "speech" in `gaia init --check --load`.

The docs now say to run `gaia download --agent talk` before asking the agent
to read aloud, since the tool no longer downloads Kokoro itself.
Replies can now be heard: a speaker button on each Agent UI reply and
/read-aloud in the TUI speak them through Lemonade's Kokoro voice, in a
voice, speed and auto-read choice both apps share via ~/.gaia/config.json.

- Backend: GET/PUT /api/speech/settings and POST /api/speech (WAV), with
  503/502/422 that say what failed; read_aloud_voice/speed/auto config
  keys validated by gaia config.
- Agent UI: per-reply button, Settings > Read aloud (voices grouped by
  accent and gender, Preview, speed, auto-read), markdown stripped and
  long replies spoken in pieces with the next fetched ahead.
- TUI: /read-aloud and /voice, playback through the OS player, voice
  list embedded and pinned to KOKORO_VOICES by a drift test.
A fetch still running after Speak returned read the package-level
folder while a test reset it, which the race detector caught on Linux
and macOS CI.
…h tool

Merges amd#6204 (the flagship text_to_speech tool) under read-aloud so GAIA
has one way to make speech: the same Lemonade client, voice list and
speed range, and the voice and speed the user picks for reading aloud.

- text_to_speech now defaults to read_aloud_voice and read_aloud_speed
  from ~/.gaia/config.json when the request names neither.
- Its speed bounds come from READ_ALOUD_MIN_SPEED/MAX_SPEED, the range
  the settings already enforce.
The speed menu's "Normal" carried the bracketed English hint, which an
<option> can't style and which scrambles in rtl; option text now uses
t.bare. The error detail used dir="auto", which pushed English 210px off
the row's edge in Arabic; it is a <bdi> now. The rtl audit gains a rule
for <option> text so the first can't come back.
# Conflicts:
#	hub/agents/gaia/npm/CHANGELOG.md
#	hub/agents/gaia/python/gaia_agent/chat_agent.py
#	hub/agents/gaia/python/tests/test_chat_tts_tool.py
#	src/gaia/audio/lemonade_tts.py
Main's new Settings layout came with fresh reference screenshots that predate
this branch's Read aloud section in the sidebar.
# Conflicts:
#	src/gaia/apps/webui/src/components/ChatView.tsx
#	src/gaia/apps/webui/src/components/settings/SettingsDialog.css
#	src/gaia/apps/webui/src/components/settings/SettingsDialog.tsx
#	src/gaia/apps/webui/visual/__screenshots__/settings-general-dark-win32.png
#	src/gaia/apps/webui/visual/__screenshots__/settings-general-light-win32.png
# Conflicts:
#	hub/agents/gaia/npm/CHANGELOG.md
# Conflicts:
#	src/gaia/apps/webui/src/components/ChatView.tsx
# Conflicts:
#	hub/agents/gaia/python/tests/test_chat_tts_tool.py
# Conflicts:
#	src/gaia/apps/webui/src/components/ChatView.tsx
…ntract

GAIA could speak replies but not listen. This adds the server half of
dictation and voice mode: a session that streams the microphone to
Lemonade's realtime recognizer, plays a chime when you stop talking, speaks
the text the app hands it clause by clause, and drops queued speech the
moment you interrupt.

- gaia.voice: realtime listener, clause chunker, <spoken> splitter, PCM and
  G.711 helpers, the host-agnostic socket protocol. Refuses a remote Lemonade.
- Agent UI server: GET /api/voice/status, POST /api/voice/models/download
  (voice models only), WS /api/voice/session with host, origin and
  mobile-access token checks.
- Voice turns go through the normal chat path with reply_style "voice". The
  flagship (API 2.28) adds a per-turn note asking for a short <spoken> summary
  and status lines. An older flagship gets a clear "update GAIA" error.
- Validated voice_* config keys.
The Agent UI and TUI each split <spoken> out of the answer stream, so one
JSON case file now pins the behaviour all three parsers must match,
including the reset when a tool step starts.
…hesis

Tested against a real Lemonade 2026.44.1. Its realtime endpoint never loads
a model, so the first dictation failed with "No model loaded". The listener
now loads the recognizer first, as Lemonade's own example does.

Kokoro takes 0.4-0.8 s per clause here, and streaming doesn't help: the first
byte arrives only when the clause is done. So the next clause is now
synthesized while the current one plays, and a real-time speaker never waits
between clauses.

Adds an integration test against a real Lemonade, run when
GAIA_VOICE_TEST_LEMONADE is set. Kokoro speaks a sentence and the
recognizer hears it back, starting from a recognizer that isn't downloaded.
Voice turns had no eval. The Agent UI MCP's send_message takes
reply_style, and three scenarios check that a voice turn opens with a short
plain spoken summary, narrates tool steps honestly, and says a failure out
loud. They run in the gaia-signal lane on the next RC.

The flagship's README, SPEC, SKILL, CHANGELOG and OpenAPI artifact now
describe reply_style (contract 2.28) and alert_owner.
The TUI could read replies aloud but not listen. Ctrl+R (or /dictate) now
dictates into the composer, and /talk opens a hands-free voice mode with a
shimmering state line, a level meter, captions and the work log. The GAIA
daemon records the microphone and plays speech, so the Go build stays free of
cgo and audio libraries.

- Daemon: /daemon/v1/voice/{status,devices,models/download,session} behind
  the client token. Capture pauses while speech plays, since the daemon has
  no echo cancellation (amd#3494), and any key interrupts. A missing,
  denied or busy mic is a stable error code with a message. Without
  `websockets` the routes say so instead of 404ing. The [api] extra gains
  websockets and sounddevice.
- TUI: a voice turn goes through the chat's normal query path with
  reply_style "voice" (flagship 2.28+, refused before voice mode opens on an
  older one). The Go splitter passes the shared spoken-split cases. Spoken
  summaries show as a bold lead line in the history. Push-to-talk is Space to
  start and Space to send, because terminals don't report key release.
- Adds github.com/coder/websocket (ISC, pure Go).
- Lint fixes in gaia.voice, and the live-Lemonade voice test is allowlisted
  for CI lanes with its reason.
The Agent UI could read replies aloud but not listen. A mic button now
dictates into the composer, with live partials in the box, and when the box
is empty the send button opens voice mode. Voice mode is a hands-free screen
with a listening ring and a speaking glow that follow the live audio, a
shimmering state word, captions, and a "What GAIA did" work log. Voice turns
are ordinary chat messages sent with reply_style "voice", so they are saved,
shown and stopped like typed ones. The spoken summary appears as a bold lead
line in the history.

- Barge-in flushes playback locally first. Permission cards show inside voice
  mode, and GAIA says it needs your OK. Arabic answers on screen with
  captions, since speech is English-only for now.
- Phone (mobile access): full-screen layout, tap to start audio, wake lock,
  pause when hidden, iOS play-and-record.
- Settings › Voice: listening and voice-mode groups next to read-aloud's
  speaking controls.
- Electron grants the microphone to the app's own page only. The macOS build
  gets the audio-input entitlement and usage text.
- Exports and search snippets show the spoken summary as text, without tags.
- Never uses the browser's SpeechRecognition or speechSynthesis; a test fails
  the build if the source mentions them.
…ession

Review fixes. After the 5-minute dictation limit, every mic frame sent another
limit event and commit. A TUI voice session whose send queue filled said it
was closed but stayed open. The voice routes now use GAIA's logger.
…mulator

GAIA can now reach you by text or phone call when something urgent happens,
and only ever at numbers you verified. The daemon owns it, so alerts fire
whether or not an app is open.

- gaia.phone: phone book with 6-digit codes (hashed, 10 min, 3 tries, 3 an
  hour). A second number also needs a code from the first, and every change is
  announced. One send path reads numbers from the phone book by id. Refuses
  emergency, short, premium and satellite numbers.
- Calls and texts say a fixed sentence per alert type, never task or agent
  text. Voicemail doesn't count as reached (answering-machine detection).
- Escalation: notify, text, call, redial, then the next number. Cooldown
  merging, daily limits, a separate limit for agent alerts, quiet hours. State
  lives in SQLite, so a restart resumes without calling twice.
- Providers: Twilio REST (inline TwiML, status by polling, no public URL) and
  a Simulated provider for trying everything before signing up.
- Sources: failed schedules, approval cards left waiting, GAIA's model server
  failing for 5 minutes, and an alert_owner tool registered only when agent
  alerts are on.
- Daemon: /daemon/v1/phone/* behind the client token, and /host/v1/alerts
  behind each agent's own custody secret.
- Tests never reach a running daemon, so no test can ring a real phone.
Settings › Phone in the Agent UI reaches the daemon through the UI server.
Changes are refused over mobile access, so who GAIA may call can only be
changed at the PC; opening an alert from the phone still stops the calls.
A sleeping PC can't call, so phone alerts now hold the system (not the
display) awake on AC power: SetThreadExecutionState on Windows,
systemd-inhibit on Linux, caffeinate on macOS. The hold is released on
battery and when phone is off. Adds the Phone Alerts guide, with Twilio setup
and its trial limits.
Phone alerts are set up and watched from the terminal too. /phone covers the
provider (Simulated phone or Twilio, with the token masked and cleared after
submit), the phone book with its code checks, each alert rule, quiet hours,
limits and keep-awake. It also shows the alerts with every call and text. An
open alert shows a one-line banner in the chat, polled every 15 s, that stops
quietly against a daemon without phone routes.
Turning phone on showed "not keeping the PC awake" for up to a minute,
because the hold was only checked once a minute.
…nd wake word

Asked to change her voice she could only make a sample file. A new tool,
set_voice_setting, saves one of five voice settings and refuses any other,
pointing the user to Settings. Voice mode re-reads the settings when a tool
finishes, so the change is heard in the same reply. Volume moves from the
browser's storage into the saved voice settings so she can set it too.
…ice, and count the new tool

The flagship now registers 106 tools; the manifests, capability matrix, guide
and skill playbook say so. The voice eval category added earlier is in the
matrix's expected list. Voice tests share one fixture through a conftest.
…picture row

The voice screen's tests stubbed the controller without the new mute and
volume functions, so every case in the file failed. The volume slider gets its
own accessible name.
Whisper wrote the wake phrase as "Hegaya", which the name match missed, so
the request was dropped.
…he chime is a setting

Speech reaches the browser faster than it plays, so the server thought GAIA
had finished while the room still heard her: talking over her started a new
turn but her old answer kept playing, and the new one queued behind it. The
app now tells the server while playback lasts, and a new request always cuts
the end of the last answer. The "heard you" tone is a setting (on by default)
that GAIA can change too. Speech ignored while waiting for her name now says
so, and the follow-up window is 20 seconds.
…" ends it

Follow-ups needed her name again after twenty seconds. The wake word is for
when it has been quiet: the window is now a minute after she last spoke, and
"GAIA, go to sleep", "good night" or "that's all" sends her back to
waiting for her name at once, whether or not the phrase names her.
kovtcharov-amd added a commit to kovtcharov/gaia that referenced this pull request Nov 12, 2026
**This is the design the voice and phone work builds on** (amd#6789,
amd#6790). The plans ship no code, and they don't block or change current
release work.

GAIA can read a reply aloud, but neither the Agent UI nor the TUI can
listen. This plan covers two features:

- **Dictation:** talk into the composer, and the text lands in the box
for you to edit before sending.
- **Voice mode:** a hands-free screen of its own. GAIA speaks short
answers and keeps the full detail of what it did on screen: tool steps,
results and files.

It's built to feel instant and to stay 100% on the PC:
- small streaming models (Moonshine Streaming for English, Whisper for
other languages, Kokoro for speech, the chat model already loaded)
- one server-side voice session
- spoken status lines the model writes before each tool call
- a latency budget of about 1.5 s from the end of speech to GAIA talking

Arabic users get dictation, and voice mode answers them on screen until
an Arabic voice exists. The plan ends with a six-PR delivery sequence,
dictation first.

Refs amd#702, amd#372

## Test plan
- [ ] `python util/check_doc_links.py` passes
- [ ] The page renders under Roadmap › Agent UI on the Mintlify preview

---------

Co-authored-by: Kalin Ovtcharov <[email protected]>
Conflicts: the capability matrix (regenerated: 106 tools) and the tool-request matcher, where main's media matches and the voice-setting match both stay.
… profile tool goldens

Three checks failed on this branch against current main: the SDK page did not mention the four voice routes, the committed API schema snapshot lacked the voice models, and the profile goldens did not list set_voice_setting, which every non-chat profile now registers. The goldens' prompts are unchanged; only the tool name is added.
Conflict: the chat view's send. Main made it report whether the message was taken; the voice turn's error signal is kept on each path that now returns false.
@kovtcharov

kovtcharov commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor Author

Brought up to date and left as a draft.

Merged the updated voice branch (#6789), which now carries current main and its fixes, so this merges with main again. No conflicts of its own. One real bug fixed here: gaia.phone was not in the list of packaged modules, so an installed GAIA would have shipped without the phone code.

Why it is still a draft:

  • It is stacked on feat(voice): dictation and voice mode in the Agent UI and TUI #6789. Until that merges, this diff contains all of it and cannot go in first.
  • It has never placed a real call or sent a real text. The description says so: Twilio has only been exercised through stubs and the Simulated phone. That needs one run against a real account before this is offered to users.
  • One check still fails: the 14 /api/phone/* routes are not in the Agent UI SDK page, which main requires for every route. I left that for whoever knows the daemon's request and response bodies, since those routes only pass through to it.

Locally on the merged branch: the phone, alert-tool, approval-alert and schedule-daemon suites pass together with the voice suites and the schema, golden, packaging and capability-matrix checks (the route-doc check being the one failure); the webui suite passes (3,701) and type-checks; black, isort and flake8 are clean. go test in tui was not re-run for this branch.

gaia.voice was missing from setup.py's package list, so an installed (non-editable) GAIA would have had no voice code at all.

Also: the doc-profile tool baseline is re-measured for the added set_voice_setting tool (46 tools; the text prompt grows by about 145 tokens), two voice eval scenarios use the corpus's own tier tags, and the TUI's new WebSocket module is recorded as ISC from the licence text it ships.
gaia.phone was missing from setup.py's package list, so an installed (non-editable) GAIA would have had no phone code.
@kovtcharov-amd kovtcharov-amd added the enhancement New feature or request label Nov 12, 2026
@kovtcharov-amd kovtcharov-amd added the third-party integration Integrates an outside company's product or service; needs vendor vetting label Nov 13, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents audio Audio (ASR/TTS) changes cli CLI changes daemon Daemon supervisor / sidecar control plane dependencies Dependency updates documentation Documentation changes electron Electron app changes enhancement New feature or request installer Installer changes mcp MCP integration changes security Security-sensitive changes tests Test changes third-party integration Integrates an outside company's product or service; needs vendor vetting tui Go terminal UI (gaia-tui)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants