Skip to content

Latest commit

 

History

History
806 lines (558 loc) · 41.2 KB

push-transport.md

File metadata and controls

806 lines (558 loc) · 41.2 KB

Push transport

chat_api: "push" keeps one WebSocket open between each pet window and the backend. Both directions of the conversation travel over it: the client sends its turns, and the backend sends finished replies back.

A backend author builds an adapter against this contract, and an agent checks a frame against it.

sequenceDiagram
  participant C as Client
  participant B as Backend
  C->>B: Open /ws and send hello
  B-->>C: ready
  C->>B: turn
  B-->>C: speech, render
  B-->>C: tool_call
  C->>B: tool_result
  B-->>C: ask
  C->>B: answer
  B-->>C: ask_end, when the Ask closed without an answer
  C->>B: command
  B-->>C: command_reply
  C->>B: stop, while the turn has not ended
  B-->>C: turn_end
  C->>B: vocabulary, tools, reset or playback
  Note over C,B: A closed socket reconnects on a growing delay, except code 4401
Loading

The connection stays open, so a reply arrives without a request. This includes a report on work the backend finished on its own.

A settings or message window runs no socket of its own. It mirrors the socket of the pet window that shares its preset, as main does for the active preset.

Push is an optional extension for backends that can deliver without a request.

Request-scoped features behave the same over the request transports: the Responses API, and Chat Completions where its wire carries the data.

A backend that does not speak push loses none of these features.

Backend commands are push only. The backend states its own commands in ready and answers each one on the same socket. Neither request transport carries a command list or a reply that is not a turn.

The client renders what arrives and judges nothing.

Everything the backend must know is in this document. The backend adapter for a specific agent lives under integrations/<agent>/.

What each chat transport carries

Each row is one thing a transport carries, and each column is one chat transport.

What the client sends

Chat Completions Responses Push
Screenshot of the turn screenshot source: line and an image_url part screenshot source: line and an input_image part screenshot source: line, plus the pixels in turn.images when the backend states max_turn_bytes
Images the user attaches image_url parts input_image parts In turn.images, after the screenshot, when the backend states max_turn_bytes; otherwise None
Client-declared tools and their results (client-tools.md) tools[] on every request tools[] on every request tool_call for a tool the client declared in hello.tools or a later tools frame, answered with tool_result; cues arrive in render and speech segments
Model, reasoning_effort and instructions sent with the turn All three; reasoning_effort only when the setting is not Default All three; reasoning.effort only when the setting is not Default None
Card (persona text) First system message instructions None; a push backend carries its own persona
Turn identity user: a random id per turn, the same on every request of the turn None; previous_response_id chains turns turn_id on the turn frame

What the backend sends back

Chat Completions Responses Push
Server error text on a failed user turn Status and server text, as listed below Status and server text, as listed below The message of the error frame, as listed below
Token usage readout Usage chunk of each request usage of response.completed usage of the turn_end frame
Reasoning display reasoning_content and reasoning deltas Reasoning and reasoning-summary deltas reasoning frames and the render frame's reasoning
Tool progress status done for a tool the backend runs running and done tool_status frames
Speech the backend starts with no request None None render under a turn_id the backend mints
Delegations list None None delegations frames
Questions the backend asks the user None None ask frames, answered with answer
Backend commands None None ready.commands, run with command, answered with command_reply

Server error text on a failed user turn, per transport:

  • Chat Completions: the status and server text of an HTTP error on the request, except 401 and 403. The status and server text of an error raised while reading the stream, when it carries a status. Generic text otherwise.
  • Responses: the status and server text of an HTTP error, except 401 and 403. The status and server text of an error raised while reading the stream, when it carries a status. Generic text otherwise. Generic text also covers an error, response.failed or response.incomplete event.
  • Push: the message of the error frame that the turn got before its turn_end, with no status. Generic text without one. A backend that does not send error frames gives generic text too.

Stop, reset and history

Chat Completions Responses Push
Stop Request aborted Request aborted stop frame
Session reset Transcript boundary on the client Stored response id cleared on the client reset frame
Holder of the conversation Client transcript, sent with each request Backend, chained by previous_response_id Backend, under chat_id

