You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(native-chat): deliver other agents' messages to chat agents directly again - #43380
When one agent sends a message to another agent's chat, Orca had stopped giving the agent the message. Since #43093 the agent got only "you have a message, run check to read it", while the chat showed the full message. So what you saw in the chat was not what the agent got, and every message cost the agent an extra step. Now the agent gets the full message again, exactly as the chat shows it.
Files
Added
Deleted
Net
Test
6
$\color{#1a7f37}{\Huge{\mathbf{+}}}$45
$\color{#cf222e}{\Huge{\mathbf{−}}}$58
$\color{#cf222e}{\Huge{\mathbf{−}}}$13
Prod
11
$\color{#1a7f37}{\Huge{\mathbf{+}}}$130
$\color{#cf222e}{\Huge{\mathbf{−}}}$77
$\color{#1a7f37}{\Huge{\mathbf{+}}}$53
What Changed
Before: a message from another agent (a coordinator's instructions, a worker's report) showed in full in the chat, but the agent itself was sent only a pointer at orca orchestration check and had to run it to see the message.
A chat must show exactly what its agent received. #43093 broke that, and made every chat agent spend a tool call per message, to fix a problem that exists only in Codex with automatic review. Agent-to-agent messages belong in the receiving agent's conversation as text, labeled with their sender. A pointer plus a tool read suits only some automatic task-finished notices and oversized results.
Not in this PR: Codex's automatic reviewer can still read another agent's message as the user's approval, as it could before #43093. The follow-up delivers agent mail to Codex as its own inter-agent message type, which its reviewer labels as coming from another agent. That needs its own real-Codex verification.
QA results and screenshots will be in the status comment.
Testing
Automated tests added/updated: a structured-chat integration test now checks that another agent's message reaches the agent exactly as the chat shows it, and that it is marked read without check. It fails on main, where the agent gets the pointer. The tests that encoded pointer delivery are back to whole delivery.
Every added test fails without this change and avoids the test anti-patterns
pnpm check:changed passes. The 7 affected test files pass (26 tests), and tc:node passes.
Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.
Notes
SSH/remote and mobile: the handover runs on the host that runs the agent, so remote chats get the same whole delivery. The chat card is unchanged.
Cross-platform: no platform-specific code.
Checklist
This PR is small and focused
I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
I stated the risk: what could break, for whom, and how to back it out
Before/after screenshots or videos attached for UI changes, or N/A with reason
Self-reviewed for correctness, security, and performance
Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)
…tly again
#43093 sent chat agents only a pointer at `orca orchestration check` for
mail from other agents, while the chat showed the full message, so the
agent never received what the chat displayed and every message cost an
extra tool call. Chat agents again receive each orchestration message
whole, with its sender header, exactly as the chat card shows it; a
message too large for one chat message still falls back to the pointer.
The Approve once control from #43093 is unchanged.
Tracked in STA-15406.
Review was skipped as selected files did not have any reviewable changes.
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: fd93ab9b-7050-4670-9f7e-66989a7a1744
Commits
Reviewing files that changed from the base of the PR and between 1d4e1a8 and 9693c54.
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.
Walkthrough
Structured mail is handed to chat workers as the original journal message instead of an orchestration.check pointer. Accepted sends are consumed only when the journal observation verifies whole-message delivery. Follow-up instructions distinguish chat workers, which receive messages one at a time, from terminal workers, which are told to check for waiting messages. Tests verify whole mail in chat turns and cleared unread mail.
Merge Risk: Low · previous review 1d4e1
Chat workers that dispatch helpers are still told that helper reports will appear in check. Short reports now arrive directly in the chat, so a later check may return nothing, which can confuse the worker. The core whole-message delivery and custody settlement behave as intended, so this is a small instruction-text fix rather than a merge blocker.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: restoring whole-message delivery of other agents' messages to chat agents, which the description and raw summary both confirm. It uses the conventional fix(scope) pref…
Description check
The description follows the template closely. It has the ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, Risk, AI Disclosure (left blank, which is allowed for team members), Review, Note…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the main change: restoring whole-message delivery of other agents' messages to chat agents, which the description and raw summary both confirm. It uses the conventional fix(scope) prefix and is one sentence of 10 words, so it is concise and specific.
Full details: Description check
Explanation
The description follows the template closely. It has the ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, Risk, AI Disclosure (left blank, which is allowed for team members), Review, Notes, and Checklist sections. The before/after behavior, mechanism, risk level, and rollback are stated clearly. The Linked Issue section cites STA-15406 and #42608 but uses 'Tracked in' rather than the 'Fixes #' form, and the Visual Proof section defers screenshots to a status comment instead of attaching them. Those are minor gaps against the template's requirements.
Resolution
Optional: rewrite the Linked Issue line as a closing reference (for example 'Fixes #...') if one of the tracked items is a GitHub issue, and attach before/after visuals or state why they are not needed, since the template requires them for UI and behavior changes.
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.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
⚠️ Outside diff range comments (1)
Minor · Pass the chat classification into the helper-mail… · worker-dispatch-preamble.ts:185-187
src/main/runtime/orchestration/workers/launch/worker-dispatch-preamble.ts:185-187 Minor · Functional Correctness · Quick win
Pass the chat classification into the helper-mail instructions.
The sub-dispatch section is shown to chat workers when they can dispatch helpers. Its text still says helper reports arrive in check. For chat workers, a short report is delivered as a whole chat message and is not left unread for check. A later check may then return nothing for that report. Reports that exceed the size limit still point to check.
Pass chat into buildSubDispatchSection. Use the direct-delivery wording for chat workers, and keep the current wording for terminal workers.
Suggested fix
-function buildSubDispatchSection(cli: string, workerHandle: string): string {+function buildSubDispatchSection(cli: string, workerHandle: string, chat: boolean): string {
return `
=== SUB-DISPATCH ===
-If the task asks for helper workers, start them here. They report to you: their-questions, escalations, and worker_done arrive in your own \`check\`, next to-your coordinator's mail.+${chat+ ? `If the task asks for helper workers, start them here. They report to you: their+questions, escalations, and worker_done arrive directly in this chat. A report too+long for one message points you at \`check\`.`+ : `If the task asks for helper workers, start them here. They report to you: their+questions, escalations, and worker_done arrive in your own \`check\`, next to+your coordinator's mail.`}
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.
…ivered whole
Whole-delivered mail is read on settle. A pointer or in-doubt send still
holds while custody is unreadable, is handed to the mailbox's new owner
when the chat lost it, and a send made obsolete by a handoff wakes that
owner.
Performance review: PASS — no confirmed P0/P1 performance regression in this span.
Reviewed head 1d4e1a848c66288c99c5f98834ded2a3ff886a05, against merge base 4b8a9b10c09504ebf00eb54bdf2fc568f61428f7 (local origin/main pinned at 956ba85de3b06ac1fb270fa72005c79535aa20a7). This is a performance review, not a merge approval.
All runtime work below runs on the agent's owning runtime: Electron main locally, or the server process on the remote host. Journal reads use the existing reader-worker path; orchestration SQL and the new equality check run synchronously on the runtime thread.
Each admitted chat submission; one receiving agent, including an existing retry after non-admission.
Sends the existing body instead of constructing a pointer. Removes one provenance parse/pointer construction on handover. Provider encoding/transport now includes the required mail text, bounded by 256 KiB of serialized blocks per whole-mail message. Stopped-history carry is additional and unchanged. The journal and chat card already contained the full body before this PR; this does not add another persisted full-mail copy or replay history per token.
Immediate accepted-send observation, an invalidated mailbox settlement pass, or consuming check reconciliation; one current reservation per message/mailbox.
Adds one selected-message lookup after lifecycle reconciliation. This is a parameterized messages.id unique-index lookup using the existing statement cache, not a mailbox/history scan. For whole accepted mail, retiring the exact attempt changes the existing one-row stamp to read-and-delivered, and deletes that reservation. The reused batch-mutation helper also adds two nested savepoint-control statements (SAVEPOINT/RELEASE), not an extra transaction commit. Subsequent callbacks fail the current-attempt gate before rereading/comparing it. The post-reconciliation read observes corrections that may have replaced the subject/body/payload.
Only a current accepted attempt whose corrected message still exists and is unread.
Parses source metadata, examines the notice members, then compares up to three ordered, nonoverlapping field ranges against the admitted text. Production construction supplies one member and one text block. Work is O(metadata + compared message characters), at most the admitted block's text; temporary filter/slices are not retained. Missing provenance, pointer-only content, invalid ranges, changed fields and already-read mail cannot be consumed as whole mail.
Accepted pointer/mismatched evidence or unknown handoff; one reservation.
Extracted the existing unavailable/stale handling into a local closure. Unavailable custody retains the obligation; stale custody retires/releases it and wakes its current owner through the existing path. No timer, retry owner, collection scan or new publication was added. An accepted oversized pointer also pays the extra selected-row read above: its cost is O(stored row bytes M), not capped at 256 KiB. No hard cap on the underlying orchestration message is assumed.
Claiming a follow-up; one source/target dispatch and its unread messages.
Predicate rename only. Same address/worker-handle classification, same bulk mailbox UPDATE, same unread-marker UPDATE. The existing work scales with mail actually moved, not all agents or worktrees.
Comment-only change. Still formats one message, preserves provenance/ranges, and falls back to a pointer when serialized blocks exceed 256 KiB. Source construction and the size check were already paid before this PR.
Arrival, relevant journal/status/owner edge, or scoped stale-mail cleanup; affected mailbox.
Comment-only change. Existing admission is serial per mailbox with one coalesced rerun; selection pages contain at most 50 messages, then advance by reservation/delivery stamps. Existing queue refusal parks instead of continuing to admit. One message is handed over per agent turn.
Building a dispatch brief / starting a follow-up; one dispatch.
A constant string choice plus one handle classification for follow-ups. No additional process, task, scan or model turn is created. The surrounding lineage traversal/startup recovery is unchanged. Chat instructions no longer request the extra check tool call.
Changed tests and fixture
Test execution only.
Expected provider text/read state changed; no production timer/import or CI workflow change.
Fleet price (source-derived operation counts, not timing): use 100 active agents at one accepted mail per 5 seconds, and independently scale to 1,000 agents at the same cadence. This produces 20 / 200 accepted messages per second: 20 / 200 additional indexed row reads, 40 / 400 nested savepoint-control statements if all are consumed whole, at most 60 / 600 field comparisons, and at most 5 / 50 MiB/s of required whole-message block bytes sent to providers (before transport escaping and unchanged history carry). A simultaneous one-message-per-agent burst gives 100 / 1,000 additional reads, 200 / 2,000 savepoint-control statements and at most 300 / 3,000 range comparisons, not N². The ordinary successful attempt is retired once; pending/unknown attempts do not run the new range comparison. Accepted-but-held fallback attempts can be inspected again on relevant edges; price that case as edge rate × held attempts × stored row bytes, rather than pretending the 256 KiB provider cap bounds the database row.
Scaling 750 → 7,500 worktrees, a dozen → 120 repos, hundreds → thousands of terminals, remote refs/remotes, or unrelated transcript/history bytes does not multiply the new work for one mail delivery. These dimensions are not traversed by the added code. Necessary N distinct deliveries do cost N message sends.
No subscription or publication was added by this diff. The full body was already persisted and published to the chat. Marking mail read updates orchestration SQL; it does not publish a new chat snapshot.
I traced the existing publication routes at this head, including unchanged consumers:
StructuredAgentSessionConversations owns one commit/epoch-replacement/stop-settle attachment per adopted session, with replacement/delete cleanup. Its keyed observeConversationPublications consumers are: one mailbox watch per session with parked mail; one approval watch per session with tracked approvals; one observer per active automation-run observation; and PR-watch's synchronous seed lookup, which immediately unsubscribes (zero retained PR-watch listeners on this feed). No cross-session broadcast occurs on this feed.
Mail watches are shared by all parked mailboxes of the session. Relevant changes are admission/queue edits, turn/context-clear/new-item/deletion/source edges; token-only updates fail the relevance predicate. The initial seed does not redrive. Unparking the last mailbox or forgetting the session unsubscribes and cancels pending coalescer timers.
The existing client-delivery branch updates status/turn-completion projections, send-settlement waiters, queue activity, journal observers and transcript subscribers. observeJournalPublications has no production call sites outside its definition/export at this head. Desktop transcript readers use structured-agent-session-read-transport.ts → agentSession.subscribe; mobile uses mobile-structured-transcript-subscription.ts → the same RPC. The server maintains one subscriber per active stream ID/session and removes it on close. Status and turn-completion feeds remain separate runtime streams. Listener multiplicity is active clients/streams, not every worktree or saved chat.
Rates: quiet sessions generate 0 mail redrives/s. With C journal commits/s, each registered publication observer receives C commit hints/s, plus actual lifecycle edges; token-only hints may carry no mail-relevant change, but generate 0 mail settlement passes. Relevant bursts use the unchanged 300 ms trailing coalescer with a 2 s maximum wait: continuously arriving relevant events produce roughly 0.5 redrives/s; separated events can approach 3.33/s. Each pass visits only that session's parked mailboxes and their outstanding sends. Fresh arrivals still drive immediate admission. The PR's incremental UI/subscription rate is 0 frames/s at idle and under the same event workload, including 0 newly introduced unchanged frames/s. Absolute provider-response/transcript frame rates depend on the provider's output and active readers and were not measured.
All six scan questions were assessed:
Work before skip gates — reviewed. Current-attempt/accepted/unread gates precede the new proof. Provider delivery uses the existing body. Existing oversized formatting still constructs/serializes O(M) bytes before falling back; that cost predates this span.
Multiplied ownership — reviewed. No added owner/listener/client. One parked-mail watch per affected session, one serial admission pass per mailbox; no row/pane/worktree fanout.
Thread/storage cost — reviewed. One additional synchronous indexed selected-row read per accepted settlement, two nested savepoint statements on whole consumption, ephemeral range checks, required provider payload encoding. Journal observation already returned the admitted body from a reader worker before this PR. No new sync filesystem operation, subprocess, table scan, whole-state flush, or worker startup.
Growth/progress — reviewed. Exact-attempt retirement removes successful work; fallback remains available to check; queue bytes, selection pages, reservation stamps and unchanged edge invalidation provide the existing admission/progress mechanism. The agent queue reserves personal-message room: 1 MiB published queue budget minus 257 KiB leaves 767 KiB for agent-origin admission. Durable pending mail is intentionally not truncated.
Execution host — source reviewed. Work stays on the owning runtime, including remote sessions; no new per-message SSH command/process or platform probe. Windows/WSL/Linux/SSH runtime timing was not exercised.
Obsolete work/budget release — reviewed. No new retained registry, watcher or retry timer. Current-attempt fencing prevents stale completion from retiring a successor. Whole acceptance deletes its reservation; refusal/unknown/unavailable/stale paths retain their existing distinct recovery rules. Existing handover abort/close ownership is unchanged.
Touched recurring classes: sync SQL / rereads — one exact-row post-reconciliation read, no fleet/history scan; streaming full-message reprocessing — changed work is handover/settlement, not token append; polling/hidden owners and listener retention — no added polling, existing scoped edge watches and teardown; whole snapshots/no-change publication — no added publication or full-body UI payload; queues/fanout — existing per-mailbox serialization, paging and byte admission unchanged; startup imports — new helper adds only an already-used source-schema runtime dependency, no new SDK/provider startup.
Pre-existing work/amplification retained in coverage: formatting and size-checking oversized mail are O(M); each relevant settlement pass visits that mailbox's outstanding Q sends. Also, journal-sql-send-admission.ts:150 calculates queued bytes with SUM(length(CAST(json_extract(payload_json,'$.body') AS BLOB))) over all waiting/returned cards of that session on each queued admission: Q=100 / 1,000 resident cards means 100 / 1,000 existing body extractions for one new card; successive enqueues revisit that prefix. This is unchanged, with the existing 1 MiB published-body budget bounding resident body bytes (767 KiB for agent-origin admission); it is not an added all-history/all-fleet scan. The new accepted-attempt reread is priced separately above.
Executed:ORCA_BACKGROUND_LAUNCH=1 TC_GATE_POOL=test tc-gate node node_modules/vitest/vitest.mjs run --config config/vitest.config.ts <three named files> --maxWorkers=2 — 3 files, 12 tests passed: structured-mailbox-pointer-delivery.test.ts, structured-chat-coordinator-mail.test.ts, and structured-chat-mail-reconciliation.test.ts. These exercise whole-body/card equality, read consumption, withdrawal/ownership races, lifecycle corrections, uncertain sends, and check reconciliation. The fleet N/10N counts above are derived from the production call graph and bounds, not an executed load benchmark.
Inspected all 17 changed files, the production callers, indexed SQL/statement caching, queue admission/retirement, worker-journal observation, publication/redrive ownership, desktop/mobile transcript routes, and provider handover/retry/abort paths. Local source review on macOS; no dependency install, build, GUI launch, code edit, commit or push. No CPU, event-loop, heap, transport-throughput or real-provider latency measurements are claimed. This PASS means no confirmed performance regression in the reviewed span; it is not a fleet-scale latency benchmark.
Problem: since #43093, a chat agent got only a pointer at orca orchestration check for another agent's message, while the chat showed the full message. So the agent never received what the chat displayed, and every message cost an extra tool call.
What changes for users: chat agents (Codex, Claude and the rest) again receive each orchestration message whole, with its sender header, exactly as the chat card shows it. They don't need check. A message too large for one chat message still falls back to the pointer. Terminal agents are unchanged. #43093's Approve once control stays.
Review: two passes, each with fresh Claude and Codex reviewers.
Pass 1 (74a53e6): both found that the revert also dropped fix(native-chat): send other agents' mail as a pointer and let the person approve a denied action #43093's custody fixes, which apply to all mail. The new owner wasn't woken after a send-time handoff, and a pointer or in-doubt message wasn't held or handed off. Fixed in 1d4e1a8: mail delivered whole is still marked read, and everything else keeps the hold and handoff. The test also gained fixed expected values.
Pass 2 (1d4e1a8): Claude and Codex both READY TO MERGE.
Perf: the full perf-scan on 1d4e1a8 passed (comment above).
QA: real Orca dev copy on M4Air, real Codex (gpt-6.1-sol, high) and Claude (claude-opus-5-5, medium; the picker has no 1M entry), on 74a53e6. The repair only changes the not-whole handoff path, which these flows don't exercise.
A, Codex coordinator gets a worker report: pass. Its rollout input is the full message (sender, Subject:, body, payload) with no pointer. Over 13 turns, 7 messages arrived whole and check was run 0 times.
B, Claude coordinator: pass. The session's user turn is the full message, and Claude answered without check.
C, follow-up to a running Codex chat worker: pass. The worker got the full text and did the follow-up without check.
D, new chat worker brief: pass. The brief doesn't tell the worker to run check for chat mail. The "arrive next" line appears only when mail is already waiting, which wasn't the case in this run.
E, Approve once: pass. The denial row shows; pressing the button records the approval, and the retry is reviewed again.
F, terminal worker: pass. It still gets You have 1 orchestration message. Run …check.
Codex coordinator
Claude coordinator
Follow-up to a chat worker
Approve once still works
CI: green except shard 10/12, agent-launch-at-rest.test.ts ("keeps a open failure out of the accepted launch reply"). That test fails for every PR against current main. It is being fixed in a separate PR.
Main reorganised the renderer store and agent status modules and
removed tests under its test policy (stablyai#43528).
- test imports follow the moved modules
- the detached restart test file is removed with main, and the one
test of the held notice moves to the after-switch test file
- the native chat recovery test expects whole mail again (stablyai#43380) and
awaits the switch where it polled for one second
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
When one agent sends a message to another agent's chat, Orca had stopped giving the agent the message. Since #43093 the agent got only "you have a message, run
checkto read it", while the chat showed the full message. So what you saw in the chat was not what the agent got, and every message cost the agent an extra step. Now the agent gets the full message again, exactly as the chat shows it.What Changed
orca orchestration checkand had to run it to see the message.checkfor chat mail. A message too large for one chat message still falls back to the pointer, as it did before fix(native-chat): send other agents' mail as a pointer and let the person approve a denied action #43093.check.Why
A chat must show exactly what its agent received. #43093 broke that, and made every chat agent spend a tool call per message, to fix a problem that exists only in Codex with automatic review. Agent-to-agent messages belong in the receiving agent's conversation as text, labeled with their sender. A pointer plus a tool read suits only some automatic task-finished notices and oversized results.
Not in this PR: Codex's automatic reviewer can still read another agent's message as the user's approval, as it could before #43093. The follow-up delivers agent mail to Codex as its own inter-agent message type, which its reviewer labels as coming from another agent. That needs its own real-Codex verification.
Linked Issue
Tracked in STA-15406. Tracked in #42608.
Visual Proof
QA results and screenshots will be in the status comment.
Testing
check. It fails on main, where the agent gets the pointer. The tests that encoded pointer delivery are back to whole delivery.pnpm check:changedpasses. The 7 affected test files pass (26 tests), andtc:nodepasses.Risk
Level: Low
Review
Agent skill upstream boundary
Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)