Repository navigation
feat(session-collaboration): immediate delivery for reports and follow-ups - #2355
Conversation
…oundary A completion receipt is invisible until the target session gets to it. With `admission: queue` and no promotion, a busy parent ran the report after everything the user had already queued, so a fan-out of eight workers looked like it stalled even though every report had arrived. Completion receipts are now promoted in the target's turn queue (ADR 0265): the same move the queue row action performs, so a busy session delivers the report as its next turn instead of behind the plain queue. Ordering between competing reports stays arrival order, because promotion appends to the priority block. The promotion keeps the existing steering rules. A Desktop-owned turn never has another session's text injected into it, so "immediate" means the next turn boundary, not preemption. A turn that already started, or a queue move that lost a race, is logged only when the error is not CONFLICT. Verified: `tsc -p apps/desktop/tsconfig.json --noEmit` with this change clean. No schema change, and task/message deliveries keep today's ordering.
…livery `send` always appended behind whatever the target had already queued, so a caller that needed to correct a busy worker had no way to say "this matters now". `session/collaboration/send` accepts `delivery: "queue" | "immediate"` (default `queue`, which is today's order). `immediate` uses the same promotion block as a completion receipt (ADR 0265): a busy target runs the follow-up at its next turn boundary instead of behind already-queued input. It never preempts a running turn — steering stays restricted to a paired caller — and an unknown value is rejected before anything is created. `spawn` rejects the field, because a worker's first task has nothing to jump. Verified: `tsc -p apps/desktop/tsconfig.json --noEmit` with this change clean.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
The completion receipt carried a serialized envelope
(`{"sessionId":…,"status":…,"result":…}`), so the receiving Agent had to parse a
JSON string out of its own inbox before it could use the report, and a human
reading the transcript saw the same blob.
The receipt is now a structured report a model can act on directly:
Sub-session report
Session: <worker title> (<session id>)
Status: completed | failed | cancelled | interrupted
Delivery: <message id> (turn <turn id>)
Report:
<the worker's final text, or why there is none>
Error: <the fence or turn error, when it failed>
The machine-readable fields stay available where they belong: the
`session.collaboration.result` projection is unchanged, so nothing parses the
message body for state. Tests now lock the format and assert the envelope is
gone.
There was a problem hiding this comment.
AIUO CodePilot · Preliminary review
Diff-only preliminary review of session-collaboration delivery promotion, receipt text format, and docs. The change promotes queued completion/immediate deliveries via queue.prioritize and replaces the JSON receipt envelope with readable text. One concrete issue: the shared dispatch logging message says "Session completion delivery" for any promote, including a caller-requested immediate follow-up. Other limits: no execution or full-repo context available (added-line evidence only), so race behavior, queue semantics, and Rust message fields were not verified at runtime.
- low
apps/desktop/electron/main/services/session\-collaboration\.ts:170: The error log message is hardcoded as a completion-delivery failure even when the promoted turn came from `delivery: "immediate"` on a non-completion send. Operators will misattribute an immediate follow-up prioritization failure as a completion receipt problem. Use a message that reflects the actual promotion source.
Evidence:deps\.log\("Session completion delivery could not be prioritized", \{
Head: 77d5b7a
Base: f3cb2a3
CI: success; mergeable: true.
Validation: code/tests NOT EXECUTED. Diff-only preliminary analysis; not approval. Human review and repository gates remain required.
Why
A worker's report is invisible until the receiving session gets to it. The
dispatch started it with
admission: "queue"and never promoted it, so a busyparent ran the receipt after everything the user had already queued. With
maxConcurrentSessionsnow defaulting to 8, a fan-out of eight review sessionslooks stalled even though every report has already arrived — which is what
prompted the plugin-side request "reports should be sent immediately, not
queued".
What changed
apps/desktop/electron/main/services/session-collaboration.tspromotes a queuedcompletion receipt:
This is the same queue move the row action performs (ADR 0265), so a busy target
delivers the report as its next turn instead of behind the plain queue. Ordering
between competing reports stays arrival order, because promotion appends to the
priority block.
The steering rules are unchanged.
deliverPromotedBlockstill accepts immediateinjection only from a paired caller's own input, so a Desktop-owned turn is never
injected with another session's text: here "immediate" means the next turn
boundary, not preemption. A turn that already started, or a queue move that lost
a race, is not an error — only a non-
CONFLICTfailure is logged.Scope:
kind === "completion"only.taskandmessagedeliveries keep today'sordering, so plugin-sent work is still a normal queue entry.
Docs
docs/adr/0265-...: records automatic promotion of completion receipts and theboundary it inherits.
docs/spec/07-plugins/03-plugin-api.md+ zh-CN: the gateway contract now says areceipt is promoted in the target's queue and never injected into a running
turn.
Verification
tsc -p apps/desktop/tsconfig.json --noEmitwith this change: clean.covered by typecheck and by the queue rules it reuses; a harness for
createSessionCollaborationServicewould be the natural follow-up.Follow-up not in this PR
RacpTurnAdmissionhas no interrupt value, so a report cannot preempt a runningturn. If "immediate" should mean injection mid-turn for Desktop-owned turns, that
is a security-relevant change to the paired-caller steering guard and needs its
own decision record. A per-delivery choice exposed to the plugin as a setting also
needs a durable hint on the message row (schema v30), which is why it is not part
of this fix.
Also in this PR: a send can ask for the same treatment
sendalways appended behind whatever the target had already queued. It nowaccepts
delivery: "queue" | "immediate"(defaultqueue= today):immediatepromotes the follow-up in the same block a completion receiptuses, so a busy target runs it at its next turn boundary instead of behind
already-queued input.
unchanged.
INVALID_ARGUMENTbefore anything is created;spawnrejects the field because a worker's first task has nothing to jump.The operation catalog's
argumentShapeforsendadvertises the field, andthe plugin-side counterpart (
SessionTaskdelivery) ships invastsa/pi-plugin-session-orchestrator#3.
The report is text a model can read, not JSON
The receipt used to carry
{"sessionId":…,"status":…,"result":…}. The receivingAgent had to parse its own inbox, and a human reading the transcript saw the same
blob. It is now a structured block:
Nothing parses the body for state —
session.collaboration.resultstill returnsthe machine-readable projection — and two tests now lock the format: the completed
receipt must contain
Status: completedandReport:\nAuthoritative final resultwhile containing no"result"key, and the interrupted receipt mustcarry
Status: interruptedplus the fence error.