Session-to-session messaging (RFC draft)
1. Purpose
Status: proposed. This is a recommendation, not a fact. Nothing here is shipped, and every claim about another product is tagged with the page it came from and what was and was not read (section 11). Written to live under docs/design/, next to the trusted-execution design, so the product-doc retrieval corpus cannot present it to a model as a feature.
The question: several Reasonix sessions run at once on one machine, in different projects or in several windows of one project. Today they cannot tell each other anything. Users copy text between windows. This RFC asks whether and how one session may send another a message or a result, and what that must never be able to do.
This is not subagent delegation. A subagent is a child the parent spawns, briefs (TaskSpec), bounds (CapabilityGrant), seeds (ContextRequest) and schedules (SchedulerPolicy). A peer session is a full session owned by the user, with its own transcript, its own permission mode and its own lease. No delegation type is reused (rule M2).
| ID |
Principle |
| P1 |
A peer message is untrusted input. It is data the receiver may act on with the receiver's own authority, never authority itself. |
| P2 |
The sender's approvals, plan tickets and permission mode do not travel with the message. |
| P3 |
Delivery is decided by the receiving controller, on the receiving session's policy. The sender never writes into the receiver's transcript, prefix or inbox manifest. |
| P4 |
The user can always see every message sent and received, and can stop the channel without touching the model. |
| P5 |
One controller implementation serves TUI, serve and Studio. No frontend owns messaging behavior. |
| P6 |
Nothing is decided by reading the message's wording. Structure, identity and counters only. |
Out of scope for this RFC: sessions on another machine (section 9, Q1), agent-to-agent traffic across vendors (A2A adapter, P2), shared task lists and agent-team semantics, and any judgement that a message "looks like" an injection.
2. Findings
2.1 Comparable products (all pages read on 2026-09-29)
| Product |
What exists |
Addressing |
Delivery |
Approval and trust |
Source |
| Claude Code, cross-session |
ListAgents and SendMessage tools between the user's own sessions; on by default from v2.1.224 (macOS/Linux) and v2.1.234 (native Windows) |
Session name set by /rename or --name; short id added when names collide; @name typeahead names a target |
Same machine: per-session Unix socket or named pipe, no server. Receiver reads it between tool calls in a running turn, or a new turn starts when idle. Plain text only, about 1M characters cap |
Receiver inbound setting: deliver, hold for user approval, or refuse. Unset default is per message from the two sessions' permission classes: a receiver that bypasses prompts holds unless the sender also bypasses. Message cannot approve anything, change configuration or run slash commands. Shown to the user as a one-line preview |
cross-session-messaging |
| Claude Code, same page |
Limits |
|
At most 50 accepted messages queued, at most 100 held, per-sender rate limit, identical repeats dropped, sender refused on a rapid burst. Offline peers on other machines: accepted, delivered after reconnect |
Cross-machine goes through the vendor's servers; isolatePeerMachines forces user approval |
same |
| Claude Code, agent teams (experimental) |
Named teammates with per-agent JSON mailboxes and a shared task list |
Teammate name; any teammate can message any other |
Mailbox file ~/.claude/teams/{team}/inboxes/{agent}.json; a send is reported successful only when the file write succeeds |
Teammates start with the lead's permission mode; teammate permission prompts appear in the lead; a relayed approval claim is untrusted; auto-mode classifier reviews each message. One team per session, no session resumption for in-process teammates |
agent-teams |
| Claude Code, field report |
Users report a one-way channel: the receiver had no SendMessage tool and session names changed mid-conversation |
Unstable names |
|
Shows two failure modes to avoid: replying instructions without a reply capability, and an alias standing in for identity. Report only; no maintainer response was visible |
issue 92982, opened 2026-09-09 |
| Codex |
Subagents inside one session: spawn, route follow-up input, wait, close. Children inherit the parent's sandbox and permission mode; approvals from inactive child threads surface in the CLI. No messaging between separate top-level sessions was found in the page read |
Thread switch via /agent |
Results return to the parent |
Inheritance, not delegation of consent |
subagents |
| Codex, request |
Open request for a shared message bus between subagents, opened 2026-05-04, no maintainer response seen |
|
|
Proposal stresses parent-owned decisions and per-agent namespaced notes |
issue 21027 |
| Cursor cloud agents |
Durable agent ids bc-<uuid>; a follow-up is a new run on that agent; one active run per agent |
Agent id; caller may supply an idempotent id |
POST /v1/agents/{id}/runs; a busy agent answers 409 agent_busy; states ACTIVE, IDLE, ARCHIVED |
API key auth. This is user-to-agent, not agent-to-agent; no agent-to-agent messaging in the page read |
cloud agent API |
| opencode |
Parent and child sessions with keyboard navigation. HTTP server: POST /session/:id/message, POST /session/:id/prompt_async, GET /session/:id/children. No session-to-session routing in the pages read |
Session id |
Synchronous or async prompt |
Not stated in the pages read |
agents, server |
| A2A protocol |
Cross-vendor agent protocol: Agent Card discovery, Message and Task objects, states including INPUT_REQUIRED and AUTH_REQUIRED, polling, streaming and push webhooks |
Agent Card and endpoint URL |
Poll, stream, webhook |
Section 13 requires that a server return only tasks visible to the authenticated client and not reveal others; recommends validating content and rate limiting. v1.0.1 released 2026-05-28 per the release page |
specification, releases |
| ACP (editor protocol) |
Coordinates editors and agents, not agents with each other, per a secondary source |
|
|
Not a fit; not read from the primary spec |
unverified: web search summary only, no primary page read |
| MCP sampling |
Server-initiated model requests through the client. Deprecated as of spec 2026-07-28 |
|
|
Spec says a human SHOULD be in the loop, clients SHOULD rate limit and both sides SHOULD limit tool-loop iterations. Not a session channel |
sampling |
What the majority does, on what was read: only one product ships a same-user cross-session channel. Its shape is receiver-side policy plus permission-class default, text only, no history transfer, local transport without a server, user-visible preview, rate limits and dedupe at the receiver. Every other product read keeps messaging inside one parent-child tree. This is a sample of one plus absences, so alignment argument is weak; the design below is justified on our own trust model, not on majority.
2.2 What this repository already has
| Piece |
Where |
Reuse for messaging |
Session write lease: OS lock file plus SessionLeaseInfo{SessionPath, WriterID, PID, Hostname, AcquiredAt} beside the session file |
internal/state/sessionstore/session_lease.go |
Liveness and identity. The OS lock is the arbiter, not the JSON: an unlocked lease is a leftover, not a holder. Discovery must follow that rule (orphan kernels exist, see the 2026-09 lease incident) |
Durable inbox: revisioned manifest, per-item blobs, idempotency keys, capacity 64 items and 64 MiB, states queued, steer_accepted, steer_consumed, running, blocked, uncertain, Origin user or host, Source, Via (paired device) |
internal/state/sessioninbox/types.go |
Receiver-side queue and admission. The manifest is single-writer, owned by the lease holder, so foreign sessions cannot append to it directly (rule M3) |
| Host-authored delivery into a live turn or as the next turn; a burst folds into one continuation |
internal/session/control/jobs_bridge.go, inbox_steer.go, internal/runtime/agent/steer_inbox.go (SteerHostItem) |
Delivery timing and attribution. A host-origin item is never rendered as something the user said |
Content-free change event plus authoritative pull (InboxChanged) |
internal/session/control inbox wiring, internal/contract/event |
Same shape for PeerMailChanged: the event carries no body |
Turn tail projection: Compose, projectTurn, <hook-context> with closing-tag escape and size clips |
internal/session/control/input.go |
Rendering rule. Peer content rides the tail, never the prefix |
Session names itself to a waiting session (Owner.SetHolder) |
internal/state/workspacelease/lease.go |
Precedent for a session-declared display name that is display only |
Read-only cross-session context: list_sessions, read_session |
internal/tools/sessiontool/sessiontool.go |
The pull half already exists. It reads saved transcripts, not live delivery |
| One hub, several runtimes, each with its own controller and lease |
internal/frontend/serve/hub.go |
In-process fast path when both sessions live in one Studio or serve process |
Approval tiers: a plan ticket carries a risk class and high returns to the human even under blanket allow |
internal/safety/permission (see the self-extension approval design) |
Proof that authority stays with the receiver's policy |
| Frontend parity, wire parity, layering, repolint budgets |
tools/repolint/frontendparity.go, wireparity.go, layers.go |
Gates a new port method must satisfy |
Not found in the tree: any registry of live sessions across processes, any tool through which one live session sends to another, and any per-machine directory of running kernels. list_sessions reads a session directory, not running processes. The claim "no such thing exists" rests on a text search for SendMessage, mailbox and cross-session in Go sources on 2026-09-29; it is not a proof.
2.3 Constraints inherited from the repository's own rules
| Constraint |
Consequence here |
| Cache-first: the prefix is byte-stable |
Peer content is a turn-tail block, and the block's bytes depend only on canonical state (determinism rule of context projection) |
| One controller behind every frontend |
Send, list, approve, deny and policy are control.Controller methods on a port. A frontend that drives none of them is counted debt |
| Errors carry identity |
ErrPeerNotFound, ErrPeerRefused, ErrPeerRateLimited, ErrPeerTooLarge sentinels; over HTTP a dotted code through refuse. No message sniffing |
| Judgements read structure, never wording |
No injection-phrase filter on message bodies. Trust is decided by origin identity and counters |
| Layering |
New state package is a utility-layer leaf; only control and frontends import the port. It imports no frontend |
Sandbox: write confinement is macOS and Linux only; unix sockets are not confined on macOS allow default |
A live listening socket is reachable from a sandboxed shell. A spool under the state root is outside the write roots (to be measured, experiment E2) |
3. Goals and non-goals
| ID |
Goal |
| G1 |
A session can address another live session of the same OS user on the same machine and send it text |
| G2 |
The receiver decides whether, when and how the text reaches its model; the default is safe for a receiver in a permissive mode |
| G3 |
No message can approve, elevate, or relax anything in the receiver |
| G4 |
Bounded rates, depth and queue so a loop terminates without human action |
| G5 |
Survives receiver restart and crash without loss and without duplication of an accepted message |
| G6 |
Every frontend gets it from the controller; the user sees every message in a durable audit view |
| ID |
Non-goal |
| N1 |
Sending files, images, attachments, @ references, slash commands or history. Plain text plus optional typed fields (section 5.2) |
| N2 |
Cross-machine delivery and any relay service (Q1) |
| N3 |
Shared task list, teams, leader election |
| N4 |
Making messaging default-on for unattended headless runs in P0 |
| N5 |
Detecting whether message text is malicious |
| N6 |
Replacing read_session |
4. Options
| Option |
Sketch |
For |
Against |
Verdict |
| A. Pull only (status quo) |
list_sessions, read_session |
Already shipped, no new trust surface |
No push, exposes whole transcripts, no liveness |
Keep, complement |
| B. Shared notes file in the workspace |
Sessions append to a file both read |
Trivial |
Workspace is execution-mutable and untrusted; no sender identity; no delivery timing; races |
Reject |
| C. Live socket per session, memory only |
Each runtime listens; sender connects |
Immediate; the one shipped precedent |
Lost if receiver is down; a listener is reachable from sandboxed shells on macOS; needs path-safety checks; identity is whatever the peer claims |
Reject as the primary channel |
| D. Route through serve or Hub HTTP |
Sessions post to the gateway |
Reuses auth and SSE |
Only reaches sessions inside one hub; a terminal session in another window is not there; adds an authorization model |
Use only as an in-process fast path |
| E. Receiver-owned durable spool plus content-free wake-up |
Sender host writes an immutable file under the state root into the receiver's spool; receiving controller ingests |
Survives crash; sender cannot touch the receiver's manifest; state root is outside sandbox write roots; needs no listener; audit is the files |
Latency bounded by wake-up interval; needs a live-session directory; Windows has no write confinement |
Recommended |
| F. A2A endpoint per session |
Agent Card, HTTP, tasks |
Vendor-neutral |
Ports, auth, discovery, task model all for a same-user local problem |
Defer to P2 as an adapter over E |
| G. Extend subagent delegation to peers |
Treat a peer as a worker |
Reuses code |
Wrong ownership: a peer is not spawned, briefed or bounded by the sender; blurs the five concepts |
Reject |
5. Recommendation (option E)
5.1 Addressing and discovery
| ID |
Rule |
| A1 |
Identity is the session id plus the writer id of the current lease holder. It is stable for the session file, not for the process |
| A2 |
A display alias is the session title or a user-set name. It is display and typeahead only. A send resolves alias to id at the sending host and records the id; an alias that matches more than one live session is refused with peer.ambiguous, never guessed |
| A3 |
Discovery reads a per-machine live-session directory under the state root, one small file per running runtime: session path, writer id, pid, surface, alias, project label, spool path. A runtime writes it after acquiring its lease and removes it on release |
| A4 |
An entry is live only if the session's OS lease lock is held. The directory file is a hint; a stale file is ignored and garbage-collected. This is the lease rule already used for orphan detection |
| A5 |
Project label in listings shows the workspace base name, not the absolute path, unless the user asks; a paired device or remote view never receives another local session's absolute path |
| A6 |
A session can send only to sessions of the same OS user and same state root. Different state roots are different worlds |
5.2 Message shape
| Field |
Type |
Set by |
Notes |
id |
ULID |
sending host |
Idempotency key at ingest |
from |
{session, writer, alias} |
sending host, never the model |
The model supplies only to and body |
to |
session id |
sending host after resolution |
|
sentAt |
time |
sending host |
|
chainDepth |
int |
sending host |
0 if sent from a user-started or model-original turn; incoming depth plus 1 if sent during a turn a peer message started or steered (M6) |
replyTo |
message id, optional |
sending host |
Lets the receiver correlate; carries no authority |
subject |
string, at most 120 runes |
model |
Shown in previews |
body |
text, at most 32 KiB |
model |
Plain text |
refs |
list of {kind: "session_turn", session, turn} optional |
model |
A pointer the receiver may open with read_session, subject to its own permissions; nothing is frozen or attached |
N1 stands: no attachments, no @ expansion, no slash commands in body; the receiving controller treats body as literal text and does not run invocation parsing on it. A pointer is not content; reading it is a separate tool call under the receiver's permission.
5.3 Send path
- The model calls a
send_session_message tool (P1 phase) or the user runs a send command (P0 phase, both). The tool is not read-only.
- Permission subject is the target session id. Default decision is Ask. A user rule such as
allow = ["send_session_message(<id>)"] moves it. bash and friends cannot reach the spool because it is outside every write root (E2 measures this).
- The sending host assigns
id, from, chainDepth, checks the size cap and the per-sender rate, then writes <spool>/<sender-writer>-<seq>.json by create-exclusive plus atomic rename. Success is reported only after the rename succeeds.
- The host records a durable outbox entry in the sender's own session (audit) and shows a transcript line
sent to <alias>.
5.4 Receive path
- The receiving controller polls its spool at safe points (turn boundary, steer point, and a slow ticker while the runtime is live) and receives a content-free wake-up when the hub hosts both sessions in one process. No listener socket exists.
- Ingest is idempotent by
id. A file that fails validation is moved to a quarantine directory and counted; valid neighbours still deliver (the failure of one entry does not block the mailbox).
- The inbound policy decides one of three outcomes: delivered, held, refused. Held items appear in the inbox panel as blocked with a typed reason
peer.awaiting_approval; approve delivers that one message, deny drops it.
- Default policy when the user has set nothing: deliver if the receiver is in a prompting mode (Ask, and Auto where the receiver still asks for high risk); hold if the receiver is in YOLO or another blanket-allow mode; refuse if the sender's alias is on a deny list; hold always when sender identity is
unauthenticated (Windows, section 6.3). This mirrors the shipped precedent but is stated here on our own grounds: a permissive receiver is the only place where a message can turn into unreviewed action.
- A delivered message enters as a host-origin item with
Source: "peer:<sender id>", either steered into a running turn between tool calls or queued as the next turn. A burst from one sender folds into one continuation, using the same folding rule as background-job completions.
- Delivery starts no plan, no goal and no checkpoint of its own. A turn the message opens is a synthetic host turn, as jobs are.
5.5 Projection into the model context
| ID |
Rule |
| R1 |
The block is rendered at the turn tail only. The system prompt, tool list and prefix configuration never change because messaging exists or a peer is present. The tool |