Skip to content

feat(chat): show a terminal-started Prime Agent's conversation in Chat - #4946

Merged
devswha merged 3 commits into
mainfrom
feat/prime-agent-chat
Nov 28, 2026
Merged

devswha merged 3 commits into
mainfrom
feat/prime-agent-chat

Conversation

@devswha

@devswha devswha commented Nov 28, 2026

Copy link
Copy Markdown
Owner

Change

Second half of #359 (the first is #4939): a Prime Agent started from a terminal shows its conversation in Chat, on Linux.

Prime Agent 0.10 writes pi's v3 session format (~/.prime/agent/sessions/<id>.jsonl), so its pane is read with the existing pi reader (pi-transcript), as Command Code reuses it. The work is proving which session a pane shows: Prime Agent keeps the conversation in a background daemon, and the pane's own process never opens the session file.

What does not bind. Prime Agent's built-in herdr report names a session per pane, but it follows the pane that created a session, not the one showing it: after ordinary /resume, /new and /fork it named the wrong session for every live pane, and two panes in one folder pointed at each other's chats (measured on 0.10.5 with a stand-in herdr socket). The command line (attach <id>, --resume), --session-dir and the folder are hints too, and the daemon lists no client PIDs anywhere.

What binds (server/prime.ts): the pane's prime-agent window holds a unix stream straight to the worker of the session it shows.

  1. The pane's one Prime Agent TUI (not a daemon or worker process).
  2. The kernel names the other ends of its sockets (ss + /proc/net/unix) and the one daemon socket among them, never a guessed default path.
  3. That daemon is asked read-only (list, its protocol echoed from its hello, under a client id of Ovis's own: a TUI's id would make the daemon count the connection as that TUI's). Its supervisor must own one end of the TUI's streams.
  4. Exactly one listed worker must own one end of them; none (the agents view in front) or several prove nothing.
  5. The session file must be a regular file of this user whose first line names that session's id.
  6. The TUI's descriptors and start time and a second list must be unchanged.

Anything unproven throws no_session_path and the pane stays in Terminal, as for pi and Command Code. macOS (where lsof -U should give the same link, not yet verified) and Windows stay in Terminal for now.

Also:

  • The socket helpers the Codex proof used (descriptorTargets, socketInodes, sameDescriptors, ssInode) move unchanged to server/unix-peer.ts, beside a table of established unix streams.
  • Prime Agent's harness_digest custom message (the model's own notes) is never shown as a chat notice, whatever its display says.
  • prime-agent joins the agents whose panes are read, and the guide lists it.

No wire contract change, no launch flags, nothing written to Prime Agent's settings.

