After an "Update everything", one fleet host took 78 s to become ready. 70 s of that was delegated-task recovery at startup. Startup holds the effect worker until recovery ends, so agents could not resume during that time.
Recovery finalized every terminal run in a parent thread whose message had ever been a delegated delivery. Each call reloaded the thread's runs, messages, subagents, and turn-item positions, then returned without writing. Only the run that holds a cohort's current delivery message can settle anything. On that host, one parent had 190 past deliveries, which caused 188 serial reloads (about 66 s, no writes).
Recovery now reads only the thread's runs. It finalizes only terminal runs whose input is a cohort's current delivery message. finalizeDelegatedCompletionDelivery already ignored every other run, so delivery behavior does not change. Startup spans now also record the recovery candidate counts.
Proof
- New test: a parent with 40 settled deliveries and 1 current one. The current delivery settles and a second recovery changes nothing. Before this change, recovery read the delivery message 41 times. Now it reads it once.
- Local fixture with 190 past deliveries: recovery went from 320 ms and 1,347 SQL statements to 7 ms and 13 statements.
- All 27 test files that use delegated recovery pass (847 tests).
Not in this PR: the time before the new process starts (likely the full DB backup on ext4, see #18633), and the slow restart continuations after ready, which wait on the SQLite connection behind background sweeps.
Reviewed with sol-loop: 1 round with GPT-6.1-Sol on high.
Created with Claude Opus 5.5 in Claude Code (T3 Code).
🤖 Generated with Claude Code
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
0ea0100a-3425-4a80-8d8b-fcd0f7ecfd43📥 Commits
Reviewing files that changed from the base of the PR and between 348f217a853dd4a23d7fa4834dedb05f545c2075 and edbfce1e04833dbe70e5372ca08abaed3d9275e1.
📒 Files selected for processing: 2
apps/server/src/orchestration-v2/DelegatedCompletionDelivery.test.tsapps/server/src/orchestration-v2/Orchestrator.tsIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
📝 Walkthrough
Recovery now matches terminal runs to current delegated-completion deliveries instead of scanning messages for historical delegated-completion payloads. Tests verify the query count and confirm a second recovery does not change run or subagent state.
Changes: Delegated completion recovery
apps/server/src/orchestration-v2/Orchestrator.ts,apps/server/src/orchestration-v2/DelegatedCompletionDelivery.test.tsuserMessageIdmatches a current delegated-completion delivery, and refreshes runs after finalization. The regression test checks that recovery queries the delivery-message projection once and that a second recovery leaves runs and subagents unchanged.Priority: ➖ Normal
Estimated code review effort: 2 (Simple) | ~12 minutes
Change: Bug fix
Suggested reviewers:
juliusmarmingeMerge Risk: ⚪ Minimal · up to
edbfcThis change speeds up restart recovery by skipping old, already-settled subagent deliveries while still finalizing the current ones. No concrete merge-blocking risk was identified.
Pre-merge checks:
4
✨ Finishing Touches
📝 Generate docstrings
🧪 Generate unit tests (beta)
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment `@coderabbitai help` to get the list of available commands.