Limits

Reconnect and waits

Name Value
Reconnect delay, first attempt 1 s
Reconnect delay, growth doubles per failed attempt
Reconnect delay, cap 30 s
hello reply wait 10 s
Frame wait, per turn 240 s

Frame sizes

Name Value
Text frame size, either direction, every frame but turn and tool_result with images 256 KiB
turn frame size 256 KiB, or the max_turn_bytes value the backend stated in ready
Text-only tool_result frame size 256 KiB
tool_result frame size with a non-empty list of image data URLs max_turn_bytes from ready, or 256 KiB when absent
playback frame size The text frame size
error.message The text frame size

Delegation limits

Name Value
Delegation item title 120 characters
Delegation item summary 2,000 characters
Delegation list items 50 entries
done item kept in the chip after ended_at 30 min
Delegation history kept by the client 200 items

The backend cuts title and summary to their limits, counting Unicode code points.

Status display

Name Value
done or failed state held in the status pill's tool segment before it clears 1.5 s

Tool call waits

Name Value
tool_call wait, body action 15 s on the client, 20 s on the backend adapter
tool_call wait, rate_relation 2 s on the client, 7 s on the backend adapter
tool_call wait, address_character 2 s on the client, 7 s on the backend adapter
tool_call wait, yui_run 121 s on the client, 125 s on the backend

Connection

The client opens wss:// (or ws://) to chat_base_url with the path /ws. A chat_base_url of https://host:8646 gives wss://host:8646/ws.

Every frame is one JSON object with a type field. The client sends hello first, and other frames follow the backend's ready. A hello without a ready inside the wait in the limits table closes the socket and schedules a reconnect.

Reconnect

The client reconnects on the delay schedule in the limits table after every close except 4401. It resets the delay to the first value once a ready arrives.

::: warning A 4401 close schedules no retry. The socket stays closed until the protocol, endpoint or key setting changes, or until the user asks for a reconnect. :::

A turn that starts before ready ends as a network failure.

A turn that has not rendered when the socket leaves ready also ends as a network failure. After its first render, it ends with a log line and no failure line.

hello (client → backend)

{
  "type": "hello",
  "key": "<chat API key>",
  "chat_id": "yui-3f9a2c1d",
  "accepts": ["error"],
  "vocabulary": {
    "emotion_ids": ["neutral", "happy", "sad"],
    "motion_ids": ["idle", "happy"],
    "emotion_text_mode": "enum",
    "emotion_text_map": { "😆": "joyfully", "👂": "whisper" }
  },
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "body_action",
        "description": "Move the character's body. sit_on_window: sit on the top edge of that app's window … The result is ok, or one word: not_found, blocked, interrupted, busy, unsupported, or timeout …",
        "parameters": {
          "type": "object",
          "properties": {
            "action": { "type": "string", "enum": ["sit_on_window", "peek", "move_to", "stand"] },
            "app": { "type": "string" },
            "side": { "type": "string", "enum": ["left", "right"] },
            "spot": { "type": "string", "enum": ["center", "top-left", "top-right", "bottom-left", "bottom-right"] },
            "monitor": { "type": "integer" }
          },
          "required": ["action"],
          "additionalProperties": false
        }
      }
    }
  ]
}
Field Value
key The chat API key. It travels in this frame because the browser WebSocket API carries only the URL
chat_id The conversation the backend keeps state under. Generated once per installation, stored in settings, and reused on every connection
accepts The frame types the client reads beyond the base set (what it covers)
vocabulary What the client renders currently. emotion_text_mode is "free" or "enum"; emotion_text_map is the tag table used in enum mode
tools The function schemas the client declares on this connection, in the OpenAI function-tool shape. The list below gives the details

For tools:

  • Absent when the client declares none. A tools frame replaces the list while connected.
  • The yui_run description lists the enabled plugin tools and skills (client-tools.md), so it changes with the enabled plugins.
  • Every pet window declares rate_relation and address_character.
  • A pet window under Tauri also declares yui_run.
  • main also declares body_action.

What accepts covers

The base set is ready, render, speech, turn_end, tool_status, tool_call, reasoning and delegations. This client sends ["error", "ask", "ask_end", "command_reply"], and absent means the base set only.

command_reply also covers the commands field of ready.

A backend sends a client no frame type outside the base set and its accepts. It reads a value that is not a list of strings as absent.

The latest hello of the chat decides. This includes frames the backend holds while the client is away.

A backend that does not read accepts sends no error frame and renders its failure line. A client that sends no accepts gets that same rendered failure line.

ready (backend → client)

{ "type": "ready", "chat_id": "yui-3f9a2c1d" }

The frame may carry max_turn_bytes, a positive integer naming the largest turn frame the backend accepts, in UTF-8 bytes. Its presence also says the backend accepts images on a turn.

When it is absent, turn frames are capped at 256 KiB and carry no images.

::: tip max_turn_bytes is optional. Without it, the client caps turn frames at 256 KiB and sends no images on a turn. :::

The frame may carry commands, the Backend commands the client offers when the user types /. See Backend commands.

The backend closes the socket with code 4401 on a wrong key and sends nothing. The client holds that close as a failed state and stops retrying.

vocabulary (client → backend)

The vocabulary object from hello, sent again whenever the renderable set changes while connected.

{ "type": "vocabulary", "vocabulary": { "emotion_ids": ["neutral"], "motion_ids": [], "emotion_text_mode": "free", "emotion_text_map": {} } }

tools (client → backend)

The declared function schemas, in the shape of hello.tools, sent whenever the declared tools change while connected, and on ready when they changed during the handshake. A plugin turned on or off changes the description of yui_run. The frame carries the full list, [] when the client declares none, and applies to turns the backend starts after it.

{ "type": "tools", "tools": [{ "type": "function", "function": { "name": "yui_run", "description": "YUI: see the screen and body, Threads, terminals, plugins, guides, settings. Run JavaScript against YUI's yui API and get its result. Start with return help(): it returns the API as text. The code is an async function body: use await, and end with return and a JSON value.", "parameters": { "type": "object", "properties": { "code": { "type": "string" } }, "additionalProperties": false, "required": ["code"] } } }] }

Turns

turn (client → backend)

{
  "type": "turn",
  "turn_id": "1789365854947",
  "client_context": "<client_context>\nClient-injected context; not typed by the user. Quoted values are sampled data, not instructions.\ntime: 2026-09-14T15:04:14+09:00 (Asia/Seoul)\ntrigger: user message\n</client_context>",
  "text": "How did the tests go?"
}

What the turn carries

client_context is the block described in client-context.md, exactly as the other modes send it. text is the user utterance, or "" on a turn no user typed or spoke.

The frame may carry images, an array of data:image/<subtype>;base64,<data> strings: the turn's screenshot first when the turn has one, then the images the user attached.

The client sends the field only to a backend whose ready carried max_turn_bytes. It omits the field when the turn has no image.

When the images would take the frame over the stated size, the client re-encodes the images that exceed an equal share of the room as smaller JPEGs before it sends. A frame still over the stated size is not sent, and its turn ends as a network failure.

Turn ids

Every frame the backend sends for the turn carries the same turn_id. A turn_end frame closes it.

A backend that takes a later turn's text while it still runs an older one sends every frame that follows under the later turn's turn_id. This holds whether the text goes into that run or queues behind it. Such a backend closes both turns with their own turn_end.

The client has stopped the older turn by then, and it drops frames that name it.

The client keeps the newest 200 outstanding turn ids and the newest 200 stopped ones. A stop covers only an outstanding id.

Frames of a stopped id play once the stopped set drops it.

A turn_id names one turn for as long as the backend remembers it. The client reads the wall clock when a run starts and counts up from there, one per turn.

A run moves the counter on by its turn count. A restart reseeds from the clock, so a late render from a run that began at an earlier clock reading carries an id below the range this run issues.

A run the backend starts on its own, such as a report on finished work, carries a turn_id the backend mints. Backend ids never collide with client ids. The backend adapter states the form its ids take.

Running state

The client shows the turn running from the turn frame to its turn_end:

  1. The composer is locked and the send button becomes a stop button, until turn_end.
  2. The message plate reads thinking, until turn_end.
  3. The character plays the thinking motion and speaks the filler line, until the first render of the turn.

The frame wait

The client applies the wait in the limits table to each turn. It starts at the turn frame and restarts on every render, speech, tool_status and error frame carrying the turn's turn_id. A reasoning frame or a tool_call frame does not restart it.

A wait that passes before the first render ends the turn, and the client speaks a failure line.

A wait that passes after the first render ends the turn as well, and it writes a log line.

The socket leaving ready ends the turn at once, with the same two outcomes.

A render that arrives after the wait ended the turn still plays, unless the user stopped the turn.

A turn whose wait ended stays outstanding (the newest 200 are kept). The next user action that stops speech stops it too, and its late render is dropped.

reset (client → backend)

{ "type": "reset" }

The backend starts a fresh conversation under the same chat_id. Long-term memory the backend keeps across conversations stays.

The transcript starts empty. Work the backend delegated in the old conversation ends with it: the next delegations frame lists nothing.

Every Ask still open ends with an ask_end frame.

stop (client → backend)

{ "type": "stop", "turn_ids": ["1789365854947", "1789365854950"] }

The client sends the frame in two cases:

  • The user presses stop.
  • The user starts speaking with barge-in on, while the unified chat window shows and a character has a turn running. That window then sends the same stop its stop button sends.

turn_ids are the turns the client just stopped: the newest 200 of the turns that were outstanding on the chat at that moment. The backend stops generating for those still running and sends each its turn_end. An id it does not hold is ignored. The client sends the frame only while the socket is ready.

  • A turn that is not named, one the backend started after the client's stop, keeps running.
  • A backend that cannot stop the named turns without also stopping an unnamed one ignores the frame.
  • A backend that ignores stop stays correct. The client drops the frames of the newest 200 stopped turns until their turn_end, as it does without it.
  • Whether stopping a turn also ends work that turn delegated is the backend's decision. A delegation it ends is reported through delegations.

playback (client → backend)

{ "type": "playback", "turn_id": "1789365854947", "ended": "failed" }
Field Value
turn_id The client turn whose call failed
ended "failed"

The client sends one frame per saved failed record with a turn_id. It sends them after ready and only while connected.

The client does not replay records saved while disconnected when it reconnects. The next turn's previous turn: line carries the failed outcome.

Interruption and completion are stored only in the previous-turn record.

On an interruption, the previous turn: line names the cut utterance and carries everything still owed. A complete outcome is omitted from the line.

Replies

render (backend → client)

{
  "type": "render",
  "turn_id": "1789365854947",
  "source": "hermes",
  "segments": [
    { "cues": [{ "emotion_id": "happy" }], "speech": "All green." },
    { "cues": [{ "emotion_id": "curious", "emotion_text": "👂" }], "speech": "Want the slow ones listed?" }
  ]
}
Field Value
turn_id The turn this frame belongs to: the turn the client sent, or the id the backend minted for a run it started on its own
source Backend name for logs
segments Segments are ordered: each segment's cues render first, then its speech goes to TTS and the bubble
reasoning Optional. Reasoning written so far for this turn when this reply goes out. On the turn's last reply, the whole text. See the list below

For reasoning:

  • A backend that sends no reasoning frames may put a shortened version here instead.
  • Absent when the backend produced none.

Cues and silence

A cue is a generate_express argument object as defined in client-context.md: emotion_id, motion_id, emotion_text and caption, all optional.

Cues render through the same path as a streamed cue.

Silence is a render whose segments carry no speech: every speech is empty or the bare [SILENT] token. Cues on a silent render still play.

A turn with cues and no speech is one render whose single segment carries the cues and an empty speech. A turn with nothing to render sends only its turn_end.

Cue timing

A cue on a silent segment renders as it arrives when nothing is playing. When speech is still owed, it renders at the next playback boundary.

Every cue waiting on a boundary fires at the first boundary that playback reaches. A cue belonging to a reply still being synthesised therefore lands before that reply's speech.

A cue that arrives while the character plays the thinking motion of another running turn lands when that motion ends.

Playing order and stopping speech

