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(bots): an empty Slack turn is asked once more before the thread hears there was no answer - #47907
Sometimes a bot finishes a Slack request without writing any answer: it ran its tools and then stopped. Now Orca quietly asks the bot once more, in the same chat, to give its answer. The person in Slack never sees that second ask, only the answer. If the bot still says nothing, the thread gets the "No answer was returned" line. If the bot already tried to post into Slack itself during that turn, it is never asked again. If it chooses to stay silent on purpose, it stays silent.
Files
Added
Deleted
Net
Test
5
$\color{#1a7f37}{\Huge{\mathbf{+}}}$274
$\color{#cf222e}{\Huge{\mathbf{−}}}$298
$\color{#cf222e}{\Huge{\mathbf{−}}}$24
Prod
22
$\color{#1a7f37}{\Huge{\mathbf{+}}}$949
$\color{#cf222e}{\Huge{\mathbf{−}}}$43
$\color{#1a7f37}{\Huge{\mathbf{+}}}$906
What Changed
Before: a bot's Slack turn that succeeded but wrote nothing after its last tool call was closed as "no answer" right away. A turn that wrote a sentence like "I'll run the command now", then ran tools and stopped, posted that sentence as its answer.
After:
Empty now means no words after the root agent's last tool call or file edit (structuredAgentSessionTurnReply). A sub-agent's calls running beside the answer don't count. Bot chats only; other Slack-linked chats keep reading their newest words.
Words written before the last tool call are not posted while a retry can still ask for the answer. When no retry runs (the turn answered more than one request, it was found at boot, its retry was refused or never ran, or it is the retry itself), those words answer as before, filtered through the quiet marker. The exception is a turn whose chat tried a post of its own into the thread it answers (a reply, or a post or attach there; a staged upload or an outright refusal doesn't count, a lost answer does): it closes as no_answer.
An empty bot turn, at its live end, gets one retry only when nothing it ran may have acted (reads only; the same toolCallHasSideEffects rule as the check-first note): a short message in the same chat asking for the answer from what it already has, without calling more tools, repeating an answer it wrote earlier, and allowing an exact NO_REPLY. It runs only when one request opened the turn and the turn answered no other. It acts for that opener's asker, or for no one named when the opener is a restart or usage-limit continuation of one cut request, never the owner. The retry's turn answers the request: words post, a bare NO_REPLY stays quiet, still empty closes as no_answer, with the check-first note if the retry itself acted.
No retry when: something in the turn may have acted (it goes straight to the no-answer line with the check-first note); the turn answered more than one request (so no retry acts for the wrong asker); the turn was found at boot; the chat tried a post of its own during the turn, counted before the cloud call so an uncertain result also counts (it closes as no_answer; the service already hides that line under a plain-text reply keyed to the request); the rows were retried before (also after a usage-limit pause recut them); a row came from an older build (its own quiet rule fills it live); a leave line is owed at this end (it would post before the retry's answer); the turn failed, was stopped, interrupted or cut by a usage limit; the chat is busy, or has run a newer turn, when the retry would go out; connectors were turned off meanwhile.
A refused retry closes its requests within the recovery's settle delay: with the words written before the last tool, or as no_answer when there were none.
Mechanism:
The reply fill, after the usage-limit pause check, asks emptyTurnRetry.hold. It cuts the turn's own rows (open ones and those its continuation claimed) under the empty turn with the existing restart cut kind, and marks them empty_retried with the turn's tools_ran, in one write that skips rows already retried. Then it sends the retry carrying a connectorClaim of that cut, so its admission claims the rows through the existing claim path. No new value in the stored claim kind.
The retry is sent as a continuation, so it is not announced as a person's message and the Slack mirror never posts it.
While the send is in flight, recovery leaves those rows. A row held for a retry that never claimed it (refused, or the app quit first), whose cut turn ended in success, closes with that turn's words before its last tool (one pass per cut turn per read, through the quiet marker), or as no_answer.
A no_answer fill keeps the tools_ran a hold stored, so the note reflects the first turn's tools.
New column empty_retried, added like the earlier ones (no user_version change).
Why
Codex drops its commentary phase when its items are translated, and Claude writes text between tool calls, so a check for no words anywhere in the turn almost never fired, and the preamble got posted as if it were the answer. A single retry from the live turn end gets a real answer in most of these cases without ever repeating a tool or a post.
Linked Issue
N/A (internal).
Visual Proof
N/A: no Orca UI change. The retry shows in the bot's Orca chat as a user message, as the usage-limit continue does.
Testing
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
connector-reply-restart-matrix.test.ts drives the real journal, fill and recovery:
an empty live turn is asked once; the retry ends empty too, and the request closes as no_answer with the first turn's tool kept, with exactly one ask;
a turn found at boot that wrote words only before its last tool call closes as no_answer with no ask (fails on the old "newest prose" rule);
a turn whose chat tried a post of its own closes as no_answer with no ask (fails without the guard);
a refused ask closes as no_answer (fails without the recovery rule).
A second retry is blocked by the stored empty_retried guard in the hold write. pnpm check:changed passes on macOS.
Performance
One extra model turn per empty bot turn, only. The hold is one write per empty turn; the post record is one map entry per chat that posted, capped at 1000 chats; recovery reads a held cut's turn verdict once per read; recovery's extra check is a set lookup per unfilled row it already reads. No timers, polling or new journal reads.
Risk
The riskiest part is the retry turn itself: the model could call a tool anyway. The prompt tells it not to; Orca never replays a tool or resends a post itself.
An older build reading a held row sees a restart cut it doesn't own and closes it as stopped; it never posts twice.
A post the bot made to another channel during the turn also blocks the retry (conservative).
Back out with a plain revert; the added column stays unused.
Level: Medium
AI Disclosure
Review
Agent skill upstream boundary
Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.
No introduced performance blocker found. Compared a9c0cee429358ed9316e8c0050a629cfd77a3c97 → 8d1be9678c5c399e7036788c5ddc2e3d1d7e01be; the supplied diff exactly matches that comparison.
Evidence is source-derived operation counts and ownership tracing. No runtime tests, timing, CPU or heap measurements were performed. Changed work, triggers and bounds
Let I be items in one chat’s operation window, D its expanded delivery IDs, R its reply rows, H held rows, and C distinct held cuts.
Changed work
Trigger and population
Cost, owner and bound
Turn reply reader
Live linked turn end or recovered answering turn
Main-process pass over at most I items, replacing two independently traversed populations. Exits when prose, bot prose and tools-ran are known; no extra journal read. See structured-agent-session-turn-reply.ts:16.
Bot prose selection and attribution
Each relevant turn fill
Selects already-derived prose; checks at most the turn’s stamps and copies opener metadata. No new history scan or I/O.
Retry eligibility and hold
Live, successful, empty bot turn with owned rows, a start timestamp, no recorded post attempt and no previous retry
Linear passes over owned rows/stamps; one writer-lane maintenance transaction. Open updates use the primary key; deduplicated claim updates use the claim index. Durable empty_retried prevents another hold. See external-conversation-reply-empty-retry.ts:58 and journal-connector-replies.ts:169.
Retry admission and withdrawal
One successfully held turn
One continuation send and one currentWork() invocation under chat admission; at most one queued-message withdrawal. Work reads reuse the validated journal cache or indexed current-work populations, with existing stale-authority retries. They select current prompts/unsettled inputs, rather than all transcript history.
Retry tracking and recovery wake
Hold begins; send settles
Set contains delivery keys for pending sends, removed on failed hold or send settlement. Send settlement schedules the existing debounced recovery mechanism. Abort prevents admission and subsequent recovery scheduling; it does not cancel an already-issued host send.
Post-attempt recording
Connector post/reply/attach RPC or bot reply
Constant-count map operations per attempt; one lookup for retry eligibility. One application-owned map, capped at 1,000 entries, with oldest-attempt eviction. No timers or per-chat listeners.
Recovery exclusion and cut verdict
Existing recovery pass
Constant-time sending check per row on two existing row passes. Cut verdict lookup scans at most I items once per distinct cut, including cached missing verdicts: worst case O(CI + R), with O(C) read-local retention.
Held answer grouping
Recovery produces held no_answer rows
Zero item traversal when H=0; otherwise one traversal of I items and D delivery IDs, followed by linear held-row grouping: O(I+D+H) time and transient storage. No per-held-row message search. See external-conversation-reply-empty-retry.ts:194.
Schema, reads and fill preservation
Database opening, reply decoding and existing fill writes
One additional column-presence query per schema initialization; nullable column addition once per older database. One scalar check per decoded row and a scalar COALESCE in existing updates. No added whole-state serialization or transaction per row.
Wiring, types and tests
Seam installation or test execution
One retry owner attached to the existing seam; no additional subscription. Type changes have no runtime cost. Five added test cases affect test execution only.
Scale and baseline accounting
At 100 agents, 100 qualifying empty turns introduce at most 100 retry sends, not one send per held delivery. At 1,000 agents, that becomes 1,000 necessary sends; there is no fleet inventory in each admission.
For H=100, I=10,000, held grouping visits 10,000 items once. Increasing either dimension 10× adds its own linear work; increasing both gives 100,000 item visits plus 1,000 held-row grouping operations, excluding expanded delivery IDs.
Pre-existing amplification: recovery’s messageOf() searches the window per row, and recovered-turn processing traverses the snapshot per turn. Placement alone can visit up to R×I items: 1 million at R=100, I=10,000; 10 million when either dimension grows 10×. These mechanisms already exist in the base.
The new cut-verdict cache retains a distinct-cut lookup cost, C×I; it does not claim a constant bound across different cuts. Held-row grouping avoids multiplying its item traversal by H.
Added recurring steady-idle wakeups: 0/s on main, renderer and daemon. Retry settlement adds an event-triggered recovery wake, not a recurring timer. Regression-class dispositions
| Classes touched | Disposition |
|---|---|
| Hot-path rescans; re-reading unchanged input | Reader consolidates two passes; grouping traverses items only when needed; verdicts cache by cut for the read. Existing recovery rescans identified above remain pre-existing. |
| Sync SQLite; persistence/write amplification | New SQL stays on the writer worker, uses indexed targets and shares one maintenance transaction. |
| Per-entity retention; queues and abandoned work | Timestamp map capped at 1,000; send keys released on settlement; durable one-retry guard; queued retry withdrawal traced. No separate retry loop introduced. |
| Idle wakeups; ownership multiplication; eager imports | No recurring wakeup, per-row owner or new SDK dependency graph found. | Six-question coverage: (1) expensive retry work follows eligibility gates; grouping skips item work without held rows. (2) Ownership is per seam, not per mounted consumer. (3) Main pays projections/grouping; reader and writer workers pay SQL. (4) Work scales with the affected chat’s required rows/window, with costs stated above. (5) No new platform probes or per-item SSH calls; Windows/Linux/live remote execution was not exercised. (6) Settlement releases transient keys, queued asks are withdrawn, and existing recovery owns refused/restarted holds.
The added tests were inspected but not executed. This verdict covers the traced work counts and bounds; it makes no measured latency or memory claim.
Problem. A bot's Slack turn that ran tools and stopped without writing an answer was closed as "no answer" at once, or it posted the sentence written before its tools as if that were the answer.
User-facing change.
An empty turn gets one hidden retry in the same chat only when nothing it ran may have acted: reads only, by the same rule as the check-first note. One request must have opened the turn, and the turn must have answered no other. The person sees only the eventual answer.
When something may have acted, the thread gets "I finished without writing a reply. Ask again if you still need one." at once, with "I may have already taken some actions, so check before asking again."
If the retry is also empty, the thread gets the same line.
When no retry runs, words the bot wrote before its last tool answer, as on main. The exception is a turn whose chat itself posted into the thread.
No retry when a leave line is owed, or when the turn answered a steered or joined message (so no retry acts as the owner for someone else's request).
File edits recorded as diffs end the commentary before them.
What counts as the chat's own post:
only a reply, or a post or attach into the answered thread, within the turn's start and end;
each post is keyed by its post id;
staged uploads and outright refusals don't count; lost or uncertain posts do.
A refused or rejected retry falls back to the held turn's own words, through the quiet marker.
Final rounds: the hidden ask names no one (so Orca's chat never shows it as the Slack person's); a post counts only for the thread it went to and only within the turn's start and end; a turn carrying another request gets no retry; a recovered answer keeps its request's own head; an empty retry closes with the no-answer line even if it wrote words before a tool.
Per surface. Orca-only chats: no change. Slack: the retry and the fallback rules above. GitHub and Linear: nothing held or retried; what posts is unchanged.
Deferred (decided or matching main):
A retry that also comes back empty closes with the no-answer line, even if the first turn wrote words before its last tool. Brennan chose this.
After a restart, post attempts (kept in memory) are gone, so recovery may post earlier words after a tool post, as main does.
Verified.
Matrix invariants through the real journal, fill and recovery: a reads-only turn is asked once; a turn that acted is never asked; older-build rows aren't held; a refused retry answers with the earlier words or stays quiet on NO_REPLY; boot and post-attempt cases. Post-attempt record invariant test.
pnpm check:changed passes. Final blinded audit on this head: SAFE. Perf scan: clean (comment above). CI green.
Not run: a real Slack run. The QA machines can't deliver Slack messages into a test copy of Orca.
Once per ended connector turn, plus once per recovered turn
O(journal items). It replaces the old two passes (the reverse prose scan plus the .some side-effect scan). It stops early once prose, bot prose and toolsRan are all known. The side-effect regexes stop running after the first hit.
It does less work than before. A read-only turn still scans the whole window, as it did before.
outboxTurn → journalTurnAnsweredMessages
Once per ended turn
O(submissions + steers×items). Steers per turn are few, and the same call already runs in connectorReplyTurnStamps.
One extra small pass per turn end. No retained state.
emptyTurnRetry.hold
Per live bot turn end that passes about 9 cheap gates (no_answer, no tools, has an asker, and so on)
One holdForRetry SQL write per empty turn, over that turn's own rows (keys + claims). At most one retry per row, enforced by the empty_retried IS NULL condition.
One write-queue op. The sending set is keyed by the turn's rows and released in finally. The send is not awaited but always settles.
emptyRetrySend
Once per held turn
One currentWork read in beforeRun, one send, and an optional queuedMessageDelete
Ends on the abort signal. No timer.
Recovery cutTurnVerdict / cutTurnWords
Per recovery read, only for rows held for a retry
Cached per cut per read, so it is one turn-reply pass per cut, not one per row
The caches live only for that read.
heldHeads
Per recovery fill
Returns immediately when no rows were held. Otherwise one pass over snapshot items.
Local maps only.
retrySending filter in recovery
Each recovery read
O(rows), one set lookup each
None
ConnectorPostAttempts
Each post into the thread from connector.act or connector.reply
Capped at 1000 chats × 32 attempts each, with LRU eviction. since() checks at most 32 entries.
Memory-only and capped. An attempt without a post id gets a fresh {} key, which the 32-entry cap still bounds.
Schema empty_retried column and COALESCE
Added at migration, written on fill
Same as the existing columns
No index change.
Six questions:
Work before skip gates: the cheap gates run before any I/O.
Ownership multiplication: no; there is one module-level attempts store and one retry per outbox.
Thread/storage cost: one extra SQL op per empty turn, on the writer's maintenance queue.
Growth/progress: every structure is capped or released, and a row is retried at most once.
Execution host: main process, the same paths as before.
Cancellation/cleanup: the send is gated on the abort signal, sending is released in finally, and settled is skipped once aborted.
…re before the thread hears there was no answer
The retry runs only when one request opened the turn, it answered no other, and nothing it ran may have acted.
Otherwise the thread gets the no-answer line at once. When no retry runs, words written before the last tool
still answer, unless the chat itself posted into the thread during the turn.
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.
No actionable comments were generated in the recent review.
Walkthrough
The change adds one-time retry handling for eligible live empty bot turns. It tracks connector post attempts, stores retry state in the journal, and updates reply filling and recovery to use held answers or earlier prose. Turn data now includes bot prose and retry-asker attribution. New tests cover retry eligibility, outcomes, recovery, and restart cases.
Merge Risk: Low · up to 3cbce
This change retries eligible empty Slack bot turns once, silently. Two narrow edge cases remain open. A post into an unrelated thread can suppress an eligible retry, which falls back to earlier words. A 429 response after an accepted post might not be counted, which could allow a duplicate answer. Both are low impact and bounded, so the change is mergeable with follow-up on these two points.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: an empty Slack bot turn is asked once more before the thread is told there was no answer. The changeset adds a single live empty-turn retry, its journal hold, and reco…
Description check
The description follows the repository template. It has the ELI5, What Changed, Why, Testing, Performance, Risk, and Checklist sections, with the Level set to Medium. The Linked Issue section says 'N/…
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: an empty Slack bot turn is asked once more before the thread is told there was no answer. The changeset adds a single live empty-turn retry, its journal hold, and recovery handling, so the title matches the primary change. It is specific and uses the 'fix(bots):' prefix, though it is long at 93 characters.
Full details: Description check
Explanation
The description follows the repository template. It has the ELI5, What Changed, Why, Testing, Performance, Risk, and Checklist sections, with the Level set to Medium. The Linked Issue section says 'N/A (internal)', which departs from the template's requirement that a linked issue always exist, but the author has explained why. The Visual Proof section gives a reason for N/A. The AI Disclosure section is blank, and the template says to fill it in unless the author is an internal team member, so this is a small gap. The Fixes line is also absent. These are minor gaps and the description is otherwise thorough and specific.
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; 4 remain after this review.
Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.
Build snapshots with consistent journal sequence order.
p.turn() assigns consecutive sequence values to the prose and completed turn. This inserts a tool between those rows in array order, but no integer sequence value can place it between them in journal order. The other inserted-tool cases have the same mismatch.
Create the prose, tool, and completed turn together with increasing sequence values. This keeps these recovery tests valid for readers that use durable sequence order.
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: c217c1c6-2dee-4be8-ada9-9d99b9a61355
Commits
Reviewing files that changed from the base of the PR and between 6af4933 and 00746bd.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
Perf scan, hot-path surface (fresh reviewer, head 261b9f7)
I found no performance regressions. Everything new is bounded, nothing grows without a cap, and the change adds no timers. The only new database write happens once per empty bot turn that gets its single retry.
Changed work
Trigger / population
Bound
New scans / timers / I/O / state
structuredAgentSessionTurnReply (now one backward pass that also returns botProse)
Each turn end that has an outbox (live) and each turn recovered at boot; items in the read window
O(window items); stops early once all three answers are known
Replaces the old two passes (the last-assistant-message helper plus a .some over every item) with one. Same or less work.
outboxTurn → turnAnsweredOthers
Each turn end that has an outbox
O(submissions + steers × items)
One extra call to journalTurnAnsweredMessages. connectorReplyTurnStamps already makes the same call, so this repeats a small pass. Steers are rare, so it's minor.
Reply fill quietIn / answeredIn
Each fill; rows of one session
O(rows × 32)
The quiet loop now runs over all rows instead of only when the marker is present. Each check is a cheap since(), and the loop still skips rows outside the conversations being filled or already decided.
emptyTurnRetry.hold
Live end of a bot turn that ended empty after read-only tools; at most once per request (empty_retried)
One holdForRetry maintenance write; one send; one currentWork in beforeRun
Adds a sending Set entry for each held row, removed in finally. Sends are fire-and-forget, and each settled ask leads to one recovery.turnEnded read.
ConnectorPostAttempts
Each orca bot reply / connector post / attach into the chat's own thread
1000 chats (least recently active evicted) × 32 posts each; since() checks at most 32 entries
Memory only, with a hard cap. Each refusal closure holds one per-chat map until the post call finishes.
One statement per key or claim, inside one maintenance write
No new index needed: the updates match the primary key, and claim_message_id lookups work as before.
Six questions: hot path touched? Yes, turn end and fill, but adding only O(window) or constant-sized work. Unbounded growth? No; both the map and the Set are capped or released. New timers or polling? None. New I/O? One maintenance write and one send per empty-turn retry, at most once per request. Repeated scans? One small repeat in journalTurnAnsweredMessages. Cleanup on abort? Yes: the signal blocks sends and settling, and finally releases the sending Set.
The reason will be displayed to describe this comment to others. Learn more.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
⚠️ Outside diff range comments (2)
Minor · Scope the retry post check to the answered… · external-conversation-reply-empty-retry.ts:93
src/main/external-conversations/external-conversation-reply-empty-retry.ts:93 Minor · Functional Correctness · Quick win
Scope the retry post check to the answered thread.
For an otherwise eligible turn answering thread A, a recorded post into thread B makes posted(turn) return true. The missing conversation argument makes since match any thread. The turn then receives no retry.
Check posts against the owned rows' conversations. A post into A must still block the retry. A post only into B must not block it.
Minor · Keep the attempt counted when the final response is HTTP 429. · connector-act.ts:268
src/main/runtime/rpc/methods/connector-act.ts:268 Minor · Functional Correctness · Quick win
Keep the attempt counted when the final response is HTTP 429.
actFailure treats a 429 as an uncertain outcome. Line 79 groups it with null and >= 500, and the message says the post "may have gone". The cleanup at line 268 uses a different predicate. A 429 satisfies answer.status < 500, so refused() clears the attempt. The same status is therefore uncertain for the error text and definite for the attempt record. If a 429 can follow an accepted post, the thread stops counting that post. The no-answer retry can then send a second answer.
Exclude 429 from the definite-refusal predicate. Lost responses, 5xx responses, and post_uncertain already stay counted. A 429 should follow the same rule. Refusals with other 4xx statuses still clear the attempt.
Also, reply is not removed at line 87. Line 87 only groups reply into the uncertain message branch.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
Perf scan, hot-path surface (fresh reviewer, head 3cbceae)
Changed work
Trigger / population
Bound
New scans, timers, I/O, retained state
structuredAgentSessionTurnReply
Every turn end, live or recovered
One reverse pass over the snapshot items, O(items). It can stop early only once toolsRan is true.
It replaces the old two passes (newest-prose lookup plus .some), so the worst case is unchanged and it often does less.
outboxTurn → turnAnsweredOthers
Every outbox turn end
O(submissions + steers × items)
journalTurnAnsweredMessages is a second call: connectorReplyTurnStamps already makes the same one. This repeats existing work once per turn end. It is minor and could reuse the first result.
Reply fill (answeredIn / quietIn)
Every fill, over the session's rows
O(rows × 32): each posted() check is a scan of at most 32 attempts
The silence loop now runs over every row, not only when the quiet marker might apply. There are few rows per session, so this is negligible.
retry.hold
Live, successful, empty bot turn whose tools only read, asked by one request
At most once per row, because empty_retried is checked in SQL
Per retry: one maintenance write (keys + claims) and one send that isn't awaited. The sending Set clears in finally. No timers.
emptyRetrySend
Each retry
One send, one currentWork, and at most one queuedMessageDelete
One RPC chain per retry. No polling.
ConnectorPostAttempts
Every bot reply, plus connector post or attach into the thread
1000 chats × 32 posts; the least recently used chat and the oldest post are dropped first
Bounded global map, memory only. since() is O(32).
Recovery: heldHeads, cutTurnVerdict, cutTurnWords
Recovery reads of a session with unfilled rows
heldHeads returns at once when no row is held, otherwise one pass over the items. The two cut lookups are cached per cut per read, O(items) each.
Caches live only for one read. The sending filter is O(1) per row.
fillRecoveredTurn (turnReplyOf)
Boot or recovery turn fill
Same single pass as above
None
SQL: empty_retried column, holdForRetry, COALESCE
Schema migration once, then per hold or fill
Updates by primary key or by claim_message_id
One nullable column. No new index; the claim update follows the existing release path.
Six questions: trigger = turn end, fill, recovery read, or a connector post · population = rows per session (small), items per snapshot window · bound = O(items) per turn end, O(32) per post check, at most one retry per row · no new scans beyond existing O(items) passes · no new timers or polling · retained state = a bounded LRU (1000×32) plus a sending Set cleared when each send settles; new I/O = one write and one send per retry.
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
Sometimes a bot finishes a Slack request without writing any answer: it ran its tools and then stopped. Now Orca quietly asks the bot once more, in the same chat, to give its answer. The person in Slack never sees that second ask, only the answer. If the bot still says nothing, the thread gets the "No answer was returned" line. If the bot already tried to post into Slack itself during that turn, it is never asked again. If it chooses to stay silent on purpose, it stays silent.
What Changed
Before: a bot's Slack turn that succeeded but wrote nothing after its last tool call was closed as "no answer" right away. A turn that wrote a sentence like "I'll run the command now", then ran tools and stopped, posted that sentence as its answer.
After:
structuredAgentSessionTurnReply). A sub-agent's calls running beside the answer don't count. Bot chats only; other Slack-linked chats keep reading their newest words.no_answer.toolCallHasSideEffectsrule as the check-first note): a short message in the same chat asking for the answer from what it already has, without calling more tools, repeating an answer it wrote earlier, and allowing an exactNO_REPLY. It runs only when one request opened the turn and the turn answered no other. It acts for that opener's asker, or for no one named when the opener is a restart or usage-limit continuation of one cut request, never the owner. The retry's turn answers the request: words post, a bareNO_REPLYstays quiet, still empty closes asno_answer, with the check-first note if the retry itself acted.no_answer; the service already hides that line under a plain-text reply keyed to the request); the rows were retried before (also after a usage-limit pause recut them); a row came from an older build (its own quiet rule fills it live); a leave line is owed at this end (it would post before the retry's answer); the turn failed, was stopped, interrupted or cut by a usage limit; the chat is busy, or has run a newer turn, when the retry would go out; connectors were turned off meanwhile.no_answerwhen there were none.Mechanism:
emptyTurnRetry.hold. It cuts the turn's own rows (open ones and those its continuation claimed) under the empty turn with the existingrestartcut kind, and marks themempty_retriedwith the turn'stools_ran, in one write that skips rows already retried. Then it sends the retry carrying aconnectorClaimof that cut, so its admission claims the rows through the existing claim path. No new value in the stored claim kind.no_answer.no_answerfill keeps thetools_rana hold stored, so the note reflects the first turn's tools.empty_retried, added like the earlier ones (nouser_versionchange).Why
Codex drops its commentary phase when its items are translated, and Claude writes text between tool calls, so a check for no words anywhere in the turn almost never fired, and the preamble got posted as if it were the answer. A single retry from the live turn end gets a real answer in most of these cases without ever repeating a tool or a post.
Linked Issue
N/A (internal).
Visual Proof
N/A: no Orca UI change. The retry shows in the bot's Orca chat as a user message, as the usage-limit continue does.
Testing
connector-reply-restart-matrix.test.tsdrives the real journal, fill and recovery:no_answerwith the first turn's tool kept, with exactly one ask;no_answerwith no ask (fails on the old "newest prose" rule);no_answerwith no ask (fails without the guard);no_answer(fails without the recovery rule).A second retry is blocked by the stored
empty_retriedguard in the hold write.pnpm check:changedpasses on macOS.Performance
One extra model turn per empty bot turn, only. The hold is one write per empty turn; the post record is one map entry per chat that posted, capped at 1000 chats; recovery reads a held cut's turn verdict once per read; recovery's extra check is a set lookup per unfilled row it already reads. No timers, polling or new journal reads.
Risk
restartcut it doesn't own and closes it as stopped; it never posts twice.Level: Medium
AI Disclosure
Review
Agent skill upstream boundary
Notes
Stacked on #47901, which is stacked on #47896.
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)