Skip to content

fix(bots): tell the thread when a merged quiet turn would drop its reply - #46062

Merged
AmethystLiang merged 2 commits into
mainfrom
AmethystLiang/fix-orca-bot-p0
Nov 21, 2026
Merged

AmethystLiang merged 2 commits into
mainfrom
AmethystLiang/fix-orca-bot-p0

Conversation

@AmethystLiang

@AmethystLiang AmethystLiang commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

When worker mail delays a bot's completion and the final turn says NO_REPLY, the thread now gets a fixed notice asking the user to try again.

Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​585 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​585
Prod 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​113 $\color{#cf222e}{\Huge{\mathbf{−}}}$​15 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​98

What Changed

Count completed turns held by owed work at the live completion feed, and carry an optional count to the connector. A delivery-triggered bot completion with multiple turns and newest text NO_REPLY emits only: “I replied but the message may not have reached you. Please ask again.” It uses the existing durable turn-end queue and retry key. Single-turn quiet completions stay silent. Held quiet answers are not counted, and a quiet answer to the thread's own message stays silent. Merged quiet decisions log only the turn count, decision and reason, and a turn end dropped because its start predates the watch is now logged; no ids or message text.

Why

Make coalesced suppression visible without recovering earlier answer text. Checked against how comparable products handle this.

Linked Issue

N/A — maintainer bug fix; no existing issue linked.

Visual Proof

N/A — no rendered UI change. Seeded connector regressions cover the fixed payload and its queued retry identity.

Testing

pnpm check:changed passes format, lint, typecheck, quality and ratchet checks; the selected unit test files pass. Reproduction covers worker status at 16:25:51 and quiet completion at 16:25:54. Tests cover coalesced fallback, subsequent single-turn silence, retry identity, constant-only output, repeated observations, per-session reset, stale-count reset, quiet held turns, a quiet answer to the thread itself, and the log shape. No live connector messages posted.

  • Manually tested with a live connector.
  • Automated regression coverage added.
  • Final local checks passed.

Performance

The completion feed retains one counter and last held identity per session. Each counter update takes constant work and adds no journal reads, text scans or receipt lookups. The fallback uses the existing queue and transport retry path.

Risk

Level: Low. A notice can ask for a retry even if an earlier reply arrived. Optional completion metadata needs no schema version bump or migration; older readers ignore it and older hosts keep their existing behavior. A revert restores quiet suppression but cannot retract notices already posted.

Review

Local engineering review passed.

Agent skill upstream boundary

  • Not applicable; no upstream skill-installer material is copied or translated.

Notes

Follow-up: stop worker status mail holding back turn completion, the trigger for this incident. The existing nonquiet merged-mail path may also surface a private-mail answer and remains a separate fix.

Checklist

  • Explained behavior, mechanism, risk and performance.
  • Considered platform, remote, mobile and folder-workspace compatibility.
  • No platform-specific paths, shortcuts, launches or rendered UI changes.
  • Required local checks and local review passed.

- Reset the held-turn count whenever owed work ends without an announced completion.
- Do not count a held quiet answer, and stay silent when the newest quiet turn answered the thread's own message.
- Log merged quiet decisions with only the turn count, outcome and reason; log turn ends dropped for an unknown start.
@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

The completion feed now tracks distinct provider turns held while work was owed and reports a merged-turn count when applicable. Chat events carry that optional count into external conversation handling, where quiet bot results can produce a fixed fallback based on the count and thread-answer state. The connector also logs turn-ended events with a null turn ID using aggregate fields.

Merge Risk: Moderate · up to efb36

The new "I replied but the message may not have reached you" notice can still be skipped in some merged-turn sequences. For example, a held quiet turn is the final turn, or a goal or child-work hold defers an earlier reply. The thread would then get no notice and the earlier reply would be silently lost, as before this change. This does not break existing behavior, but the fix is incomplete and should be corrected before merge.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: when a merged quiet bot turn would drop the thread's reply, the thread now receives a notice. It matches the summary, which adds a fixed fallback for multi-turn comple…
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.
Description check Passed The description follows most of the template. It has an ELI5, What Changed, Why, Visual Proof marked N/A with a reason, Testing with checkboxes, Risk with a level and revert plan, Agent skill boundary…
Full details: Title check

Explanation

The title names the main change: when a merged quiet bot turn would drop the thread's reply, the thread now receives a notice. It matches the summary, which adds a fixed fallback for multi-turn completions whose newest text is NO_REPLY, with supporting logging and held-turn counting. The title is specific and uses the conventional fix(scope) form.

Full details: Description check

Explanation

The description follows most of the template. It has an ELI5, What Changed, Why, Visual Proof marked N/A with a reason, Testing with checkboxes, Risk with a level and revert plan, Agent skill boundary, Notes, and Checklist. The Linked Issue section is marked N/A with a maintainer reason, but the template says an issue should always exist for outside contributors. The author is a maintainer, so the N/A is acceptable under the special-case note. The AI Disclosure section is missing; the template says to skip it only for StablyAI team members, and the author's status is not stated. The Why section is thin: it says the approach was checked against comparable products but does not name the alternatives considered. The Review section is brief. The Testing section lists local checks and regression coverage but does not name the platforms tested, which the template asks for.

  • 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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Review info

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: e1e853eb-72ae-4638-b350-dd26f7ea7b7a
Commits

Reviewing files that changed from the base of the PR and between 3ad8578 and efb361f.

Files selected for processing: 9

  • src/main/connector-cloud/connector-turn-events.test.ts
  • src/main/connector-cloud/connector-turn-events.ts
  • src/main/external-conversations/external-conversation-chat-turns.ts
  • src/main/external-conversations/external-conversation-chat.ts
  • src/main/external-conversations/external-conversation-coalesced-quiet.test.ts
  • src/main/external-conversations/external-conversation-turn-ends.ts
  • src/main/native-chat/agent-session-wire/observations/structured-agent-session-turn-completion-feed.test.ts
  • src/main/native-chat/agent-session-wire/observations/structured-agent-session-turn-completion-feed.ts
  • src/shared/agent-session/view/agent-session-turn-completion-wire.ts

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

return null
}
// Live work defers this end; its held turns still merge into whichever end is announced.
if (this.heldByLiveWork(sessionId, state, request)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Major · Functional Correctness · Heavy lift

Count nonquiet held turns that complete while live work holds the end.

When live work defers a successful completion, the nonquiet turn is not added to the held count. The next completion is then not mergedTurnCount > 1 if it is quiet. That completion stays silent, so the thread never learns that the earlier reply was dropped.

This can occur when the completed turn is observed with no owed work and no running turn, and the next turn starts without an observed owed-work state for it. Goal continuation and child-work holds can produce this sequence.

Count each such nonquiet completed turn once, by request ID, in the held path. Keep quiet answers excluded, and keep the existing owesWork branch's deduplication intact.

}
const mergedTurnCount =
baseline.heldCompletedTurns +
(request.kind === 'turn' && baseline.heldRequest?.id !== request.id ? 1 : 0)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Major · Functional Correctness · Quick win