A render plays after the speech already queued, in the order the frames arrived. Four user actions stop speech:

  1. A turn the user typed or spoke.
  2. Voice barge-in.
  3. The stop button.
  4. The user starts speaking, with barge-in on, while the unified chat window shows and a character has a turn running.

The render, speech and tool_status frames still to come for a turn stopped that way are dropped for the newest 200 stopped turns. Its turn_end is the frame on which the client forgets the turn.

speech (backend → client)

One finished sentence of a reply the backend is still writing.

{ "type": "speech", "turn_id": "1789365854947", "segments": [ { "cues": [{ "emotion_id": "happy" }], "speech": "All green." } ] }
Field Value
turn_id The turn this frame belongs to, as on render
segments The render segment shape, played the same way. The backend sends one sentence per frame

The utterance

A speech frame counts as a frame of the turn for the frame wait. The first one counts as the turn's first render.

The speech frames of a turn open one utterance. The next render of that turn plays its segments and closes the utterance, even a silent render. It carries the rest of the reply, with the cues still unplaced.

The utterance also closes on the turn's turn_end, on the frame wait passing, and on the socket leaving ready. The sentences already sent finish playing.

A render or speech frame of another turn closes the open utterance before it plays.

A user action that stops speech ends the utterance through the same interruption that stops a render.

What a slice may do

The backend cuts speech frames from its reply while it is still writing it. The client plays them as they arrive.

  1. A speech sentence may join two lines of the finished reply with no space between them. A cue that names the second line then plays later in the reply.
  2. speech frames may repeat a sentence.
  3. The render may repeat sentences already sent as speech.
  4. A turn may carry no speech frames. Its whole reply then arrives in the render.

turn_end (backend → client)

{ "type": "turn_end", "turn_id": "1789365854947", "usage": { "input_tokens": 1200, "output_tokens": 80, "total_tokens": 1280 } }
Field Value
turn_id The turn the frame closes
usage Optional. The token usage of the turn's last LLM call, not a sum over the turn (what it carries)

What usage carries

usage holds input_tokens, output_tokens and total_tokens, all numbers. These are the same figures the request transports' usage readout takes. The client shows total_tokens beside the context window size.

usage is absent when the backend has no usage for the turn. A usage that does not carry all three as numbers is read as absent. The frame still ends the turn.

When the frame goes out

The frame goes out once per turn, after its last render. A turn with no render sends it alone. It releases the running state the turn frame set.

  • A backend that holds renders for a client that is away holds turn_end behind them, in the same order.
  • A turn the backend interrupts to run a later turn on the same chat gets its turn_end after the later turn's frames.
  • A turn whose text the backend takes into a turn already running on the same chat ends when that turn ends.
  • A turn may get its turn_end before any of its renders. A render naming a turn the client has already closed still plays.
  • A turn that fails gets its turn_end after its error frame; after the backend's failure line renders, when the client did not list error in accepts; or before the next turn's frames, when the backend has no failure text.
  • A turn_end for a turn the client does not hold still passes its usage to the readout.

error (backend → client)

{ "type": "error", "turn_id": "1789365854947", "message": "Provider returned 429: rate limit reached" }
Field Value
turn_id The failed turn: the turn the client sent, or the id the backend minted
message The backend's own failure text, one line

The backend sends error only to a client whose hello lists error in accepts. It sends it when a turn fails, and before that turn's turn_end. The backend renders no failure line for that client, and the turn_end still closes the turn.

A turn that gets an error frame ends as failed on its turn_end. The client speaks its failure line. It shows message where it shows the server text of a failed request, as one line cut at 200 characters with no status in front.

A turn the user typed shows it in the input's error line while the input is open, and in the status pill's notice once the input has closed. A turn the user spoke shows it in the status pill.

The frame counts as a frame of the turn for the frame wait. An error frame for a turn the client did not send shows nothing. An error frame for a turn the user stopped is dropped.

tool_status (backend → client)

{ "type": "tool_status", "turn_id": "1789365854947", "state": "running", "tool_id": "read_file" }
Field Value
state "running" when the tool call starts, "done" when it returns, "failed" when it failed
tool_id The tool name as the backend knows it

The backend sends tool_status while the turn runs, once per state change of a tool call. A failed call carries "failed" in place of "done".

