Skip to content

Agents and LLMsHarness and toolingreference

Watching and steering coding-agent sessions from a phone

Long-running coding-agent sessions need two things from a phone: a push when one of them waits for an answer, and a way to look at it and reply. This page describes one working arrangement of three parts: a push broker that cannot read what it forwards, a dashboard that indexes the agent sessions on a server, and a presence rule that sends each alert to one device. It is for someone who runs pi (a terminal coding agent) in tmux, or any similar long-lived process, and wants the phone side without handing message content to a third party.

The system was built over late November and early December 2026 on a home network and last checked on 2026-12-02. Components are named by role because none is published. The broker’s key hierarchy is already explained in End-to-end encrypted push notifications through an untrusted broker; this page covers what was added around it and how the parts combine. The Evidence table separates what was exercised live from what was only tested on a scratch server.

TL;DR:

  • The broker stores ciphertext and the Android app decrypts. Firebase Cloud Messaging (FCM) carries a data message the app turns into a notification itself, so Google’s servers see routing metadata (topic name, priority, collapse key, ids) and a sealed body they cannot read, and no title or body text.
  • Senders that cannot encrypt (Home Assistant, Alertmanager) post ntfy-style plaintext to a relay on loopback. The relay seals it and publishes ciphertext, and answers an error when it has no key instead of falling back to plaintext.
  • Files travel as 64 KiB AES-256-GCM (Advanced Encryption Standard; Galois/Counter Mode) chunks under a per-file key. An APK (Android Package Kit) sent from the command line installs from its message through the system installer, and a 30.9 MiB one went through the public edge.
  • The dashboard reads tmux panes, the process tree, per-process presence files and background-worker state files. A second host appears through a peer that is polled over an ssh tunnel, and a peer that stops answering is frozen at its last snapshot, never dropped.
  • The web UI (user interface) sits behind mutual TLS (Transport Layer Security) at the edge proxy. The server believes a forwarded certificate fingerprint only from the proxy, and only when that fingerprint was pinned when the certificate was issued. The phone gets its certificate as an encrypted attachment and imports it into AndroidKeyStore.
  • Windows idle and lock state is sampled by one long-lived powershell.exe started from a systemd user unit inside WSL (Windows Subsystem for Linux). Started through ssh it runs in session 0 and reports about 32 hours of idle. While the desktop is in use the phone is not pushed, and pending items push once on leaving.

Home serverWindows desktoppi sessions(tmux) and workersDashboardindex, web UI, terminalspanes, /proc,presence + state filesDashboard peer(in WSL)polled overssh -L tunnelPush brokerciphertext onlysealed alertspowershell.exeidle + lock samplerevery 15 sHome Assistant,AlertmanagerLocal relayloopback onlyplaintext, ntfy-stylesealed envelopeFCMdata messageAndroid applist + WebViewEdge proxymutual TLSclient certificateHTTP + fingerprint header

Plaintext exists in three places: the sender’s own loopback to the relay, the host that publishes an alert, and the phone. Everything between them is ciphertext, and the broker holds no key.


You wantUseWhat it costs
A push about a script or monitor, readable only on your devicesthe broker, with a publisher device on the senderone device approval per sender, and a topic key per epoch
The same, from a tool that only speaks ntfy headersthe local relay beside that toola process that holds the publisher’s topic keys
A file on the phone (an APK, a certificate) without a cloud drivean encrypted attachmentthe file is stored, as ciphertext, for 72 hours by default
One view of every agent session, with a reply boxthe dashboarda per-host process and an edge route
A second machine’s sessions in that viewa federated peera tunnel and a control token per peer
No duplicate alert at the desk and on the phonedesk presencea sampler on the desktop

A full device holds topic keys and can subscribe, rotate and approve. A publish-only device can post but cannot subscribe or rotate, so a compromised sender can forge alerts and cannot read any (see Onboarding a device). Both kinds join the same way: a one-time provisioning link, then an approval by an existing full device after both sides show the same fingerprint. The exception is the first full device, which activates itself. The fingerprint is the first 80 bits of a SHA-256 (Secure Hash Algorithm) hash of a fixed prefix and the public key, printed as four groups of four base32 characters. Approval wraps the topic keys the approving device holds (for a publisher, only each topic’s latest epoch), and creating a topic wraps its first key only to the device that created it. A device approved before a topic existed therefore has no key for it, and the relay answers 422. Syncing does not help and an active device cannot be approved again: a full device has to rotate the topic, which wraps the new epoch to every active device.

