Repository navigation
Conversation
A reply that ended because the model failed showed as failed only while it streamed; reopen the chat and it looked like an ordinary answer. The saved message now carries the same failed flag as the stream's done event, on streamed, non-streamed and scheduled turns alike.
A phone paired on the home network reaches GAIA on its own listener, so the server has to tell it apart from the PC and from mobile access. Requests on that listener are the paired device whose token they carried, or nobody; on the main listener the PC is decided exactly as before. - principal() names the caller (pc, device:<id> or tunnel), and require_local_pc, is_local_pc and the device guards read it. - refuse_on_device_listener keeps a route on the PC for paired devices. - audit_approval records who approved a tool call, goal, schedule or folder. - export_route_access writes each route's guard class for the phone app, so it can say "change this on your PC" instead of offering a control that would fail.
GAIA can now be used from a phone on the same Wi-Fi as the PC. The PC shows a QR code; the phone scans it, pins the PC's certificate and waits until the PC allows it. Each device has its own token, which the PC can revoke at any time. Pairing is off until device_pairing is set in ~/.gaia/config.json. - gaia.ui.devices: the single-use pairing window, the device table (tokens stored hashed), the owner-only key folder and certificate, and a second uvicorn listener whose device auth runs before the app. - /api/devices: turn the listener on or off, open a pairing window, allow, unpair and reset from the PC; pair and unpair itself from the device. - A paired device can't change what stays on the PC: mobile access, provider keys and connection settings, connector setup and grants, agent installs, logs and the troubleshooting report, the memory profile scan and admin, documents added by path or folder, and opening files on the PC's screen. - Device pairings reach only the PC's own windows, and tool, goal, schedule and folder approvals are written to the audit log with who made them.
A phone browsing files, opening a preview or an image, or searching sees only the folders the chat was given, never the rest of the PC's home folder, and never a key, .env or credential file even inside those folders. Previews on a phone are capped at 50 lines. Documents are added to the library on the PC; a phone opens a cited document through file preview. - Browse, preview, image and search take the chat's session_id on the device listener, and refuse a path outside its folders before touching the file. - secret_read_refusal() is the one copy of the read policy the agent's read tools and these routes share.
Every backend started through `gaia.ui.server.main()` completed TLS with a phone and then hung up without answering, so pairing failed on every real install. main() injects truststore into `ssl`, which made the listener's server context a truststore one; that context checks the peer's certificate after each handshake, and a phone sends none. The test harness never injects truststore, so it answered normally. - The listener's server context is now a stock `ssl.SSLContext`, built through `gaia.tls.stock_ssl_context`, which the injection doesn't reach. - The listener runs one in-memory handshake before it binds, so a context that can't serve fails the start and the status says so instead of reporting listening.
The device listener let an allowed device call about 210 of the backend's routes, from mailbox sends to wiping memory. It now refuses every route it doesn't list, so a route stays on the PC until a change opens it to devices on purpose; each later feature widens the list for its own routes. - DEVICE_ROUTES lists the phone's core: its own unpairing, health and status, chats and their messages, sending a turn and its stream, stopping it and answering its prompts, and reading schedules and tasks. - The gate lets a request through only when every route that matches it is listed, so a listed template never opens a sibling such as /api/sessions/search. Anything else is a 403 with code pc_only. - routeAccess.gen.ts marks every unlisted route not_on_listener, and the device API, the listener's security model and device_pairing are documented.
The phone's chat list stays current through the same session event stream the PC's windows read; only the PC's own windows get the pairing and security events on it.
DELETE /api/devices/me also matches DELETE /api/devices/{device_id}, which
only the PC may call, so the gate refused a device unpairing itself. A
sibling route that refuses devices with its own guard no longer blocks a
listed one; an unlisted sibling that would serve a device still does.
The pairing models and /api/devices routes were missing from api.schemas.json and api.gen.ts, so the schema drift test failed.
1 of 4 tasks
2 of 6 tasks
This was referenced Nov 17, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Lets a phone or tablet on the same Wi-Fi pair with GAIA and use a small, fixed set of routes over its own listener, with TLS pinned to the PC's certificate. Off by default.
Why
GAIA had no way to be used from a phone without sending traffic through an outside service. This adds the PC side: a second listener that only answers paired devices, pairing by QR code, Allow and Remove on the PC, and a deliberately small list of what a device may call. The feature is off until
device_pairingis set in~/.gaia/config.json, and nothing listens until the PC turns it on.Linked issue
Refs #6385 (a phone that stays trusted across restarts and can be revoked). Depends on #8335.
Changes
pc_onlyand stays available on the PC. The list is one file,src/gaia/ui/devices/routes.py.Test plan
python -m pytest tests/unit/chat/ui -qpython -m gaia.ui.export_route_access --checkandpython -m gaia.ui.export_openapi --check"device_pairing": true, start GAIA normally (python -m gaia.ui.server), turn on the listener, and from another machine callGET /api/healthon the device port with a paired token (200), without one (401), andGET /api/providers/listwith one (403pc_only)device_pairingoff:GET /api/devices/statusanswers 403Evidence
pc_only.