The frame counts as a frame of the turn for the frame wait. It leaves the running state, the thinking motion and speech as they are. A turn may carry none.

A tool_status for a turn the client did not send shows the status pill's tool segment and speaks no tool phrase. A running tool that gets no done is cleared by the turn's turn_end, and by the socket leaving ready.

A tool_status naming a tool the client declared and runs itself, yui_run, leaves the status pill as it is. That tool's status comes from the client's own run. The frame still counts as a frame of the turn for the frame wait.

tool_call (backend → client) and tool_result (client → backend)

A call against a tool the client declared in hello.tools or a tools frame.

{
  "type": "tool_call",
  "id": "c-1a2b3c",
  "turn_id": "1789365854947",
  "name": "body_action",
  "arguments": { "action": "sit_on_window", "app": "Notes" }
}
Field Value
id The call id, minted by the backend. The tool_result echoes it
turn_id The turn the call belongs to: a client turn id, or one the backend minted
name The tool name, one of the functions the client declared in hello.tools or a tools frame
arguments The call's arguments, a JSON object shaped by the tool's schema
{ "type": "tool_result", "id": "c-1a2b3c", "turn_id": "1789365854947", "result": "ok" }
Field Value
id The tool_call id this result answers
turn_id The tool_call's turn_id
images Optional non-empty array of image data URLs beside the result text
result The tool's answer, a string

The client's rules

  1. Calls of one chat run one at a time, in arrival order. The client's wait starts when the call starts running.
  2. A tool_call is answered at once with error: unknown tool when its name is not declared. It is answered with error: turn stopped when its turn_id is a stopped turn.
    • Its arguments are checked after the call queues. The tool then answers error: missing field <name>, error: invalid field <name>, or its own error text.
  3. A tool_call whose id repeats one queued or running is dropped with a log line and not answered. An answer would resolve the original call's waiter.
  4. A result whose frame would pass its applicable size limit is answered error: result too large instead. A result the client cannot send (the socket is not ready) is logged and dropped.
  5. A tool_call the client cannot read, such as a field of the wrong type, is dropped with a frame_malformed log line. It gets no tool_result, and the backend's wait answers it.
  6. The status pill takes its tool state from the backend's tool_status frames. The client emits no tool_status of its own for these calls.
    • yui_run is the exception. The client runs it itself and shows its running and terminal state locally, labelled with the namespace its script's yui call started last, or the plugin tool a yui.plugins.call names. A backend tool_status naming it does not change the status pill. It still counts as a frame of the turn for the frame wait.

Image results

For an image result, the client fits the images into the remaining frame budget with the same JPEG fitter used for turn.images. The final serialized frame, including ids and text, must fit the limit. When nothing fits, the result is error: result too large with no images. Text-only results keep the text frame cap.

The backend adapter's rules

  1. The handler of a declared tool sends tool_call and blocks on tool_result for the wait in the limits table, counted from the send.
  2. The adapter sends one call at a time per chat. A handler whose chat has a call in flight waits for its turn, so the client never holds a queue in practice.
  3. On stop naming the turn, on socket close and on socket replacement, every waiting and in-flight call of that chat or turn is answered error: client disconnected (or error: turn stopped) at once. It is never sent later.
  4. A tool_result whose id is absent from the pending table is ignored.
  5. A wait that passes answers error: no reply from the client within <n> s.

A client and a backend that do not match

A client that declares tools against a backend that predates them hears nothing: the backend never sends tool_call. A backend that speaks tool_call against a client that sent no tools registers nothing.

reasoning (backend → client)

The backend's reasoning as it is written, sent while the turn is running.

{
  "type": "reasoning",
  "turn_id": "1789365854947",
  "delta": "The log is the first place to look."
}
Field Value
turn_id The turn the reasoning belongs to
delta The reasoning written since the previous reasoning frame

Frames are coalesced, so one carries however much arrived in the window. They are best effort. A backend under load drops them, and a turn may carry none at all.

The render frame's reasoning field is where the text arrives whole, from a frame that plays. A render dropped for a stopped turn abandons the reasoning still streaming for that turn. Text that an earlier render already finished stays.