The Android app registers an FCM token with the broker, and the broker pushes through FCM’s v1 HTTP (Hypertext Transfer Protocol) API (application programming interface). It sends a data message, which carries only custom key-value pairs and is handled by app code, rather than a notification message that Firebase’s client library would display from its own fields.1 Both types are capped at 4096 bytes.1 The payload is the same one the browser path uses: the sealed message when it fits, otherwise a routing hint with a fetch flag, and the app then asks the broker for the stored ciphertext. A cancel event removes a notification by tag.

The app decrypts with the topic key held in its own storage, which is wrapped by an AndroidKeyStore key. The Android documentation describes keystore keys as non-exportable once stored, with use restrictions the app can set.2 A message the app cannot open becomes a placeholder naming the topic, so a failure to decrypt delays the content and never drops the notification, and a high-priority message always ends in one. The credential-encrypted storage is unreadable before the first unlock after boot, so a push in that window also shows the placeholder.

A sender such as a Home Assistant rest_command cannot encrypt, and an encrypted topic refuses plaintext. The relay is a client-side listener that accepts the same HTTP publish ntfy accepts, a POST with the message as the body and the title and priority as headers,3 and publishes the sealed envelope through a device session. Nothing is added to the server.

RuleBehaviour
Listen addressloopback; any other address is refused unless an explicit flag is passed
Optional shared secretwhen configured, required as a bearer token or query parameter, compared in constant time; it is separate from the device’s broker token
Body sizeat most 64 KiB; bodies, titles and tags are never logged
No key for the topic422, nothing published
Stale epoch from the brokersync keys and retry once; still stale: 502 naming the topic a full device must rotate

The relay runs as a hardened service under its own user on the host that runs Home Assistant, with its profile in a 0700 state directory. Its threat model is the same as any publisher device: the host holds the topic keys, and plaintext exists only on loopback. Home Assistant does not retry a failed rest_command, so while the relay is down alerts are lost, not queued.

A 40 MB file as one compact JWE (JSON Web Encryption) object would need the sender to hold the whole file to produce the authentication tag and the receiver to hold all ciphertext before any plaintext is released, plus about a third more for base64 text. On a phone that fails at exactly the sizes the feature exists for, so the attachment is a chunked AEAD (authenticated encryption with associated data) object instead,4 while the message envelope stays a compact JWE.

PartValue
Headermagic and version, chunk size, a 32-byte random salt, the topic-and-epoch key id
Chunk size65536 bytes plaintext; readers accept 4096 to 1048576
File keyHKDF-SHA256 (HMAC-based Extract-and-Expand Key Derivation Function)5 of the topic key with the salt, so every file has its own key
Chunk cipherAES-256-GCM (Galois/Counter Mode), nonce is the chunk index, associated data is the header plus a final-chunk flag
Attachment idlowercase hex SHA-256 of the whole blob, computed by the server without a key
Sealed in the messagename, plaintext size, type; at most 8 per message

Each chunk is authenticated before any of its plaintext is used. The final-chunk flag makes truncation and trailing bytes fail, and the chunk index in the nonce makes reordering fail. The receiver hashes the blob as it streams it and, before the plaintext file is published, checks the hash against the id named inside the sealed message, which also catches a broker that swaps in a different valid blob. Memory stays at one chunk on both sides, and the uploader knows the exact length in advance because it is a function of the file size.

The broker links a blob to a message through a plaintext header of opaque ids, since it cannot read the sealed list. It sees blob ids and sizes, never names or types. Download is authorised by the same rule as the message that references it, so revocation, history policy and cancellation apply to the file. Storage is bounded per blob, per user and in time: an upload no message references expires after 1 hour by default, and a referenced one after 72 hours or the message’s own expiry, whichever is sooner.

On the phone the type is only a hint. An APK goes to the system package installer, which still shows its own confirmation, and anything else is saved under Downloads without overwriting. The app refuses a file over 64 MiB by the sealed size before making any request.


