Skip to content

The agent protocol ​

Diffo never spawns an agent, calls a model, or holds an API key. The agent that wrote the code attaches to the review itself, by running one command, and everything it is asked to do arrives in the JSON that command prints.

This page explains that mechanism for a person: what "attached" means, what the agent receives, and what it is obliged to do with it. It is the page to read when you want to know why feedback went where it went.

The instructions the agent itself follows are generated, not written here. They live in the Agent Skill and in the prompt the server builds for every payload, both produced from the same source strings, so the two cannot drift apart. For command syntax, see the CLI reference.

What "attached" means ​

An agent is attached when it is holding an open diffo poll. That is the whole relationship: no registration, no handshake, no process of Diffo's running on the agent's behalf. Three things follow from it.

  • Feedback lands where the context is. The poll runs inside the session that wrote the code, so a comment arrives in the conversation that already knows why the code looks like that.
  • An agent that is not polling is not reachable. Sends queue instead, and the review says so (presence reads waiting). Nothing is lost; the next poll collects it.
  • Diffo does not care which agent it is. Any process that can run a shell command can drive the loop, registered or not.

The loop, from the agent's side ​

StepWhat the agent runsWhy it matters
1. Opendiffo --no-openStarts the review and prints the URL. --no-open because an agent should never throw a browser window at someone; it hands over the URL instead, immediately, before anything else
2. Guidediffo comment -m "…"One comment on the whole changeset (a map of the change, not a reading order), only when the changeset needs it, written while the reviewer is opening the page. See the guide comment
2b. Layersdiffo layers --suggest "…"Optional: a flag that this read benefits from layers. The layers themselves are posted only when the reviewer asks. See layers
3. Attachdiffo poll --title "…"Blocks until the reviewer acts, then prints one payload. The title becomes the reviewer's browser tab name; see the tab title
4. Re-attachdiffo pollBefore the work, not after it, so the agent keeps listening while it acts: see listening while working
5. Act(edits, and diffo reply)Work the threads the payload named, and answer each one. A reply is what settles a thread
6. Detachdiffo endWhen the review is over

Step 1 returns immediately, leaving a background server, so it is a short command and not something the agent waits on. Only the poll blocks.

The tab title ​

Every Diffo tab is titled "Diffo", which is fine until the reviewer has three of them open. The poll that attaches carries --title "<the change, in 2-3 words>", and that becomes the tab's whole name: tab titles, not tab titles · Diffo.

Two or three words is not a style preference. A tab in a crowded strip shows around twenty characters and cuts the rest, so the app's own name would spend half the budget repeating what the favicon already says, and the word that tells this review apart has to come first rather than last.

It is the agent's to send because the agent is the only party that knows what the changeset is at the moment it starts listening. The rules:

  • The newest title wins. A changeset that grows into something else renames its own tab on the next poll that carries one.
  • A poll without --title leaves the name alone, so re-polling through a long review never has to repeat itself.
  • Until some poll sends one, the tab reads "Diffo" exactly as it always did.
  • A review served from a source checkout reads dev · <title>, so a dev review is never mistaken for a shipped one at a glance.
  • Anything over 40 characters is cut with an ellipsis, a backstop against an essay, not a target.
  • The title is part of the review state: it survives a reload and a server restart, and it is dropped when the reviewer clears the review; that round is over, and the poll woken by the clear names the next one.

What a poll payload carries ​

One JSON object, discriminated by status:

statusMeaning
feedbackWork is waiting. The only status that carries any
timeoutThe 30-minute cap on this poll closed. Nothing is lost; poll again
quietTwenty polls in a row brought nothing from the reviewer (timed out, or cut off by the harness). Stop, ask the user whether to keep listening, and re-poll only on a yes; the next poll starts a fresh count
supersededAnother session took the review, or this session started a newer poll of its own. Do not re-poll
endedThe agent side detached with diffo end. Do not re-poll

A feedback payload:

jsonc
{
  "status": "feedback",
  "kind": "threads",           // "threads" = individual sends · "finish" = the reviewer is done reading
                               // "layers" = the reviewer asked for layers · "cleared" = they started over
                               // "reminder" = threads handed over earlier that still have no reply
  "threadIds": ["4f1c9a2e-…"], // reply to each of these
  "prompt": "…",               // the authoritative instruction (see below)
  "owed": [                    // handed over before this payload and still unanswered; absent when nothing is
    { "what": "thread", "id": "9b2d…", "where": "src/db.ts:214", "intent": "issue",
      "state": "no reply yet", "waiting": "6m" }
  ],
  "next_step": "…"             // what to do now: start the next poll, then act
}

owed is written by the server from each thread's state, never from the reviewer's words: the id, where it is anchored, and why it still counts (no reply yet, code changed, no reply yet, or a --more promise not yet kept). It rides every payload, a timeout included, so an agent is never more than one poll away from seeing what it has not answered. Layers the reviewer asked for and nobody posted appear there too, as "what": "layers".

prompt is prose, built server-side, and it is what the agent actually acts on. It carries the thread text, a snapshot of the hunk each thread is anchored to as it was when the comment was written, the intent contract below, and the reply protocol. Because it is assembled per payload, an agent with no skill installed and no memory of this page still receives complete instructions.

A kind: "finish" payload is the reviewer pressing Finish review: the whole batch at once, with coverage attached (38/42 hunks read, 2 files skipped). Any closing note leads that batch as its own thread on the whole changeset, with an id to reply to. It re-ships every thread that was sent, including ones already answered, and the prompt tells the agent not to answer those twice.

A kind: "layers" payload is the reviewer pressing Ask the agent for layers, or Layer again over layers that have gone stale. It carries no threads and owes no reply: the prompt restates the whole layers doctrine and asks for one diffo layers --json post, which is what concludes it. A kind: "cleared" payload is the reviewer starting the review over; it owes nothing but a fresh guide, if the changeset warrants one.

Change or Question: the intent contract ​

Every thread carries the reviewer's intent, and the contract is two lines, shipped verbatim in the prompt:

question threads want an answer, not an edit. Reply in the thread; change no code for them unless the reviewer asks.

issue threads want a code change. Address each one, or push back in the thread with your reasoning.

This is the load-bearing distinction in the whole tool. A reviewer asking "why a Map here?" wants a sentence, and an agent that answers with a refactor has made the diff worse and moved the code under a reader mid-review. Disagreeing with a change request is allowed, in the thread, with reasons. Ignoring it is not.

The prompt adds two rules with the same intent: change only what the threads ask about, and re-read the current file before editing, because the snapshot in the prompt was frozen when the comment was written.

Listening while working ​

Two facts about an agent are kept apart, because for a long time they were one and that was the loop's weakest point.

Listening is whether a poll is attached. Owed is the list of threads the agent was handed and has not answered. A poll says only the first: I am listening. It never says I am done. Only a reply settles a thread (or the reviewer resolving or deleting it, or diffo end).

So the order is: read the payload, start the next poll, then work. A reviewer who writes stop, do it the other way while the agent is mid-fix is heard mid-fix, instead of after the whole batch. The payload's next_step says this every time, in both shapes, because only the agent knows which harness it runs in:

The poll…Order
runs as a background task whose completion wakes the agentpoll first, then act
holds the turn (a foreground poll)act and reply first, then poll

What keeps a listening agent from being interrupted for every keystroke, and from quietly dropping a thread:

  • Sends are batched while it works. With a batch in its hands, a new send waits until the sends stop for 8 seconds (30 seconds at most), so three quick comments are one interrupt. A Finish review is never held. An idle agent is woken at once.
  • Every payload lists what is owed, and so does every command's ack (below).
  • A stalled thread is handed over again. After 5 minutes with no reply, the owed threads return as a kind: "reminder" payload, in full, because the likeliest reason for the silence is a session that lost their text. Edits in the working tree read as the agent at work and push that back, for up to 15 minutes.
  • After 3 reminders the review stops waiting. One more silent window and the thread reads no answer, and the reviewer can send it again. A thread the agent decided not to act on still needs a reply saying so: a reason is an answer and silence is not.
  • Owed threads alone never end a poll. Only new feedback, a reminder whose clock ran out, the poll window, or a detach does. Otherwise every poll would return at once and the agent would spin on its own debts.