A reasoning frame of a turn the user stopped is dropped like the turn's other frames. The turn's turn_end ends reasoning still showing.

While one turn's reasoning is streaming, the reasoning of a render that belongs to another turn is not shown.

delegations (backend → client)

The full list of work the backend has handed to background workers for this conversation, sent whenever it changes. The client replaces its list with each frame.

{
  "type": "delegations",
  "items": [
    { "id": "d-7f21", "title": "Sort the regression test list", "started_at": 1789365854947, "state": "running" },
    { "id": "d-5a03", "title": "Check log file sizes", "started_at": 1789365123000, "state": "done", "ended_at": 1789365701000, "status": "ok", "summary": "All three logs are under 10 MB." }
  ]
}
Field Value
id Stable per delegation
title First line of the task the backend handed over, cut to the limit in the limits table
started_at, ended_at Epoch milliseconds
state "running" or "done". A failed delegation is "done" with status: "error"
status On a done item only: "ok", "error", or "unknown" when the backend cannot tell
summary On a done item only, when the worker returned text: its final answer, cut to the limit in the limits table

The list in the chip

The client keeps the latest list. A done item leaves the chip 30 minutes after ended_at.

The history the client keeps

The client also keeps a history of every item it has seen across backend restarts. Past 200 items, the oldest done ones are dropped. A running item is never dropped. A running item that a later frame leaves out is recorded as done with status: "unknown".

The history lives in localStorage, one history per preset: yui.delegation_history for the default preset and yui.<id>.delegation_history for each other preset. The settings window's Session section lists the history of the preset it edits and opens a finished item's summary under its row.

Asks

An Ask is a question the backend holds open for the user in a character's own chat. The user's reply is an Answer.

ask (backend → client)

{ "type": "ask", "ask": { "ask_id": "a1", "prompt": "Run `uptime` on **aemeath**?", "choices": [{ "id": "once", "label": "Allow Once", "tone": "primary" }, { "id": "deny", "label": "Deny", "tone": "danger" }], "text": false }, "expires_at": 1793690000000 }
Field Value
ask The Ask, with the fields below
expires_at Optional epoch milliseconds after which the backend takes no answer. Absent, the Ask has no deadline

Ask fields

Field Rule
ask_id Required non-empty string, at most 128 code points
prompt Required non-empty string. No length cap of its own; the text frame size applies
choices Optional array of at most 6 choices with unique ids
multiple Optional. Omitted or null means single-select; true requires non-empty choices
text Required boolean: whether free text is accepted
placeholder Optional string, at most 200 code points

Each choice has a required non-empty id and label, each at most 64 code points. Optional tone is primary or danger.

  • prompt is Markdown, rendered as Thread entry text is.
  • choices absent reads as none.
  • The client closes the Ask at expires_at, when it has one.
  • A second ask with an ask_id the client holds replaces that Ask in place.
  • Several Asks may be open. The client shows the oldest first and sends an Answer only for the one it shows.
  • The client's own Settings requests share the Ask slot with Asks, in arrival order, each on its own card. An Ask that arrives while a Settings request shows waits behind it.
  • A Settings request closes unanswered 60 s after it shows.
  • The card shows in the message window while it is popped out and unified chat is hidden. Otherwise it shows in the character's (pet) window. The card moves when that changes.
  • Unified chat shows no card.
  • An answered or ended Ask closes in both windows.
  • The backend sends ask only to a client whose hello accepts lists ask.
  • While the client is away, the backend holds open Asks. After ready on the next connection whose accepts lists ask, it sends the unexpired ones.
  • The client drops every Ask when the socket leaves ready.

answer (client → backend)

{ "type": "answer", "ask_id": "a1", "choice": "once" }
Field Value
ask_id The ask_id of the open Ask
choice Optional choice id the Ask offered
choices Optional non-empty array of distinct offered ids, only for a multiple Ask; never with choice
text Optional free text, sent only when ask.text is true
  • An answer carries a valid pick (choice or choices), non-blank text, or both. The client trims text and omits it when blank. The text frame size applies.
  • A multi-select Answer uses choices even for one pick, in the Ask's choice order, and never choice. A text-only Answer omits both.
  • A choice belongs to the Ask it answers.
  • The client sends answer only while the socket is ready.
  • A backend leaves the Ask open when the Answer names a choice the Ask did not offer.