One server process builds a snapshot of every agent session from four sources and serves it as a REST (representational state transfer) interface with an OpenAPI description.

SourceWhat it gives
tmux pane listwhich panes exist, and what each one runs
The process tree under each panethe topmost pi process on a branch, and whether it is in the foreground
A presence file per pi process, written by a pi extensionsession id, name, unattended mode
The state files of background workerseach worker’s state, log and, for a loop worker, its event stream folded into iteration, model and failing checks

The background workers are the detached tasks, loops and subagents described in Subagents, worktrees, and parallel agent work. Workers are shown under the session that spawned them, and a running worker can be steered through the same inbox file pi’s own tools use. A pi started before the presence extension was installed still appears, with an id taken from its workers or its pid, but without its model, session file or unattended flag, so it can never raise an unattended-stop push.

The dashboard runs two kinds of session side by side:

  • Attached: pi keeps running as its full terminal UI in tmux, so every extension and shell escape keeps working. The dashboard mirrors the pane by polling tmux capture-pane and sends input with tmux send-keys.
  • RPC (remote procedure call) threads: for work started from the phone, the server spawns pi in its RPC mode and owns the pipes. Selection, confirmation and input dialogs become cards in the web UI.

The gates stay pi’s own. The dashboard only surfaces a prompt that is waiting and pushes it.

A live terminal is a tmux client attached with -f ignore-size, optionally read-only,6 inside a pty that the server owns, on a grouped session with its own current window. The ignore-size flag stops the browser’s dimensions from resizing the owner’s window. Output reaches the browser by long-poll into a terminal emulator widget. Viewing needs the read scope, and takeover needs the control scope.

A second host, here a Windows desktop with its sessions in WSL, runs its own dashboard process bound to loopback. The main server reaches it through an ssh local-forward tunnel kept alive by a user unit; WSL’s localhost forwarding carries the Windows loopback port into WSL, and that path was proven before anything was built on it.

Every 3 seconds the main server fetches each peer’s session list with a 2-second timeout and a control token that lives in a file readable only by its owner. The merged list marks every session, worker and thread with its host, and ids are host-local, so the pair of host and id is the identity. Actions on a peer’s item go through a reverse proxy route that forwards to the peer’s matching path with only the peer token as credential: the caller’s key, cookies, certificate headers and Upgrade are not passed on. A non-GET needs the control scope even where the peer’s own route would accept read, because opening a terminal is a POST. Long-polls pass through unbuffered.

A peer that fails a fetch keeps its last good snapshot and is marked down with the reason and the time of the last success. It is never dropped, because the desktop sleeps and a dropped peer would turn every one of its workers into a “lost” alert at once. Federation is one hop: items a peer holds from its own peers are discarded, so a ring cannot loop.

Two credentials exist. A per-device token has a read or control scope, is stored only as a SHA-256 hash and can be revoked while the server runs. The edge adds a pinned client certificate.

Phone WebView or browserEdge proxyrequire_and_verify against the device CAclient certificateDashboardTrusted peer + header present?header_up setsSHA-256 fingerprintFingerprint pinned andnot expired?yes: the cert decides aloneX-API-Key tokenno headerprincipal named afterthe cert entryyes401, costs the client IPone rate-limit tokenno

The proxy runs mutual TLS in its require_and_verify mode against a trust pool holding the device CA (certificate authority),7 and passes the client’s SHA-256 fingerprint to the upstream in a header it sets itself, replacing any value the client sent.8 9 The server believes that header only when the direct peer is in a configured trusted-proxy range, and ignores it from every other address. A certificate the CA signed but the server never pinned is refused. Revocation is removing the pin, which a running server sees on the next request, and a stolen CA key alone mints nothing usable. When the header is present and trusted, the certificate decides: an X-API-Key on the same request is ignored and a bad certificate does not fall back to it. Failed credentials cost the client IP (Internet Protocol) a token from a bucket of 30 per minute, and once it is empty any request carrying a credential gets 429 before the credential is checked, so guessing has no oracle.

The device CA is ECDSA (Elliptic Curve Digital Signature Algorithm) P-256 with a 10-year life and a path length of zero. A client certificate it issues has client-authentication usage only and a default validity of 825 days.