Validation

  • server/prime.test.ts: the proof against stand-in process, kernel and daemon readers (the linked session; a second pane linked to another worker; the agents view; two linked workers; a daemon the TUI is not on; a TUI on two daemons; a header naming another session; a change between reads; macOS; no session file; two TUIs in a pane), the daemon list over a real unix socket (protocol echoed, Ovis's own client id, a non-Prime socket asked nothing), and a recorded 0.10.5 session read through the pi reader with its harness digest hidden. All new; server/prime.ts does not exist on main.
  • Live, in an isolated HOME with the real prime-agent 0.10.5: two TUIs started in the same folder each resolved to their own session file, 21 ms each. The design run (same algorithm) also followed /resume, /new, /fork and attach on four live panes where the herdr report was wrong for three.
  • bun run typecheck passes; server/conversation.test.ts, server/codex.test.ts, server/pane-routes.test.ts, server/transcript-records.test.ts and the convention tests pass.

Second half of #359. Prime Agent writes pi's session format, so its pane
is read with the pi reader; the work is in proving which session a pane
shows.

Prime Agent keeps the conversation in a background daemon, and its own
herdr report follows the pane that created a session, not the one showing
it (measured wrong for every pane after /resume, /new or /fork), so that
report, the command line and the folder never bind. What does, on Linux:
the pane's prime-agent window holds a unix stream straight to the worker
of the session it shows. server/prime.ts reads the kernel's view of that
stream and the daemon it is on, asks that daemon read-only (`list`) which
session the worker runs, checks the file's header carries that id, and
reads everything again to see nothing moved. Anything unproven (macOS,
Windows, the agents view, two links) stays in Terminal.

The socket helpers the Codex proof used move to server/unix-peer.ts with a
table of established unix streams beside them. Prime Agent's harness digest
is never shown as a chat notice.

Refs #359
…start

Review round (omo gate CLEAR, Codex via axwith: no HIGH):
- The daemon and the worker must be Prime Agent processes in that role,
  and their starts, the supervisor and the session id must be the same at
  the second read.
- The daemon's answer is read as bytes with a cap before decoding, the
  deadline covers connecting, and malformed frames or rows are skipped.
- The test of two linked workers links two, and dropping the descriptor
  or start rechecks now fails a test.
- The guide no longer says a pane that only ran `attach` is followed.
@devswha

devswha commented Nov 28, 2026

Copy link
Copy Markdown
Owner Author

Reviews ran on the branch before this PR opened, on its first commit; fixed once in the second commit:

  • omo gate: CLEAR.
  • Codex (gpt-6.2-sol-fast, xhigh, via axwith; the team proxy was at its limit): no HIGH.

Fixed:

  • MEDIUM (gate): the "two linked workers" test linked none, so the several-workers branch had no failing test. It now links two, and dropping the several-workers check, the descriptor recheck or the worker's start recheck each fails a test (checked by mutation).
  • MEDIUM (Codex): supervisor and worker pids had no start check, and the second read did not compare the supervisor or the session id. Both are now checked, and the daemon and the worker must be Prime Agent processes in that role (--mode daemon, worker).
  • MEDIUM (Codex): a null frame or row threw in the socket callback; the deadline did not cover connecting; the byte cap applied after decoding. Frames and rows are validated, the deadline covers the whole exchange, and the answer is buffered as bytes with the cap first (which also fixes a non-ASCII path split across chunks).
  • LOW: the guide no longer says a pane that only ran attach is followed (such a pane gets no herdr label and stays in Terminal).

Left as they are:

  • MEDIUM (Codex), same-user spoofing of the daemon socket or the session file: a process of the same user can already write any file Ovis reads. The proof now also checks process roles and starts.
  • MEDIUM (Codex), the proven file identity (piFile) is not carried into page reads: it is handled exactly as pi's own today, so a change belongs to the pi reader for both, in a follow-up.
  • LOW (gate): codexUnixPeer keeps its own ss parser beside the new table; folding it in would change the Codex proof, which this PR leaves alone.

After the fix: 451 related tests pass, typecheck clean, and the live run (two real TUIs in one folder, each proven to its own session) was repeated with the role checks.

@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Explain Change →

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • New Features
    • On Linux, Prime Agent conversations can appear in Chat when Ovis can reliably match a pane to its session. Sessions that can’t be verified remain in Terminal.
    • Chat follows session switches for supported Prime Agent panes.
  • Documentation
    • Added Prime Agent support details, including when conversations appear in Chat and when they remain in Terminal.
  • Bug Fixes
    • Excluded internal harness digest notices from chat transcripts.

Ovis now resolves a Linux Prime Agent pane to its native session transcript when process, socket, daemon, and session evidence matches. The conversation resolver returns the transcript to Chat. Harness digest messages are excluded from transcript notices.

Changes: Prime Agent chat transcripts

Layer / File(s) Summary
Shared Unix socket inspection
server/unix-peer.ts, server/codex-unix-peer.ts, server/codex.ts
Unix descriptor and socket helpers are centralized in server/unix-peer.ts. Codex now imports the shared helpers.
Prime Agent session discovery
server/prime.ts, server/prime.test.ts, server/conventions.test.ts
Linux discovery checks process descriptors, socket peers, daemon session listings, worker identity, and session headers. Tests cover matching evidence, rejected evidence, and daemon protocol responses.
Chat transcript integration
server/conversation.ts, server/pane-routes.ts, server/transcript-records.ts, server/fixtures/*, docs/guide.md, changelog.d/*
The conversation resolver handles prime-agent panes and returns proven sessions as pi-transcript. harness_digest messages are ignored as notices. The guide and changelog describe Prime Agent chat behavior and fallback cases.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Suggested reviewers: rasperepodvipodvert, jpcarranza94

Merge Risk: Low · previous review 2f6a4

Linux Prime Agent panes can now show their conversation in Chat when the session is proven, and unproven panes stay in Terminal. Two narrow edge cases remain. A suspended Prime Agent TUI might briefly keep showing its old conversation after another job takes the pane. Page reads do not re-check the session file identity found at discovery, which matters only if another process owned by the same user swaps the file. These are low risk and can be handled as follow-ups.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: showing a terminal-started Prime Agent's conversation in Chat. The raw summary and objectives confirm this is the primary feature, with Linux-only scope that the title…
Description check Passed The description follows the template's Change and Validation sections. The Change section explains the problem, the binding approach, the Linux-only scope, and the non-binding fallback to Terminal. Th…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: showing a terminal-started Prime Agent's conversation in Chat. The raw summary and objectives confirm this is the primary feature, with Linux-only scope that the title does not state.

Full details: Description check

Explanation

The description follows the template's Change and Validation sections. The Change section explains the problem, the binding approach, the Linux-only scope, and the non-binding fallback to Terminal. The Validation section lists the tests, the live run, and the typecheck. It does not link a maintainer-agreed issue; it references #359 and #4939 as a series instead, and the template asks for a linked issue for features.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
Fix failing CI checks

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between ddf9a1f and 2f6a443.

Files selected for processing: 12

  • changelog.d/prime-agent-chat.md
  • docs/guide.md
  • server/codex-unix-peer.ts
  • server/codex.ts
  • server/conventions.test.ts
  • server/conversation.ts
  • server/fixtures/prime-agent-0.10.5-session.jsonl
  • server/pane-routes.ts
  • server/prime.test.ts
  • server/prime.ts
  • server/transcript-records.ts
  • server/unix-peer.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.

@devswha
devswha merged commit 0330b9c into main Nov 28, 2026
22 checks passed
@devswha

devswha commented Nov 28, 2026

Copy link
Copy Markdown
Owner Author

Merged through pr-merge at head 3abbafe7f. Seen before the merge was asked for: required checks green, no unresolved thread, no conflict, no hold, main not red, no release in progress. CodeRabbit reviewed this head.

main had moved since the checks of 2f6a4434f: pr-merge --update merged it in (7f4107da5), and every required check was green at this head.

main moved but untouched: merged without update. Its new commits up to 9da0576ab change no file of this pull request, none imported by one, nothing that decides which checks run, and no core path.

omo gate CLEAR and Codex (gpt-6.2-sol-fast xhigh, via axwith as the team proxy is at its limit) no HIGH, both on the branch before the PR opened; one fix round in 2f6a443; Rust PTY host failed once on a pre-existing Kimi contract race and passed on rerun; owner's go for #359 (2026-11-28, via the lead's brief)

@devswha
devswha deleted the feat/prime-agent-chat branch November 28, 2026 06:29
devswha added a commit that referenced this pull request Nov 28, 2026
…was measured on (#4947)

## Change

Last part of #359, after #4939 and #4946. Both depend on Prime Agent
0.10's daemon protocol, measured on 0.10.5:
- the ACP child gets a daemon of its own (`--daemon-socket`) and a
shutdown scoped to it (`PRIME_AGENT_DAEMON_SOCKET`,
`PRIME_AGENT_CODING_AGENT_DIR`);
- the pane's chat proves its session through the daemon's `list`
(protocol 7) and the TUI's direct link to its worker.

`scripts/harness-drift.ts` lists every agent CLI whose latest release is
outside the versions Ovis's link was measured on. Prime Agent publishes
no npm package, so the script now also reads a GitHub repository's
latest release (`github:<owner>/<repo>`), and holds Prime Agent to
`0.10.x`. The table's column is renamed from "npm package" to "Released
as".

## Validation

- `bun test scripts/harness-drift.test.ts`: 3 pass, including 0.10.9
inside and 0.11.0 outside the window.
- `bun scripts/harness-drift.ts` live: Prime Agent's latest release
(v0.10.5) is inside and adds no row; the Codex row it prints (0.172.0)
was there before.
- `bun run typecheck` passes. No UI, no runtime code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant