Show a message another agent sent, on a session this server is running

Peer messages were only ever produced by the *import* path, reading them out
of the CLI's own session file. A message another agent sent to a session
this server was driving appeared nowhere, so the session started working on
something nobody on the phone had asked for and there was nothing on screen
to explain it.

Measured rather than guessed, because the obvious place to look for it is
empty: a real cross-session message sent to a real `--input-format
stream-json` session on CLI 2.1.237 produces **no `user` record**, and
nothing in the partial-message stream mentions it either. The whole of it
arrives as an `origin` object on the turn's `result`, in exactly the shape
the session file records -- so `import::peer_message` now reads both, one
function for one wire format. Two copies would drift the first time a field
is renamed, and the half that drifted would go on producing nothing, which
is indistinguishable from nobody having sent anything.

The cost is the position: the note lands after the reply it caused rather
than above it, because at no earlier point in the turn does the CLI say why
the turn started. Taken deliberately over the alternative -- a second reader
tailing the CLI's own session file for the one record stdout does not carry,
which is two sources of truth for one conversation and a poll per live
session. Recorded in PLAN.md so that if the CLI ever announces the injection
where it happens, the next reader knows to move it there.

Both halves tested: the real record shape, and an ordinary result carrying
no `origin` -- which is the half that decides whether the check is a check.
Four ordinary results on a real session's stdout had none between them.
This commit is contained in:
iris committed 2026-08-31 23:02:49 -04:00
1 parent fe6a36bde4
commit 6236f0d5bd
4 files changed
+132 -2

No files matched your search

+25
View File
@@ -247,6 +247,31 @@ turn. Claude's dialect: a `user` message on stdin mid-stream; pi's: `steer`.
- Images in: base64 image content blocks in the stream-json user message.
- Working directory, host, and model are spawn-screen fields.
### A message from another agent, on a live session (measured 2026-08-31)
Peer messages were only ever produced by the *import* path, reading them out
of the CLI's own session file — so a message another agent sent a session
this server was running never appeared at all, and the session simply
started working on something nobody on the phone had asked for.
Measured rather than guessed, by sending a real cross-session message to a
real `--input-format stream-json` session on CLI 2.1.237: the CLI emits **no
`user` record** for it, and nothing in the partial-message stream mentions
it. The whole of it arrives as an `origin` object on the turn's `result`, in
the same shape the session file records — `kind: "peer"`, the sending
session's `name`, and the message as `body` — so `import::peer_message` reads
both, and there is one function for one wire format. Only peer-caused turns
carry it: four ordinary results on a real session's stdout had no `origin`
between them.
**The cost is the position.** The note lands after the reply it caused rather
than above it, because at no earlier point in the turn does the CLI say why
the turn started. The alternative is a second reader tailing the CLI's own
session file for the one record stdout does not carry — two sources of truth
for one conversation and a poll per live session — and it was rejected on
that. If the CLI ever announces the injection at the point it happens, this
moves to that record and the ordering comes right with it.
### Taking a queued message back (decided 2026-08-31)
A message sent into a running turn is drawn as a bubble waiting below the