The phone needs a client certificate, and the obvious route (a PKCS12 (Public-Key Cryptography Standards number 12) file copied over, with a typed password) leaves a private key in a download folder. The issuing command instead sends the file as an encrypted attachment on a topic the phone already holds a key for, with the PKCS12 password as the sealed message body and a marker tag or title prefix. It passes the password to the push client on standard input, never in argv, then deletes the file and key it wrote; the password is printed only if the send fails.

The app sees the marker with exactly one .p12 attachment, hides the password from the notification and the inbox, and on tap downloads and verifies the blob, parses the file, imports the key into AndroidKeyStore with KeyStore.setEntry so it is non-exportable from then on, deletes the decrypted file and clears the password. The WebView then answers the edge’s client-certificate request with that key through ClientCertRequest.proceed.10 A message without the marker, or with two attachments, is an ordinary file.

Not built: a certificate request generated on the phone, which would keep the private key off the issuing host. In this design the key exists on that host between issuing and the delete after a successful send.


Pi already raises a Windows toast when a session settles or asks a question, and the dashboard pushes the same event to the phone. With both active, one event meant two alerts, and the topic that carries the dashboard’s pushes held 34 messages at the time of the decision, mostly worker-finished events. The rule that replaced it: the toast is the alert at the desk, the phone push is the alert everywhere else, and never both.

A desktop host answers one question: is the owner here. One long-lived powershell.exe, started by the peer process, loops every 15 seconds and prints the idle time and whether the screen is locked. Idle comes from GetLastInputInfo; locked means a LogonUI process exists. It is restarted with backoff when it exits and is never spawned per sample.

GetLastInputInfo reports input for the session that called it.11 Since Windows Vista, session 0 is reserved for services and the first interactive user is in session 1.12 A powershell.exe started from a systemd user unit inside WSL, or from a tmux server started in a terminal, lands in the interactive session and reads real idle time (0 while typing). The same command run over ssh runs in session 0 and read about 32 hours of idle. A test over ssh therefore passes and measures nothing, which is why the sampler is its own unit and not a probe.

The user manager’s PATH has no Windows directories, because WSL appends them only to a login shell’s PATH, so the unit names the PowerShell directory explicitly.

The sample is served as a small block in the dashboard’s snapshot with a timestamp from the desktop’s own clock. The main server rebases it onto its own clock using the sample’s age, so skew between the machines does not matter.

ConditionMeaning
Desktop peer up, sample present, sample under 60 s old, not locked, idle under 5 minutesat the desk: Windows toast, no phone push
Anything else, including no sample, a stale one, a down peer or an unknown hostaway: phone push

The toast side asks the local dashboard for the sample with a 500 ms budget and applies its own idle setting (the defaults match the server’s) and drops the toast when the screen is locked or the idle limit is passed; on any error it toasts. Both sides therefore fail toward alerting, and the worst case is two alerts.

While at the desk, the rules for pending items (a prompt waiting past its 15-second grace, a session idle in unattended mode for 10 minutes, a thread dialog) neither push nor record that they pushed. When the owner leaves, every item still pending pushes once, and an item answered at the desk never does. Finished workers are one-time events and are dropped while at the desk, not replayed. Separately, a pi or loop worker finishing normally never pushes; failed, killed and lost still do.

Each pushed prompt, unattended stop and dialog is tracked under a key. When the item stops being pending (the prompt is answered from any device, the session resumes, the thread exits) the server emits a cancel first in the next 3-second tick, outside the cap of 10 pushes per tick. The publisher remembers the id the broker returned and asks the broker to cancel it; the broker sends a cancel data message with the message’s notification tag (its collapse key, which the dashboard always sets), only to devices that could read the message, and the app removes that notification and its inbox row. The remembered ids live in memory, so after a restart older pushes stay on the phone until the broker expires them, and items of a host that is down are not cancelled.


  • Sampling from the wrong session fails silently: the value is plausible and wrong. Check it while typing.
  • A relay profile approved before its topics existed cannot be fixed by waiting or syncing: a full device rotates each topic, which wraps the new epoch to every active device.
  • A restarted or woken desktop loses every tmux session at once. After a peer was down, “lost” never pushes for its workers.
  • The decrypted inbox on the phone (the last 50 entries) sits inside the same keystore-encrypted store as the keys, so its protection is the keys’ protection.
  • A WebView can remember a “no certificate” answer for the origin, so the app clears its client-certificate preferences after importing a certificate.