A reviewer agent's thread follows the same rule as the human's. Its reviewer keeps waiting through the reminders, and leaves once the thread reads no answer.

A batch also ends when the agent runs diffo end, or when its session dies. Whatever was still owed is recorded as unanswered. When another session takes the review over, what the first one still owed goes to the newcomer in full: it never saw those threads.

What an ack says about polling ​

Every command the agent runs (reply, comment, layers, …) ends its next_step with the one true thing about polling at that moment, read from the review:

StateThe ack says
A poll is attachedYour poll is still listening: do not start another
No poll, nothing owedNo poll is listening: run diffo poll now
No poll, threads owedStart it now if it runs in the background; if it would hold the turn, finish what is owed first

A fixed then run poll line told an agent that was already listening to start a second poll, which released the first and woke it for nothing. A second poll from the same session still releases the first, and the first is told exactly that.

The guide comment ​

Right after handing over the URL, an agent is asked to judge whether a cold reader needs orientation, and if so to post exactly one comment on the whole changeset. The URL goes first because writing a guide is the slowest step of an open, and a reviewer waiting for a link should not wait on a diagram: the guide lands live at the top of the review, and a banner points at it if they have already scrolled into a file. The doctrine is stated once in the source and interpolated into every surface that teaches it, so all of them say the same thing:

WhenMulti-file, structural, or subtle. Skipped when the diff explains itself
WhatA map of the change, not a tour of it, written for a reader who never saw the session: the problem it solves and what it changes, in a sentence or two; the flow it changes, from what sets it off to what someone sees, as a small ```mermaid diagram when a picture beats words (functions where code carries it, people and screens when they are the flow, never a file list or which code references which); what has to stay true, as checks for the reviewer to run (an invariant the change must keep, a judgment call it made, a shortcoming it knows about); and what they can skip. Ingredients, not sections: a rename needs no diagram, a one-file change needs no checks
Not in itA reading order or a file list. Layers and the Files tab own those; a change that reads better in order gets diffo layers --suggest, not a numbered guide
How muchAbout a hundred words of prose plus the diagram, one screen
The legendIn the diagram, new code is tagged :::new and changed code :::changed, with two classDef lines diffo help guide prints verbatim; a plain node is anything existing the change now leans on. A reviewer sees the seam where new meets old by color, in the same visual language on every review
The changeset mapA ```changeset-map fence draws Diffo's live map of where the change lands: the files as boxes in their folders, sized by how much changed. It is a picture for one line, cheaper than an artifact, so the agent puts one in the guide when where the change lands is part of the story, optionally with one line, color: steps, review or change. It never draws a file map of its own
The line it must not crossOrient reading, never pre-review: no verdicts, nothing is "fine"
When it goes staleThe agent replies to its own guide thread with a short update, rather than posting a second guide

The reason it is a map: every other tool infers a summary by reading the diff back. The session that wrote the change still holds what no diff shows — the invariant it had to respect, the seam it chose, the alternative it rejected, what it left alone on purpose — and that is what a reviewer cannot get anywhere else. Pre-review is the one thing it may not add: a guide that says the change is correct has judged the code for the person whose independent judgment is the reason Diffo exists. If a takeover happens, the new agent inherits the existing guide and updates it in place, so the reviewer never ends up with two.

The map is also navigation. A file the guide names — as `path` or `path:line` in prose, or in a diagram node — becomes a jump to that file in the review, the same way a layer summary's references do. diffo help guide carries the whole doctrine and one worked example, labelled as one shape that works rather than the shape.

Layers ​

