Messages and agent state
Build a message screen that can answer a practical question: is there a reply to read, is the agent still working, or has the phone lost its upstream connection? Each has its own signal.
On this page
Read three independent signals
| Question | Read | Example behavior |
|---|---|---|
| Is the agent working? | SNAPSHOT payload bit 0 | Pulse while the agent thinks or acts. Stop on a newer snapshot with the bit clear. |
| Is there something to read? | SNAPSHOT payload bit 1 | Keep a notification dot visible even after the working light stops. |
| Can the phone fetch the conversation? | RELAY_STATE | Keep a cached message visible if the latest fetch failed. The separate voice session can still work. |
| Kind | Direction and capability | ID / seq | Payload |
|---|---|---|---|
| 42 RELAY_STATE | App → device, relay state | selected context (zero allowed) / revision | One u8: 0 unbound, 1 connecting, 2 available, 3 unavailable, 4 paused. |
The relay observation concerns the upstream chat/history path. Available means the last fetch succeeded. Unavailable means the last fetch failed. Paused means monitoring was intentionally suspended. The app owns this observation and its retries. A device can be connected over BLE and playing voice while text history is unavailable. Start at unknown for each newly bound session. Ignore unrecognized state codes and stale revisions. Clear upstream state when the session is lost. Accept current-epoch updates monotonically (u32 sequence arithmetic). A successful read or write on a characteristic does not establish relay availability.
For a separate “thinking” light, use SNAPSHOT payload bit 0. That bit includes thinking, acting and responding. For a notification badge use bit 1 (one or more unread messages). Bit 2 signals a question or need for input. A question can require opening the app. Clearing “working” does not imply a new message, and an unread message need not interrupt the user. These are latest-value indicators. A device may use a light, display, haptic or another suitable interaction.
Messages and choices
| Kind | Direction | ID / seq | Payload |
|---|---|---|---|
| 3 SNAPSHOT | App → device | context / revision | u8 state bits, u32 message token, u32 question token, u8 option count, text caption, text body, then one text field per option. |
| 4 TEXT | App → device | context / revision | u32 message token, u32 page, text body (up to 640 bytes). Header flag 1 means another page follows. |
| 5 READ | Device → app | context / revision | u32 message token. Send when the user reads the current message. |
| 6 ANSWER | Device → app | context / exact revision | u32 question token, u8 zero-based option. Only for a current choice the user actually selected. |
| 7 PAGE | Device → app | context / revision | u32 message token, u32 zero-based page. Page 0 begins at offset 0. Each page holds up to 640 text bytes. |
| 40 PRESENT_MESSAGE | App → device | context / nonzero current message token | Empty. Ask to open an already synchronized message. Requires present-message capability. |
| 41 PRESENT_RESULT | Device → app | same context / same token | Empty. Header flags 0 shown, 1 stale or unavailable, 2 busy. A presentation receipt is separate from READ. |
Keep at most one PRESENT_MESSAGE outstanding per peer. Match PRESENT_RESULT by epoch, context and token. Repeating a request for the already displayed message is idempotent. Report busy when a settings panel, tutorial, full-screen image, active touch or update prevents presentation. A device can choose how to present the content.
SNAPSHOT uses a flags byte inside the payload. Working=1, unread=2, input requested=4, voice in use=8, error=16, more text=32, image=64. Contextual caption is human-readable and may change between app releases. Machine behavior must use flags, tokens and relay state. Each text field is a u16 byte length and that many printable ASCII bytes or line feeds. The app folds unsupported text. Caption ≤120 bytes. Body ≤640 (≤320 with choices); 0–3 choices, ≤80 bytes each. Parse with bounds checks. Capability-specific contents may be omitted or cleared.
An LED-only device needs just the state byte after validating the snapshot. Ignore snapshot revision zero. After revision 0xffffffff, the next usable revision is 1. A face-free screen can page through the body. Token zero indicates no corresponding action. Coalescing is allowed, so always use the tokens in the latest matching revision. When answering, retain revision and token from the rendered question to prevent a delayed tap selecting an option on a replacement question. The app owns conversation history and the decision to accept the answer. Credentials, unbounded free text and approvals that require app UI stay on the host.
Browse an older reply
An ordinary PAGE request fetches more bytes from the live message. To navigate between messages, negotiate message history (bit 13, requires text) and wait for bit 0x80 in the header of the current SNAPSHOT. A host using the legacy handshake can advertise history in its SNAPSHOT. A device that understands the flag can then request a window. With no advertisement, use the live message.
- Device requestsPAGE · flag 0x80
Use context as ID and a fresh nonzero request ID as sequence. Send a nine-byte window request: anchor token u32, step i8, first row u32. All zeros opens the newest message. - App answersTEXT · flag 0x80
Match the epoch, context and request ID. Decode token u32, chronological index and count u16 each, actual first row and total rows u32 each, then u8 attributes and the remaining ASCII text. Attribute bits 0, 1 and 2 mean user-authored, has gallery and unread. - User selects OlderPAGE · new request ID
For token 7 send07 00 00 00 ff 00 00 00 00. Step −1 selects older, +1 newer and 0 the named message. Use the returned token and index since a missing anchor resolves to newest.
The host serves up to 100 delivered messages, oldest at index zero. Each window spans up to 18 rows of 32 columns and up to 576 text bytes. Use the actual start row in the reply. Count and token zero describe an empty conversation. A history attachment uses its message token for gallery requests. Keep choice answers tied to the live question. Drop a late window if the user has since moved to a different one.
Add another interaction
See voice control, audio frames and delivery for speaking and listening. A device can answer an offered choice or send a voice turn. V1 has no general command to post arbitrary typed prompts.
For attachments, see images and galleries.