Follow one message
Press Send and watch every hop, from the keypress to the last streamed word.
You type “Why do shadows change length?” in a new chat and press Send. Your question appears, then a few words of the answer. Between those moments, Pipal opens a chat on disk, accepts the question, and starts the work that will answer it. That work is called a run. The browser watches it on a connection of its own.
In this chapter
- Follow the first Send from a browser draft to a saved conversation
- Tell an acceptance receipt from the update that puts words on screen
- See what changes when the model asks for a tool
- Understand what a retry or Stop asks the server to do
The first Send opens a chat
- Tab
- Hono
- Core
- Pi
- Model
- Disk
First Send
Tab → Hono · Create POST
Press Send on a new chat
The tab sends the title, profile, model, thinking level and a creation
requestIdtoPOST /api/v1/conversations. It includes the displayed approval mode asyolo, plus the location and project when selected. For this question the title is “Why do shadows change length?”Hono → Core · create()
Give the chat a place to live
After the HTTP and JSON checks, Hono calls
runtime.create(). Core saves the empty conversation and its settings through Pi Durable, pinning the location and any project. It records the chat ID in the creation receipt and gets the current snapshot.Hono → Tab · 201 Created
Select the new chat
The response body is the conversation snapshot itself. The tab reads its
id, selects that chat, and applies the empty snapshot.Tab → Hono · Events GET
Open a separate events connection
In the visible tab,
watchConversation()creates an EventSource forGET /api/v1/conversations/:id/events?delta=1.Tab → Hono · Message POST
Send the question itself
After creating the EventSource, the tab fingerprints the payload and sends
{text, requestId}as JSON toPOST /api/v1/conversations/:id/messages. This ID belongs to the message.The tab does not wait for the events GET to connect. The watch can attach before or after admission.
Hono → Core · submit()
Take a turn in the admission queue
Hono checks host, Origin, session, body size, and JSON before calling
runtime.submit(). Core validates the input, then takes its turn in the queue and looks for a receipt. For a fresh send it checks archive status, model, chat activity, and host capacity.Core → Pi · conv.admit()
Place the input inside the commit
Core asks Pi Durable to place the input with
whenBusy: "reject". In the same transaction Core records the deadline.Pi → Disk · Commit
Save the question and its work together
The commit stores the user entry, the generation task, the submission record, and the deadline.
Hono → Tab · 202 Accepted
Acknowledge the POST
Core checks and arms the deadline after the commit, then returns
{id, requestId}. Hono sends that receipt. The tab clears the draft if it is still the draft for this attempt.The next steps follow generation and the events GET. Both can already be making progress before the 202 arrives.
Pi → Model · Model request
Ask the model to answer
The admitted generation task prepares a request from the active conversation and agent settings. Pi AI handles the call to the selected provider.
Model → Pi · Partial text
Catch the first words
As text comes back, Pi Durable updates the live generation in
pi.live.Hono → Core · watch()
Open the conversation watch
On the events request, Hono calls
runtime.watch()and awaits its first value before opening the 200 event stream.The watch can produce its first value before the model starts.
Core → Hono · Watch value
Project the current conversation
A value includes the recent transcript and live state. The saved question can already be in the first value, and Core can coalesce changes.
Hono → Tab · SSE update
Draw the question and growing reply
The first event is
snapshotwith{version: 1, snapshot}. Later changes arrive asdeltawith{version: 1, revision, edits}. The browser applies the resulting view to the transcript. A fast answer can reach the tab without a separate visible partial.Pi → Disk · Final answer
Append the completed answer
Pi saves the assistant’s answer as a transcript entry.
This commit can land before the browser has drawn any partial text.
Hono → Tab · Saved answer
See the completed entry
The watch can include the answer in the first snapshot or in a later change. The browser shows the completed assistant entry in the transcript.
A tool round
Pi → Model · Model request
Ask with tools available
In a chat with
workspace_readenabled, suppose the model answers a question about two files by asking to read both. Start this path after admission.Model → Pi · Two read calls
The model asks Pipal to read
The model returns two tool calls. Each names a tool and supplies its arguments.
Pi → Core · First read
Start the first call
Pipal sets Pi Durable’s tool execution to sequential for this path. The second call waits while the first is running.
Core → Pi · First result
Collect the first result
The tool returns its result to the harness. The round still has a call left.
Pi → Core · Second read
Start the second call
With the first call settled, the harness runs the second.
Core → Pi · Second result
Complete the round
The tool results are now available for the next model request.
Pi → Model · Next request
Give the model what the tools found
The harness makes another model request with the results in context. The model can answer now or ask for more work.
Hono → Tab · Reply updates
Watch the answer arrive on the same stream
The two reads can share a collapsed tool group while they run and after their results arrive. Open it to see each read in call order. The tab sent one question for the whole exchange.
Tab → Hono
Press Send on a new chat
The tab sends the title, profile, model, thinking level and a creation requestId to POST /api/v1/conversations. It includes the displayed approval mode as yolo, plus the location and project when selected. For this question the title is “Why do shadows change length?”
Before Send, you can change the profile or model while the chat is still a draft. On the first Send, the browser takes the first line of your question for the title and sends it to POST /api/v1/conversations with the draft settings. The profile supplies instructions, the model does the answering, and a supported thinking level requests a reasoning effort. If the host advertises workspace locations, the draft carries a workspace locationThe place a chat uses for project tools, either the Pipal host, an account reached over SSH, or a Docker project. choice. It also carries any selected project or automatic approval settings. The Svelte workspace follows the draft inside the browser. App.svelte index.ts
Core’s create() pins the location in pipal.chat, along with the project and scope when applicable. The scope is the value Core checks to confirm that the chat is still bound to the same workspace. To work in a different location or project, start a new chat. Three ways to touch a project follows the choice in Runtime. index.ts
The creation request also carries a request IDA value the client sends again when retrying the same input so the server can recognize it., a key the server can use to recognize the same operation on retry. For a first attempt the server saves the key with the new conversation and returns 201 Created with a conversation snapshotThe JSON view Pipal assembles for the browser from saved chat state, recent messages, and live work.. A snapshot is the view of a chat at a moment in time. On this first attempt, the snapshot describes an empty chat. A matching creation retry gets the current snapshot of the existing chat. index.ts app.ts
The visible tab selects the conversation, applies that snapshot, and creates an EventSource for GET /api/v1/conversations/:id/events?delta=1. It then fingerprints the message and posts it to /api/v1/conversations/:id/messages with a separate request ID. The browser starts the watch without waiting for the GET to connect. In an existing chat, Send uses the conversation ID it already has. App.svelte watch-conversation.ts
The receipt says Pipal has accepted the question
{
"text": "Why do shadows change length?",
"requestId": "b0a52c40-34a1-43e1-9bec-bdf9d86dc8fd"
} - Your question
The client trims the draft before sending.
- Key for this send
The browser retains this ID if you retry with the same payload.
{
,
} 1 Your question
The client trims the draft before sending.
Hono checks the destination, where the write came from, whether you’re signed in, and whether the body fits and has the expected fields. Then it hands the text and request ID to runtime.submit(). The Hono server follows those checks from the outside in. app.ts request.ts
Core gives each attempt its turn before deciding whether it can start answering. For this new chat with capacity available, Core asks Pi Durable to place the input and saves the deadline in the same commit. That step is admissionPipal’s acceptance of an input in the commit that saves the message, its work, and its run deadline.. One transaction in durable.sqlite commits your question, the generation task that will answer it, the submission receipt, and the deadline together. The core runtime explains how Core makes that decision. index.ts README.md
{
"id": "7",
"requestId": "b0a52c40-34a1-43e1-9bec-bdf9d86dc8fd"
} - Submission ID
Pi Durable assigns it. Core returns it as a string that identifies the accepted submission.
- The key you sent
Core echoes the key from the request.
{
,
} 1 Submission ID
Pi Durable assigns it. Core returns it as a string that identifies the accepted submission.
After the browser receives and parses the 202 Accepted receipt, it clears the draft if it still matches the attempt. Your question appears when the watch reports the saved entry. The timing of the two requests can leave the composer empty briefly before the question appears. The client draws the transcript from the server’s view of the conversation. App.svelte
Deep diveWhat the POST actually waits for
For a fresh text submission, submit() makes a conv.commit() call. Inside it, place() calls conv.admit() with whenBusy: 'reject' and then sets the deadline. Pi’s contract makes the admission provisional until the whole commit lands. After that, Core calls arm() for the freshly placed submission while it still holds its turn in exclusive(). index.ts README.md
api.post('/conversations/:id/messages', async c => { const { text, requestId, attachmentIds, textFiles } = await body(c, message); const files = attachmentIds?.length ? { ids: attachmentIds, prepare: (vision: boolean) => uploads.prepare(attachmentIds, vision) } : undefined; return c.json( await runtime.submit(c.req.param('id'), text, requestId, files, textFiles), 202);});Browser API calls add the build’s base path and api/v1/, encode the POST body as JSON, and parse the JSON response. On the server, that await covers admission. Pi runs the generation task separately. Core starts a submission wait in arm(), uses its settlement to disarm the timer, and awaits the deadline check before returning. For files, the route supplies a preparation function and Core can release its place in the queue while preparation runs. Files in, artifacts out follows that path. api.ts index.ts
The answer grows in the live view
Pi Durable prepares the model contextThe instructions, messages, and tool information assembled for a model request., the material the model sees for this request. It includes the active conversation history and the agent’s settings. Pi AI handles the call to the provider. As text comes back, Pi Durable keeps the unfinished reply in a live document called pi.live. README.md
Core’s watch notices changes to the chat and projects its latest state into snapshots. Hono sends a full snapshot first, then sends changes as deltas when the snapshot differs. The browser applies those changes before updating the transcript. Several changes can arrive together, so a watch might show the question and answer in the same update. Live streams follows the format on that connection. index.ts app.ts
Deep diveWhat opens the events stream
Hono checks the session and starts runtime.watch(). It waits for the first value before sending headers, so a missing chat still gets 404. Core watches the Pi conversation and its pipal.chat document. Hono wraps the first public view as a versioned snapshot event, and the tab’s replica applies any later delta events in revision order. A hidden tab closes the watch and a visible tab reconnects for a fresh snapshot. app.ts index.ts watch-conversation.ts
A model can also ask the host to do something before it answers. A tool is an operation the model can request, such as reading a file in a chat that has file access. When the model requests tools in one reply, that makes a tool roundA model response that requests tools, together with the tool calls it requested.. Switch the figure to A tool round and watch the second call wait for the first to finish. The next model request can use both results. Tools and extensions explains how the model gets those choices. index.ts runtime.test.ts
In this example the transcript can show both reads under 2 tool calls. Open the row to see what each read returned. The Svelte workspace explains how the browser groups the calls as the stream updates. transcript.svelte.ts ToolGroup.svelte
Retry the send or stop the work
Core compares the text, the upload IDs in order, and the names and contents of inline text files in order. A match returns the original submission’s receipt, even if the run has already ended. A different payload under that same ID is a conflict. If the outgoing payload changes, the browser gives it a new ID. index.ts App.svelte
A run can finish with an answer or failure, or end because you stopped it or its time ran out. The browser sends Stop to POST /api/v1/conversations/:id/stop?runId=…, using the task ID from the running snapshot. It sends an empty JSON object and Hono replies with 202 Accepted and {ok: true}, even if the task has already given way to another one. A stale task ID leaves the new task alone. Closing the tab ends the watch without stopping the run. App.svelte app.ts
When a top-level chat offers Resume response, you can continue after Stop, a timeout, a turn-limit failure, or a final reply reserved as the tool budget ran low. That button sends a new input with a fresh budget and tells the model to continue from the saved conversation and tool results. Pipal can also supply the tail of an aborted reply. view.ts index.ts
Deep diveWhat a repeated request can recover
The browser stores the request ID alongside a digest, a SHA-256 fingerprint of the JSON payload. On another attempt it reuses the ID when the digest matches. Core does its own comparison against the stored entry. The model-specific preparation of uploads can change, so Core compares the original upload IDs. App.svelte drafts.ts index.ts
The creation POST has a separate receipt keyed by its UUID, and a retry can recover the original chat before the message is sent. After a lost reply, the browser reuses that saved creation request if the location and project are both unchanged. If the profile, model, thinking level, or automatic approval setting changed, it can PATCH those settings on the recovered chat before selecting it. A rejected creation with HTTP 400 clears the saved attempt so the next try can use a new request ID. App.svelte index.ts
A previous matching submission returns before the archive, model, and capacity checks for fresh work. A lost HTTP response therefore leaves two possibilities. A retry can get the receipt the first attempt saved, or it can be the attempt that actually places the input. The watch supplies the chat’s current state in both cases. index.ts
| A text-only message POST can return | What you know |
|---|---|
| 202 | Pipal accepted this input or found its matching receipt. |
| 400 or 415 | The JSON, fields, or input are invalid, or the media type is wrong. |
| 401 or 403 | The session is missing or expired, or the host or origin check failed. |
| 404 | The conversation could not be found. |
| 409 | The chat cannot accept the input now, or the ID belongs to different input. |
| 413 | The HTTP body exceeded its size limit. |
| 429 or 503 | Pipal refused new work because of capacity or shutdown. |
| 500 | The server encountered an unexpected error. |
A closed tab can reconnect to work still running on the host. What happens if it’s the host that stops in the middle of a sentence? Durable by default follows the records Pipal has when it starts again.
Recap
- On first Send, the browser creates the chat with its location and any project, starts watching it, and posts the question.
- Admission saves the input and its work together. The POST returns a receipt and the stream updates the transcript.
- A matching retry can recover the receipt. Stop targets the task the browser was showing when you clicked it.
- On your first Send, your question appears before the message POST finishes. How did it get there?
- The browser copied the draft into the transcript
- The event stream showed the committed entry
- The provider sent back the question
Answer and explanation
The event stream showed the committed entry
The transcript follows the server’s view on the events connection. The receipt travels back on the message POST.
- You retry a message with the same request ID and payload in the same chat after losing the POST response. Pipal already accepted it. What happens?
- Pipal starts another run
- Pipal returns the original receipt
- Pipal creates another conversation
Answer and explanation
Pipal returns the original receipt
A matching payload and request ID in the same conversation identify the existing submission.
- In the illustrated sequential tool round, the model asks for two reads. When does the second call start?
- When the first call settles
- As soon as the model names it
- When you reopen the tab
Answer and explanation
When the first call settles
Pipal configures sequential execution. Pi Durable finishes the first call before starting the next.
On your first Send, your question appears before the message POST finishes. How did it get there?
You retry a message with the same request ID and payload in the same chat after losing the POST response. Pipal already accepted it. What happens?
In the illustrated sequential tool round, the model asks for two reads. When does the second call start?