Count the released quiet turn when it was excluded from the held count.

If nonquiet A is held, quiet B is also held, and pending input is then withdrawn, heldCompletedTurns is one and heldRequest identifies B. This comparison adds zero for B. The completion omits mergedTurnCount, so the connector stays silent despite A's dropped reply.

Track whether heldRequest contributed to the count. Include the final turn when it did not. Preserve single-turn silence and avoid counting an already counted nonquiet turn twice.

@AmethystLiang
AmethystLiang merged commit 2ded221 into main Nov 21, 2026
64 checks passed
AmethystLiang added a commit that referenced this pull request Nov 21, 2026
…k DM

- A bot's reply to a Slack DM with words before NO_REPLY now posts those words, the trailing
  marker stripped; a reply that is only the marker stays quiet. Threads the bot follows, mail,
  items and automations keep today's rule. Decided per reply row (connectorReplyTurnOutcome),
  so the live outbox fill and boot recovery agree. A DM is read from the conversation id the
  cloud sets (Slack source only), never from message text.
- endRepliedTurn reports 'told' | 'not-covered' | 'unsafe'. The legacy turn end posts a DM's
  stripped words only when the journal stamps prove the turn answered that DM and no outbox
  row can also post them (mostly defensive since #46044 ends stamped Slack turns state-only).
- The merged-quiet fallback (#46062) no longer fires for a DM whose words now post, so the DM
  gets one post.
AmethystLiang added a commit that referenced this pull request Nov 21, 2026
…k DM

- A bot's reply to a Slack DM with words before NO_REPLY now posts those words, the trailing
  marker stripped; a reply that is only the marker stays quiet. Threads the bot follows, mail,
  items and automations keep today's rule. Decided per reply row (connectorReplyTurnOutcome),
  so the live outbox fill and boot recovery agree. A DM is read from the conversation id the
  cloud sets (Slack source only), never from message text.
- endRepliedTurn reports 'told' | 'not-covered' | 'unsafe'. The legacy turn end posts a DM's
  stripped words only when the journal stamps prove the turn answered that DM and no outbox
  row can also post them (mostly defensive since #46044 ends stamped Slack turns state-only).
- The merged-quiet fallback (#46062) no longer fires for a DM whose words now post, so the DM
  gets one post.
AmethystLiang added a commit that referenced this pull request Nov 21, 2026
…k DM (#46182)

* fix(connectors): NO_REPLY can't silence a bot's real answer to a Slack DM

- A bot's reply to a Slack DM with words before NO_REPLY now posts those words, the trailing
  marker stripped; a reply that is only the marker stays quiet. Threads the bot follows, mail,
  items and automations keep today's rule. Decided per reply row (connectorReplyTurnOutcome),
  so the live outbox fill and boot recovery agree. A DM is read from the conversation id the
  cloud sets (Slack source only), never from message text.
- endRepliedTurn reports 'told' | 'not-covered' | 'unsafe'. The legacy turn end posts a DM's
  stripped words only when the journal stamps prove the turn answered that DM and no outbox
  row can also post them (mostly defensive since #46044 ends stamped Slack turns state-only).
- The merged-quiet fallback (#46062) no longer fires for a DM whose words now post, so the DM
  gets one post.

* fix(connectors): only the owner's own DM hears words before NO_REPLY, and only the protocol marker goes

- C1-3: the marker loses its silence only for a delivery the bot's owner sent (the journal's asker
  role, marked on the turn's stamps); a member's DM, even one steered into item or worker mail,
  keeps today's rule. The preamble tells the bot the owner's DM posts the words before the marker.
- C1-1/C1-2: addressedBotWords strips every trailing marker but keeps a quoted mention ending a
  sentence (Use `NO_REPLY`), and a rest with no letter or digit (`> NO_REPLY`, `- NO_REPLY`) stays
  quiet.
- C1-4: the legacy DM-words branch is owner-gated too and documented as reachable only without a
  reply outbox; a test pins that with an outbox it never posts the words.

* fix(connectors): a continuation's claimed owner-DM row keeps its owner proof

A continuation (usage-limit pause, restart) answers rows its claim names, and those stamps carry no
asker, so the owner's DM answer ending in NO_REPLY was filled quiet again on the resume leg. The
fill now reads an unmarked DM row's admitting message (journalReads.submissionBody(row.messageId))
for its asker, with nothing new persisted, so live fill and boot recovery decide alike. A delivery
seen twice in a turn's stamps keeps the owner's mark (stamps are copies, never journal objects), and
rows that answered with words get no merged-quiet stand-in.

* fix(connectors): a queued owner DM keeps its owner proof after a pause, and askers are read only when needed

- A delivery to a busy chat is queued: its outbox row keeps the queue card's id, and the card is
  handed over as a new send. submissionBody gains an opt-in `family` read (the current send whose
  admission family is that card), used only by the fill's owner read, so a queued owner DM is
  answered after a pause and continue too; a member's queued DM stays quiet.
- journalAskedByOwner is the one production adapter (install and the restart matrix both use it).
- The fill reads askers only for a successful bot turn whose prose ends with the marker.
- Tests: queued owner/member through pause and continue on the real journal, the adapter, a
  member duplicate never marked owner, a quiet answer not counted as answered.

* fix(connectors): rows an earlier fill answered for the same turn count as answered

When boot recovery fills a turn's owner-DM row before its live end, the live fill skips that row,
so its conversation was missing from 'answered' and a merged-quiet stand-in could go out beside the
words. Rows whose stored fill is this turn's answered outcome now count too.

* fix(connectors): a turn's live end knows its answer after recovery's row was sent

Boot recovery and the live end fill through the same function, and a sent row is deleted, so the
live end could miss an answer recovery already sent and post the merged-quiet stand-in beside it.
The fill keeps, in memory and bounded to recent turns, the conversations each turn answered with
words, and seeds 'answered' from it.
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