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
feat(orchestration): flag replies to superseded mail and ask agents not to ack - #51356
Agents that message each other sometimes answered an old message after the sender had already sent a newer one, so the answer no longer fit (for example "sign-in in progress" a minute after "signed in"). Agents also woke each other with short "thanks" or "got it" notes. Now a reply to an outdated message still goes through, but the replier is told about the newer message so it can correct itself. Agent-to-agent mail and the worker instructions carry one rule: answer once, only what was asked, with no acknowledgements.
Stacked on #51362; retarget to main once it lands.
Files
Added
Deleted
Net
Test
1
$\color{#1a7f37}{\Huge{\mathbf{+}}}$112
0
$\color{#1a7f37}{\Huge{\mathbf{+}}}$112
Prod
7
$\color{#1a7f37}{\Huge{\mathbf{+}}}$115
$\color{#cf222e}{\Huge{\mathbf{−}}}$30
$\color{#1a7f37}{\Huge{\mathbf{+}}}$85
What Changed
orchestration.reply: before storing the reply, look for newer mail from the same sender to the replier that the replier hasn't answered yet. It counts when it is on the same thread, or, for a worker and its coordinator, anywhere on the same Dispatch (mail into its dispatch: mailbox, or worker mail recorded from the same Dispatch), since all of that pair's mail is one task. Other pairs, such as two bots, stay thread-scoped. If found, the receipt's existing warnings list gains a superseded_reply warning that names the newer message and the orchestration inbox command that shows it. The reply is never blocked.
AGENT_STATUS_RULE (from fix(bots): record a bot's status to another bot on its item instead of waking it #51362) gains the answering rule: mail another agent only to ask, hand off, answer, escalate or report finished work; answer once and only what it asks; no acknowledgements or thanks; plain sentences. It replaces the worker preamble's separate mail wording, which now also names "finish with one worker_done".
Chat mail cards add [Agent mail. <rule>] only on peer agent mail whose answer stays in Orca. Owner item mail and mail whose answer goes to a person's thread never get it. On a card near the size limit the rule is dropped first, so the line saying where the answer goes is kept.
Why
Over three days, 47 replies answered mail that already had a newer message from the same sender, and about 130 acks and self-described FYIs woke their recipients. A receipt warning costs one indexed query per reply and doesn't change delivery.
Linked Issue
N/A (maintainer change)
Visual Proof
N/A: no UI change. The card line is agent-facing text outside the displayed content ranges.
Testing
superseded-reply-warning.test.ts (real dispatcher and in-memory DB): warns for newer mail on the same thread even when it was read; stays silent for another thread, mail the other way and mail already answered; counts a worker and its coordinator's newer mail on another thread. The reply tests fail without the change.
Real-agent run with Claude and Codex workers and bots: stale replies got the warning ("on this task" and "on this thread") and each worker sent one correction and one worker_done, with no loop. Different-thread mail between non-worker parties gave no warning. FYI mail to Claude and Codex bots drew no acknowledgement. An owner item instruction had no rule line and the bot carried it out. All nine workers reported exactly once.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
Performance
None, because it adds one indexed SELECT ... LIMIT 1 per local reply and one short line per peer chat mail card.
Risk
A false warning only adds a line to the receipt. Plain revert.
Level: Low
Notes
Cross-platform, remote and mobile: server-side text and a DB read only; paired-server replies take their own path and are unchanged.
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)
The changes add mail-answer guidance to shared agent rules and worker instructions. Structured mail now selects among sender-specific note variants based on the size limit. The reply path now checks for newer unanswered matching mail and includes any resulting warning in the reply receipt. Tests cover matching and non-matching messages.
Merge Risk: Low · up to 8eecd
Replies still go through. The remaining issues are minor: the new warning can be missed or mislead in some edge cases, and the new mail card names the production launcher in dev builds. Worth fixing before or shortly after merge, but not blocking.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the two main changes: a superseded-reply warning on replies (feat(orchestration)) and a request that agents not send acknowledgements. Both appear in the changeset (superseded-reply-wa…
Description check
The description follows the template sections (ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, Performance, Risk, Notes, Checklist). The Linked Issue section says N/A (maintainer change)…
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 two main changes: a superseded-reply warning on replies (feat(orchestration)) and a request that agents not send acknowledgements. Both appear in the changeset (superseded-reply-warning.ts, reply-method.ts, and AGENT_MAIL_ANSWER_RULE). It is a single line, though at 78 characters it is slightly long and joins two changes in one line.
Full details: Description check
Explanation
The description follows the template sections (ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, Performance, Risk, Notes, Checklist). The Linked Issue section says N/A (maintainer change), which the template permits for maintainers. The AI Disclosure and Review sections are missing, and the Risk level is filled in. The Performance section is complete. The Testing section gives concrete steps and platform notes. The Agent skill upstream boundary section is also missing. Several template checkboxes are unchecked, including the lint/typecheck/test/build item, which is deferred to CI. The description also has a stacking note about #51362.
Resolution
Optional: add the missing Agent skill upstream boundary checkbox and the Review section, and state which platforms were actually tested (macOS, Linux, Windows, SSH). Consider running pnpm lint, typecheck, test, and build locally before merge.
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.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
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.
Minor · Stability & Availability · Quick win
Measure the appended image blocks when selecting the note variant.
The note variant is selected by measuring only its text block. The image-ref blocks are appended after the check. When the text fits alone but text plus image references exceed MAX_PROMPT_BYTES, the host refuses the body. The mail is then parked and retried without success. The new reply rule can cause this by moving selection to a larger guided text. Include the image references in the size check, and append the same images to the chosen blocks.
Suggested fix
--- "a/src/main/runtime/orchestration/mailbox/structured-mail/structured-mail-source.ts"+++ "b/src/main/runtime/orchestration/mailbox/structured-mail/structured-mail-source.ts"@@ -181,14 +181,15 @@
}).text
: formatted.text
// The reply rule is dropped first, so a long mail keeps the line saying where its answer goes.
- const noted = withConversationNotes(guided, from, input).find(- (blocks) => !structuredAgentSessionBlocksTooLarge(blocks)- )+ const images = botItemMailImageBlocks(input.message)+ const noted = withConversationNotes(guided, from, input).find(+ (blocks) => !structuredAgentSessionBlocksTooLarge([...blocks, ...images])+ )
return {
body: {
kind: 'message',
role: 'user',
- blocks: [...(noted ?? whole), ...botItemMailImageBlocks(input.message)],+ blocks: [...(noted ?? whole), ...images],
from: {
...from,
orchestration: {
The reason will be displayed to describe this comment to others. Learn more.
Old questions get no warning
supersededReplyWarning runs only for ordinary mail. Replies to worker questions return earlier through the helper or run branches. If a worker asks a question and then asks a newer question on the same Dispatch, answering the older question sends no warning. This leaves part of the stale-reply problem unchanged. Run the check before storing local question answers too, and include it in their receipts.
The reason will be displayed to describe this comment to others. Learn more.
Unrelated threads trigger stale warnings
Mail to any dispatch: mailbox skips the thread check, even when the sender is not that worker's coordinator. When one helper sends another two unrelated questions on separate threads, replying to the first warns that the second supersedes it and suggests a correction. That can cause needless follow-up mail.
Check that the sender coordinates the recipient before allowing a different thread to match.
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.
Minor · Functional Correctness · Quick win
Use cliCommand for the reply command in the agent-mail rule card.
The [Agent mail.] card builds its rule from AGENT_STATUS_RULE, which hard-codes orca orchestration reply --id <msg>. The reply banner in the same function uses ${cliCommand}. In dev builds, cliCommand is orca-dev, so the card directs the agent to plain orca. The repository guide states that plain orca targets an installed production Orca, not the dev runtime that owns the message. The reply can then fail or reach the wrong runtime.
The correct banner does not cover this case. It appears only when the answer stays in the bound conversation. That branch never includes the rule, and the rule-bearing variant names no launcher.
Build the reply command for this card from cliCommand, so dev builds get orca-dev orchestration reply.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Functional Correctness · Quick win
Add the superseded-reply check to question answers.
Answers to questions skip the superseded-reply warning. The helper and run branches return before the lookup at line 191, so their receipts never include superseded_reply.
A worker can hold more than one open question. With wait: false, ask returns while the question stays open, and a new question is created without checking for an open one. A newer open question from the same Dispatch matches the superseded query. If the older question is answered through either branch, the warning is not returned, even though the worker-to-coordinator question channel is the case this lookup targets.
Compute supersededReplyWarning(db, original) before answerQuestion in both branches. Add the result to the receipt's warnings when present. Apply this to the federated return in the run branch as well. The warning is advisory and does not block the answer, so delivery is unaffected.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Functional Correctness · Quick win
Limit the cross-thread provenance match to mail with the Dispatch's coordinator.
The message_dispatch_provenance branch matches on Dispatch identity alone. A worker that sends to a peer agent on two threads gets provenance rows for the same Dispatch on both messages. A later reply to the first message can then match the second message, and the warning says "on this task". The helper's doc comment limits cross-thread matching to a worker and its coordinator, so this match is outside the stated contract.
The dispatch: mailbox branch has the same gap. It matches any sender to a worker mailbox across threads without checking that the sender is the coordinator.
Require that cross-thread matches apply only when the recipient is the coordinator of the original sender's Dispatch. Keep same-thread matching unchanged.
message: `${newer.id} from ${original.from_handle} ${where} is newer than the message you answered; read it with \`${localOrchestrationCliCommand()} orchestration inbox --terminal ${original.to_handle} --limit ${newer.rows_since} --full\`, and send a correction if your reply no longer fits.`
The reason will be displayed to describe this comment to others. Learn more.
Minor · Functional Correctness · Quick win
The superseded-reply command can omit the named message when the original mail is self-addressed.
The warning counts recipient mail before the reply is stored. For self-addressed mail, the stored reply lands in the same mailbox. The inbox returns the newest --limit rows, so the reply uses one slot and pushes the named message out of the window. When rows_since is 1, the command shows only the reply.
Read mail does not cause this. The inbox history read includes read messages, and the limit is passed through without a clamp.
The count must cover the reply when the reply lands in the same mailbox. Either compute the limit after the reply is stored, or add one to the limit for self-addressed mail. The choice is open. Either way, the command must return the named message.
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
Agents that message each other sometimes answered an old message after the sender had already sent a newer one, so the answer no longer fit (for example "sign-in in progress" a minute after "signed in"). Agents also woke each other with short "thanks" or "got it" notes. Now a reply to an outdated message still goes through, but the replier is told about the newer message so it can correct itself. Agent-to-agent mail and the worker instructions carry one rule: answer once, only what was asked, with no acknowledgements.
Stacked on #51362; retarget to main once it lands.
What Changed
orchestration.reply: before storing the reply, look for newer mail from the same sender to the replier that the replier hasn't answered yet. It counts when it is on the same thread, or, for a worker and its coordinator, anywhere on the same Dispatch (mail into itsdispatch:mailbox, or worker mail recorded from the same Dispatch), since all of that pair's mail is one task. Other pairs, such as two bots, stay thread-scoped. If found, the receipt's existingwarningslist gains asuperseded_replywarning that names the newer message and theorchestration inboxcommand that shows it. The reply is never blocked.AGENT_STATUS_RULE(from fix(bots): record a bot's status to another bot on its item instead of waking it #51362) gains the answering rule: mail another agent only to ask, hand off, answer, escalate or report finished work; answer once and only what it asks; no acknowledgements or thanks; plain sentences. It replaces the worker preamble's separate mail wording, which now also names "finish with one worker_done".[Agent mail. <rule>]only on peer agent mail whose answer stays in Orca. Owner item mail and mail whose answer goes to a person's thread never get it. On a card near the size limit the rule is dropped first, so the line saying where the answer goes is kept.Why
Over three days, 47 replies answered mail that already had a newer message from the same sender, and about 130 acks and self-described FYIs woke their recipients. A receipt warning costs one indexed query per reply and doesn't change delivery.
Linked Issue
N/A (maintainer change)
Visual Proof
N/A: no UI change. The card line is agent-facing text outside the displayed content ranges.
Testing
superseded-reply-warning.test.ts(real dispatcher and in-memory DB): warns for newer mail on the same thread even when it was read; stays silent for another thread, mail the other way and mail already answered; counts a worker and its coordinator's newer mail on another thread. The reply tests fail without the change.Real-agent run with Claude and Codex workers and bots: stale replies got the warning ("on this task" and "on this thread") and each worker sent one correction and one
worker_done, with no loop. Different-thread mail between non-worker parties gave no warning. FYI mail to Claude and Codex bots drew no acknowledgement. An owner item instruction had no rule line and the bot carried it out. All nine workers reported exactly once.I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
Performance
None, because it adds one indexed
SELECT ... LIMIT 1per local reply and one short line per peer chat mail card.Risk
A false warning only adds a line to the receipt. Plain revert.
Level: Low
Notes
Cross-platform, remote and mobile: server-side text and a DB read only; paired-server replies take their own path and are unchanged.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)