Status as of 2026-12-02.

ClaimStatusHow it was checked
Relay publishes ciphertext only; no key gives 422; stale epoch gives 502 with a rotate hint; non-loopback refusedtested on a scratch serverdatabase file and its write-ahead log inspected for plaintext (none), a full device decrypted title and body, race detector 3 runs
The relay on the Home Assistant host publishes to the brokerlivea test post to the relay returned 200 and the server row showed an encrypted body; the automations themselves had not yet fired from Home Assistant when recorded
40 MiB attachment round trip, blob has no plaintext, other users refused, a publisher device can upload but is refused on download, 70 MB refusedtested on a scratch serverSHA-256 of the file compared after fetch; blob entropy measured
30.9 MiB APK through the public edgelivesent with the command-line client through the public edge; the 40 MiB scratch run above is the integrity check
APK install from the notification taplivea 31.0 MiB build of the phone app was sent with the command-line client and installed over the running version from its message, through the system installer’s confirmation
Certificate import and mutual TLS handshake from the WebViewliveissued with --send, tapped on the phone, web UI loaded through the edge
Federation with a second hostlivemerged list showed the remote host up with its sessions beside the local ones
Live terminal on a remote session, a push from a remote worker, a sleeping peer shown frozennot yet seen livethe freeze was proven on a scratch setup by the implementing worker
Presence sampler and routinglivethe dashboard reported the desktop idle 0 s, unlocked, sampled 9 s earlier, and logged that phone pushes were held
Push on leaving the desk, and the phone notification disappearing on cancelnot yet seen liveunit-tested in the push diff rules only
Certificate request generated on the phonenot builtsee Certificates through the push channel

Must the broker be unableto read alerts?Is the sender ableto encrypt?yesServer-readable broker(ntfy)noPublisher deviceyesLocal relaynoDo you watch agent sessionsfrom more than one host?DashboardnoDashboard + peeryesDo you also work ata desktop that toasts?Add desk presenceyes
  1. If the server is yours and trusted, ntfy is the smaller system: it already has native apps and no key management.
  2. If the broker must be blind, a sender that can run the client library is a publisher device, and one that only posts HTTP goes through the relay.
  3. One host needs one dashboard. A second host adds a peer, a tunnel and a token.
  4. Desk presence is worth building only if the desktop already raises its own alert for the same events.

  1. Google, “About FCM messages,” Firebase Cloud Messaging docs. https://firebase.google.com/docs/cloud-messaging/customize-messages/set-message-type ↩ ↩2

  2. Google, “Android Keystore system,” Android Developers. https://developer.android.com/privacy-and-security/keystore ↩

  3. ntfy, “Publishing,” ntfy docs. https://docs.ntfy.sh/publish/ ↩

  4. D. McGrew, “An Interface and Algorithms for Authenticated Encryption,” RFC 5116, IETF. https://www.rfc-editor.org/rfc/rfc5116 ↩

  5. H. Krawczyk and P. Eronen, “HMAC-based Extract-and-Expand Key Derivation Function (HKDF),” RFC 5869, IETF. https://www.rfc-editor.org/rfc/rfc5869 ↩

  6. tmux, “attach-session,” tmux manual page. https://man.openbsd.org/tmux ↩

  7. Caddy, “tls (Caddyfile directive), client_auth,” Caddy docs. https://caddyserver.com/docs/caddyfile/directives/tls ↩

  8. Caddy, “reverse_proxy, header_up,” Caddy docs. https://caddyserver.com/docs/caddyfile/directives/reverse_proxy ↩

  9. Caddy, “Caddyfile concepts, placeholders (tls_client_fingerprint),” Caddy docs. https://caddyserver.com/docs/caddyfile/concepts ↩

  10. Google, “ClientCertRequest,” Android Developers. https://developer.android.com/reference/android/webkit/ClientCertRequest ↩

  11. Microsoft, “GetLastInputInfo function (winuser.h),” Microsoft Learn. https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getlastinputinfo ↩

  12. Microsoft, “Service Changes for Windows Vista,” Microsoft Learn. https://learn.microsoft.com/en-us/windows/win32/services/service-changes-for-windows-vista ↩