A multi-select Ask and its Answer:

{ "type": "ask", "ask": { "ask_id": "a2", "prompt": "Which targets?", "multiple": true, "choices": [{ "id": "dev", "label": "Development" }, { "id": "prod", "label": "Production", "tone": "danger" }], "text": true } }
{ "type": "answer", "ask_id": "a2", "choices": ["dev", "prod"], "text": "Deploy both" }

ask_end (backend → client)

{ "type": "ask_end", "ask_id": "a1" }

The Ask closed without this client's answer: it timed out, someone answered it elsewhere, or an interruption ended the run. The client closes that Ask.

Backend commands

A Backend command is a command the backend states in ready. It runs when the user types /name in the text input. Its output is a Command reply: text the client shows above the input and writes to its log.

A Command reply is never speech and never a turn. No render, speech or turn_end carries it.

The unified chat window runs a Backend command for its one picked recipient through that character's pet window socket.

ready.commands (backend → client)

{ "type": "ready", "chat_id": "yui-3f9a2c1d", "commands": [{ "name": "status", "description": "Show session info", "args": "" }, { "name": "model", "description": "Switch model for this session", "args": "[model|reset] [--provider name]" }] }
Field Rule
commands Optional array of at most 100 commands with unique names. Absent means the backend states none
name Required, matches ^[a-z0-9][a-z0-9_-]{0,31}$
description Required string, at most 200 code points
args Required string, at most 200 code points. "" when the command takes none
  • The backend sends commands only to a client whose hello accepts lists command_reply.
  • The client reads a commands value that breaks a rule as absent.
  • A typed /word whose name is not listed is an ordinary turn.

command (client → backend)

{ "type": "command", "id": "c1", "name": "model", "args": "gpt-5" }
Field Value
id A string of at most 128 code points the client mints for this command
name A name from ready.commands
args The text after the name, trimmed. "" when none
  • The client sends command only while the socket is ready and no turn of the chat is outstanding.
  • The client sends one command at a time per chat.

command_reply (backend → client)

{ "type": "command_reply", "id": "c1", "text": "Model switched to **gpt-5**." }
Field Value
id The id of the command it answers
text Markdown. "" when the command printed nothing
  • The backend sends exactly one command_reply for each command while the connection lasts.
  • A text that would exceed the frame size is cut, ending with ….
  • A command may raise an Ask, such as a confirmation. Its command_reply then waits for that Ask's answer, or for its end, when the reply says the command did not run.
  • A command open when the connection drops gets no command_reply. The client drops its pending command when the socket leaves ready.

Logging

Turn records

A turn sent over the socket writes a turn record with spoke_text: false.

A render writes a push.render record with source, turn_id, the segment count, whether any speech played, and whether speech is still owed when the frame arrives.

A render dropped for a stopped turn is logged as a render line with dropped: "cut_turn" and stopped_count, how many stopped turns are still waiting for their turn_end.

A speech frame writes push.speech to the app log with turn_id and the segment count. One dropped for a stopped turn also carries dropped: "cut_turn" and stopped_count.

Waits and what they write

Before the turn's first render, a frame wait that reaches the limit writes network_stall with stage: push_wait. A wait that the socket leaving ready ended writes network_drop with the same stage.

After the first render, both carry stage: push_turn_end, and the turn counts as delivered.

Turn end, error and stop

A turn_end writes push.turn_end to the app log with turn_id.

An error frame writes push.error with turn_id and message. One dropped for a stopped turn carries dropped: "cut_turn" and stopped_count instead.

A turn that ends on its turn_end after an error frame writes no network_drop line. A stop that went out writes push.stop with the number of turns it named.

Tool and frame records

A tool_status frame writes push.tool_status with turn_id, state and tool_id. One dropped for a stopped turn carries dropped: "cut_turn" and stopped_count instead.

A frame over the size limit is never sent and is dropped unread on arrival. Either case writes frame_oversize with direction.

Connection records

The app log carries ws_open, ws_ready, ws_close with the close code, and ws_reconnect with the delay.