A diff arrives in alphabetical order, which is almost never the order it should be read in. Layers are the agent's reading plan: the change split into a few layers, each one rule or idea a person would explain in one breath, with a title that states it and the lines that belong to it. They come from the agent only, because the session that wrote the code still remembers what it changed and why; Diffo never guesses a plan from paths, and with no layers the review is exactly the flat file list.

Two commands, one doctrine:

Suggestdiffo layers --suggest "<why, in one line>", at open, next to the guide. It flags that this read benefits from layers, without writing them. The review shows the offer to the reviewer; the reason is quoted next to it. Add --preset <id> when one of the reviewer's presets fits the change (the open's output lists the ones that are on): the Layers tab then opens on it, with your reason, unless the reviewer has a default of their own. A preset that is not on is dropped, and the ack's note says so
Postdiffo layers --json '<post>', or the same JSON piped to diffo layers --stdin. A post is { "preset", "layers": Layer[] }, or a bare Layer[] for layers that follow no preset. Posted only when the reviewer asks, because writing layers is the heavy step and most changesets never need them. When the JSON is too long to inline, write it to a file in one command and pipe that file in the next, never both in one: a harness that screens each command on its own (Claude Code's auto mode, for one) refuses a post it cannot trace back to the session, such as a pipe from a file the session never visibly wrote
The askThe reviewer's click arrives through the poll as a kind: "layers" payload, with the doctrine restated and no threads to answer. The Layers tab reads Layering… and the presence chip layering the change until the post lands; a poll does not end the wait, because the agent listens while it writes them. Layers owed for three minutes read as stalled: the tab says the post never came and why it might not have, and offers the ask again, which withdraws the old one. After six the request lapses on its own
PresetWhat the layers are for, chosen before you write them (see What the layers are for). The ask names it: the reviewer picked a preset, and the payload carries its instructions, which decide what goes in the layers, in what order, and what goes to background; or the pick was left to you, and the payload lists the presets that are on, each with its use it when and instructions — choose by the change, follow it, and post "preset": { "id": "<its id>", "picked": true, "why": "<one line>" } so the reviewer sees the pick and the reason
NoteThe reviewer's words for this change only, sent with the ask. On top of a preset the payload quotes it after the preset's instructions: follow both, and the note where they disagree. With no preset (One-time instructions) the note is the whole ask, and the post carries no preset. The note is never part of the post: the server keeps it with the layers the post answers, and a re-post nobody asked for keeps it too
Talking about a presetEvery preset has a conversation with you in the Layers presets dialog. A kind: "preset" poll payload carries the preset as it stands and the messages so far; the last reviewer message is what to act on. The reviewer can start a new conversation, which clears the messages and keeps the preset, so never rely on an earlier turn being there. When they want it changed, diffo preset update <id> --json '{ "<field>": "…" }' --message "<what changed>" sends only the fields you change — a preset nobody has yet is made from them (a name at least), and a built-in is never edited: copy it under a new id of your own and say so. The message is your line on what you changed and why; it shows in the conversation with an undo. When no edit is needed, a question or advice against the change, diffo preset reply <id> --message "<text>". One of the two per message; nothing else is owed. diffo preset list and diffo preset show <id> read; diffo help preset has the fields: a name under forty characters, a one-line blurb saying in plain words what the layers show, use it when for an agent choosing among presets, and instructions concrete enough that two agents following them post the same layers
Add to layersThe light ask, from the Since your review label: not a new split. The payload carries the layers as they stand, as the JSON a post takes, and what is outside them; put each path in the layer it belongs with, add a layer at the end only for something none covers, and re-post the whole list. The layers keep the preset and the note they had, whatever the post names
Layer againThe same ask over existing layers, from the Layers tab's menus. The payload names the layers they have and asks for the whole list again. Ids survive for titles that match, so the reviewer's place holds. The reviewer can also remove the layers from the tab's menu; the next ask starts from none
When to suggestWhen the change has an order worth explaining. A wide diff with one idea does not need layers; four files can hide three steps. Agent judgment, no file-count threshold
TitlesThe reviewer reads every title and may read nothing else, so the title is the finding: one full sentence stating what is now true, present tense, leading with who or what it is about (Refunds over $500 need a second approver). Not a topic (Refund approvals), not a question (Who approves refunds?), not what was done to the code (Refactor checkout middleware), not a place. Plain words, about nine, twelve at most. Only what the lines show: a title that overstates is worse than a vague one, because the reviewer remembers the title and not the code. Background and mechanical layers are titled plainly by what they hold (Tests, Call sites and imports)
OrderThe preset's instructions decide: by Importance, what would cost the most if it were wrong comes first; by Concept, each layer needs only the ones before it. With no preset, the order you would explain the change in. Mechanical and background layers always go last
Mechanical"kind": "mechanical" marks a layer that changes no behaviour (a rename, moved code, import lines, call sites following a signature); its files render folded. A moved file that was also edited is not mechanical: its edited lines go to the layer for what they change, because a move is where a dropped check hides. If unsure, don't tag
Background"kind": "background" marks a layer the reviewer skips. Tests, docs, styling, generated files, lockfiles and build wiring always go there, and so does whatever else the preset sends there (by Importance, the implementation behind the key layers). One thing in a test is worth a line: an expectation that was removed or loosened is named as a decision, with its at, in the layer whose rule it pinned. List its files whole. The lines a review layer highlights are that layer's, and a background layer holds what is left of each file, so the complement of a highlight is never worked out by hand; a file the review layers took whole simply contributes nothing. Background layers go last; the reviewer sees them in their own section under the ones for review
SummariesTwo sentences of prose, about forty words. First what was true before and what is true now, concretely: the values, the roles, the status codes. Then what follows from it (who or what is affected, what can no longer be undone), with the reason in a clause when the change gives one. No retelling of the code, no file names. When a behaviour change is one nobody asked for, the summary says exactly that. The guide's line holds verbatim: orient reading, never pre-review
FilesA file entry is its path. Listed bare it claims every changed line of the file, which is right only when all of them belong to the layer. When a file holds lines of more than one layer, each layer names its part: with a highlight, or as path:from-to (head-side lines; the ask lists every file with its hunks' ranges, so a split is a copied range), in every layer that has a part of it, never bare in one review layer and by range in another. Split wherever a file changes for two reasons; a file many features share (styles, a registry, shared types) usually does. Every changed line belongs in some layer: the post's ack reports any it leaves out, and the fix is a re-post with them placed
HighlightOn by default: a file object's "highlight" names the head-side lines ("40", "12-18", or a list of up to thirty) the step is about within the file. It also decides which changed lines the step owns: a hunk with no highlighted line is not in the step, and a hunk several steps share is listed in each with its own lines lit. A file or hunk listed without a highlight owns all of its changed lines, and a highlight that lights none of the entry's changed lines is ignored. Each changed line belongs to exactly one layer: the post is refused when two layers claim one, and reports any no layer claims. A deleted line goes with the head line right after it, so a deletion is claimed by highlighting that line. The numbers are checked against the file as it stands after the change: a highlight that covers no changed line is ignored, and the whole file is claimed in its place. Left out only when every changed line of the file is the step's (a new file read top to bottom, a mechanical step)
DiagramsWhen the step has a shape (a flow, a decision, a before/after), a small ```mermaid diagram usually beats prose. Nodes are tagged :::new / :::changed with the guide's two classDef lines
DecisionsUp to five per layer, each one short line (under eight words) with a one-sentence detail and an at, where it lives: path, path:line or path:from-to, or a list of up to three such places when the decision spans hunks (the rule and the test that pins it). A decision is where the agent chose between real alternatives a reviewer might weigh differently (a cache, a data shape, a fallback), where the code now does something the diff does not make obvious (a 400 where there was an empty list, a sort every caller sees), or where something in the repo or the environment shaped the change (no clock on the model, tests that could not run). Only what a reviewer could want done differently or would be surprised by later; nothing about naming or style; no verdicts. Each line is a concrete statement in plain words, the answer to "what did you decide here?" for a teammate who has not seen the code, understood in a second: no project nicknames, no clever phrasing, the effect rather than the mechanism. Most layers have none — a plumbing step has nothing to decide, so the list is left out

A post, and a layer in it:

jsonc
{
  "preset": { "id": "importance", "picked": true, "why": "a large feature the reviewer owns" },
  "layers": [ /* Layer[] */ ]
}
jsonc
{
  "title": "Weekday resolution",
  "summary": "A bare weekday resolves to the *next* occurrence. Read `weekday.ts` first.",
  "kind": "mechanical",            // optional: "mechanical" (changes no behaviour) or "background" (how it's done, nothing to decide)
  "files": [
    "src/weekday.ts",
    { "path": "src/dates.ts", "note": "delegates to resolveWeekday; the old arithmetic goes" },
    "src/routes.ts:40-62",         // part of a file: the hunks these head-side lines touch
    { "path": "src/parse.ts", "highlight": ["14-19", "33"] }   // the lines this step is about
  ],
  "decisions": [                   // optional, at most five
    {
      "text": "A bare weekday means next week, never today",
      "detail": "The ask didn't say. Same-day would need a clock the todo doesn't have.",
      "at": "src/weekday.ts:31-36"
    },
    {
      "text": "Unknown ?due= values return 400, not an empty list",
      "at": ["src/routes.ts:45-47", "test/routes.test.ts:12"]   // one place, or up to three
    },
    { "text": "Todos have a date, never a time", "at": "src/model/todo.ts:8" }
  ]
}

The reviewer sees the decisions under the layer's summary, one line each, and . walks them, landing on the first place. Opening one shows the detail, a chip for each place that goes there, and Comment, which opens a comment on the layer with the decision quoted: a layer thread, in the payload like any other, opening with > decision: ….

Files are listed by path relative to the repo root. A bare path is the whole file; path:from-to is the hunks those head-side lines touch, for a file whose hunks belong to different steps — the same path then appears in each step with its own range, and the reviewer sees in each step only that part, with the rest folded under the name of the step it reads in. A path listed whole in one layer and by range in another is refused. Unknown paths are accepted, since the file may land later, and simply show nothing until they do.

A highlight on a file object lights those head-side lines in the pane and dims the rest of the hunk (Show this layer changed · lines on the layer card, the default; hunks shows the hunk plain). The entry then holds only the hunks its highlight lights a changed line in, within its range if it has one, and claims those changed lines; a file or hunk listed without a highlight claims all of its changed lines. Each changed line belongs to exactly one layer: a post that claims a line in two is refused with exit 1, naming the lines and layers (src/a.ts:31-33 (layers 2, 4)).

The ack names what the layers left out: { "ok": true, "layers": 4, "uncovered": [{ "path": "src/a.ts", "ranges": ["88-95"] }, { "path": "src/b.ts" }], "next_step": "…" }. The layers are live regardless, with the leftovers under Since your review, lit; the next step is a re-post with them placed. A range is the head-side lines of changed lines no layer claims, a deleted line named by the head line it goes with; a path alone is a file no layer names.

The rules that make a post safe to repeat:

  • A post replaces the whole list. The agent never diffs its own layers. Ids are minted by the server and kept for every title that survives a re-post, so the reviewer's active layer stays under them.
  • Resolution happens at render. Layers are re-resolved against the live changeset on every refresh. A file the agent touches after posting lands in a derived trailing layer, Since your review, which is never stored; the agent absorbs it by re-posting. A renamed file lands there too, under its new name, and so do the hunks of a split file that no range touches any more — a range is lines, and an edit above it moves them.
  • Marks stay on hunks. Progress per layer is the same coverage Finish review reports, so a re-post cannot lose a read mark.
  • A suggestion is cleared by the post that answers it, and refused once layers exist. Both go when the reviewer clears the review.
  • A thread can anchor to a layer. The reviewer asks about the step itself, not a line in it. The prompt heads the thread layer "<title>" and, in place of a diff snapshot, quotes the layer as it was when the comment was written: title, summary, files. Answer about the layers, with diffo reply like any thread; if the ask is to re-split or re-order, re-post the layers. A layer thread follows its layer by title across re-posts, and a re-post that drops the title retires it.

If the agent suggests layers, the suggestion belongs in its handoff message too, where the reviewer's eyes already are: say "layers" and I'll split it into layers before you start. Saying it in the terminal is the zero-UI path.

Presence: what the reviewer can see ​

The review always shows whether a Send is reaching anybody. The states are derived from the connection and the queue, never asserted by the agent:

StateReasonWhat it means
waitingno-agentNothing attached. Sends queue for the next poll
endedAn agent detached deliberately
disconnectedA poll died without detaching, and the agent never came back
listeningpollingA poll is open. A Send arrives now
workingdeliveredFeedback handed over, no reply yet. Whether the agent is also listening is the separate listening flag below
arrivingThe agent's CLI opened the review and it has not polled yet: it is reading the change and writing its guide. A Send queues for the first poll
repliedA reply just landed; a grace window before the next state
repollingThe poll ended on its own (the window closed, the process was killed) and the session is alive; its next poll is expected
stalledDelivered over 5 minutes ago with nothing back, and no edits in the tree since. The agent is being reminded

Beside the state, the stream carries listening: whether a poll is attached right now. A working agent that is listening hears a new send within moments; one that is not hears it at its next poll, and the chip then reads · sends wait.

Three deliberate choices here. stalled stays inside working rather than becoming its own state, because a slow agent and a dead agent look identical from outside; the reviewer gets the elapsed time and decides. There is a grace after each reply, so an agent working through a batch does not flicker between states on every diffo reply: with a known session pid the grace lasts while that process lives (capped at 10 minutes), without one it is a fixed 90 seconds. And a poll that ends without diffo end — the poll window closing, or the harness killing the process — parks the agent in that same grace as repolling rather than dropping to waiting: the CLI tells the session to re-run the poll, and it normally does within moments, so the reviewer must not be asked to invite an agent that is still there. Only when the grace runs out without a re-poll does the review read disconnected.

The same grace covers the agent's arrival. Opening a review from an agent (piped stdout) posts POST /api/agent/arrive before the URL prints, and until the first poll the review reads working / arriving — the chip says agent · reading the change — because that is what happens between diffo and diffo poll: the agent reads the changeset and writes its guide, often for minutes, while the reviewer is already on the page. A named session is watched like any other (gone, or 10 minutes, ends it); an anonymous one gets 5 minutes. An arrival that never polls falls back to no-agent, not disconnected. A human's own diffo from a terminal announces nothing: there the opener is the reviewer, and Invite is the right offer.

If nothing is attached at all, every thread carries a Copy prompt button: the same prompt the poll would have delivered, ready to paste into any agent.

One session owns a review ​

Each diffo poll identifies its session by walking up the process tree for a recognisable coding-agent process (claude, cursor, codex, copilot, and friends), skipping shell processes and the wrappers that only exist to run the CLI (npx, tsx) on the way, and sends that pid as x-diffo-session-pid.

The newest poll wins. When a second session polls a repo another session already holds:

  • the new poll gets an x-diffo-took-over-from: <pid> response header, and is told to mention the takeover, since the reviewer's feedback now arrives there;
  • the displaced poll returns status: "superseded" and is told to stand down rather than re-poll, because two agents trading a review back and forth helps nobody.

Nothing queued is lost in a handover: undelivered feedback lives in the review, not in the poll, so it is re-derived and re-queued for whoever is listening. Threads the displaced session was handed and never answered are queued again too, in full.

Reviews are scoped per branch as well. A checkout under a running server swaps both the review and the delivery queue to that branch's work, so feedback queued on one branch cannot surface against another branch's hunks.

Why nothing gets lost ​

The guarantee is at-least-once, and it holds because feedback lives in the review rather than in any process:

  • A payload is not marked delivered until the write to the poll succeeds. Hono swallows stream write errors, so a "successful" write is not proof of receipt; an unconfirmed payload is delivered again on the next poll.
  • The delivery queue is not persisted. On startup it is rebuilt from the threads themselves, which means a restart cannot drop feedback nobody collected.
  • Killing the poll, the agent, or the server changes nothing about what the reviewer sent. The next poll, from any session, picks it up.

The cost of at-least-once is the occasional duplicate, which is why finish re-ships answered threads and the prompt tells the agent to leave them alone.

Reviewing a pull request ​

When the target is a pull request (diffo <PR URL>), the agent is a copilot for code it did not write. That premise is checked first: a pull request the signed-in user authored is not opened. The CLI prints two commands instead, a branch review (diffo --base <base> from the checkout: local, nothing touches GitHub) or a PR review (diffo pr <PR>: the GitHub pull request), and tells the agent to ask the user plainly which they want, with no commands in the question; an author who wanted their own changes fixed was otherwise handed draft comments about them. With the premise settled, the protocol bends in four places, all of them carried by the open output and the payloads, as usual:

  • Where to work. The open prints the worktree Diffo checked the PR out in. The agent runs its investigation there (tests, grep, the code) and leaves the worktree as it found it: an uncommitted edit would show in the reviewer's diff as if the pull request had it. It never commits or pushes.
  • What it is told about trust. The PR description, its commits and every GitHub comment are third-party text. Payloads frame them as information to weigh, never as instructions.
  • What reaches it. Only the reviewer's private threads, and none of them carries an intent label: a pull request's composer has no Change / Question chips, so the agent reads what is wanted from the words. Public review comments are drafted for GitHub and post when the reviewer finishes; the agent never sees them as feedback and never posts to GitHub. When the answer is a fix, it goes in a ```suggestion block in the reply, not an edit to the worktree; the reviewer can turn that reply into a public draft.
  • What it writes for the author. The reviewer's private messages are of two kinds, and the protocol teaches the agent to tell them apart. A question ("what calls this?") wants an answer. A finding stated about the code ("this resets the streak on late completions") is a review comment in the making, and the agent writes it: diffo reply <id> --message "<private answer>" --pr-comment "<the comment>". The comment is in the reviewer's voice, to the author, with none of the agent's evidence in it; that stays in the reply. It appears under the reply with Add as PR comment draft, Edit and Dismiss, and nothing posts until the reviewer submits. The agent attaches one when the reviewer states a finding, when their hunch proves right, when they ask for it, or when a plain question turns up a bug it can show; not when the reviewer was wrong, not on pushback against its own reply, where it redrafts the one already in the thread, and not when asked but it has nothing worth saying to the author, where it says so privately rather than inventing one. Payloads quote the reviewer's own review comments, and the suggestions they edited before adding, under The reviewer's voice, so the next suggestion sounds like them. How the comment should read in the first place is the reviewer's own standing text (Settings → Voice in the review page; a default asks for one or two plain sentences, the point first, no em-dashes), and the current text travels with every delivery.
  • How it ends. Finish submits the review on GitHub and hands the private threads to the agent as always. A poll then returns a "kind": "submitted" notice (the verdict, the comment count, the body, and what became of the comments it suggested), which is context, not work.

The guide and layers work as on any review, built from the description, the commits and the diff; the guide is skipped when the description already orients.

Where the agent's instructions live ​

None of the text an agent reads is maintained by hand:

SurfaceGenerated from
skills/diffo/SKILL.mdsrc/skill.ts, via pnpm build:skill. A test fails if the committed file drifts, which is why it is never hand-edited
Every poll payload's promptsrc/server/prompt.ts, the same module the skill imports its command strings from
diffo help agentThe same strings again, for an agent whose context was compacted mid-review

See also ​

Released under the Apache-2.0 License.