fix(server): snoozed threads allow queued automatic wakes #19099
main fromrefs/pull/19099/head·merged by Yash-Singh1(GitHub profile, opens in a new tab) View on GitHubProblem#
Snoozing a thread failed when it had a queued automatic wake, even though that work should stay queued while the thread is snoozed. Also, Stop and process recovery could leave provider-buffered wakes queued after their output had been discarded.
Change#
Allow snoozing when queued runs belong to notifications or delegated task completions, while keeping user messages as blockers. Cancel buffered provider notifications when Stop or startup/shutdown recovery discards their provider output. Include queued message records in projection recovery reads so held buffered wakes can be found.
Scope and approval#
This is a focused server fix for queued automatic wakes. User messages still prevent snoozing, and durable automatic messages remain queued across snooze and recovery.
Verification#
Added orchestration tests for snoozing notifications and delegated completions, preserving queued user messages, cancellation on Stop, and cancellation during startup and shutdown recovery. Existing test changes supply empty message projections where required.
Closes discussions#
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
juliusmarminge added labelsmacroscope-review
Approvability#
Verdict: Approved at
6c0a0a4Macroscope's review found this PR approvable — This is a contained orchestration bug fix that distinguishes durable queued work from provider-buffered automatic wakes across snooze, Stop, and recovery paths. The production changes are localized and backed by targeted tests, with no schema, deployment, security, billing, or default-setting impact.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
-
⚙️ Run configuration
-
- Configuration used: Path: .coderabbit.config.ts
- Review profile: CHILL
- Plan: Team
- Run ID:
a5769f41-86db-4304-a87c-4719a248d94a
📥 Commits
-
Reviewing files that changed from the base of the PR and between a13975b17d6b309aae4c3170134ed13b60a70b18 and 6c0a0a4aa08170e49f9eb0ace870d340d2800ab7.
📒 Files selected for processing (4)
-
apps/server/src/orchestration-v2/ProjectionRecovery.test.tsapps/server/src/orchestration-v2/ProviderRuntimeRecoveryService.test.tsapps/server/src/orchestration-v2/ProviderRuntimeRecoveryService.tsapps/server/src/orchestration-v2/ThreadStop.test.ts
Included review availability: This review used your included allowance. 7 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 10 reviews per hour.
-
📝 Walkthrough
-
The server now distinguishes buffered provider notifications from other queued messages. Thread stop cancels buffered provider notification runs. Snooze checks allow notification and delegated-completion wakes. Runtime recovery applies separate handling to buffered notifications and other queued runs.
Changes: Buffered Provider Notification Handling
Layer / File(s) Summary Stop and snooze handling
apps/server/src/orchestration-v2/NotificationMailbox.ts,apps/server/src/orchestration-v2/Orchestrator.ts,apps/server/src/orchestration-v2/runtimeLayer.test.ts,apps/server/src/orchestration-v2/ThreadStop.test.tsThe new predicate identifies agent messages created by the provider that have a notification and no delegated completion. Thread stop cancels queued runs backed by these messages and holds other queued runs. Snooze checks allow queued notification and delegated-completion wakes, while user-message runs still block snoozing. Tests cover both stop operations and snooze/unsnooze behavior. Buffered notification recovery
apps/server/src/orchestration-v2/ProviderRuntimeRecoveryService.ts,apps/server/src/orchestration-v2/ProjectionRecovery.test.ts,apps/server/src/orchestration-v2/ProviderRuntimeRecoveryService.test.tsRuntime recovery reads messages for queued runs and retains buffered provider notification runs for cancellation processing. Other unheld queued runs continue through the existing hold logic. Recovery tests cover startup and shutdown reconciliation; the runtime recovery test mock now provides getThreadRecords.Priority: ⬇️ Low
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix · Severity of issue fixed: Low
Suggested reviewers:
juliusmarminge
Merge Risk: ⚪ Minimal · up to
6c0a0-
The inspected stop, snooze, and recovery paths preserve queued user and durable automatic work while handling buffered provider notifications. No identified issue currently blocks merging.
Pre-merge checks ·
4-
Passed checks (4 passed)-
Check name Status Explanation Description check The description covers the problem, implementation, scope, linked issues, and focused verification. It does not state observed test results, but it provides sufficient detail for this focused fix. Title check The title clearly and concisely identifies the main change: allowing snoozed threads to retain queued automatic wakes. Linked Issues check The changes satisfy the coding requirements for #16233and#15862.thread.snoozenow ignores queued notification and delegated-completion messages, while queued user messages still block snooze. The…Out of Scope Changes check The changed production code and tests support the linked issue requirements. The message classifier, snooze guard, Stop handling, recovery handling, projection reads, and orchestration tests all addre…
-
✨ Finishing Touches
-
📝 Generate docstrings
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
-
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
Yash-Singh1(GitHub profile, opens in a new tab) closed this
Thread transfer impact#
✅ Thread transfer remains within every enforced ceiling.
Provider Metric Main baseline This PR Impact PR ceiling Codex Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅ Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅ Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅ Codex Live turn WebSocket decoded 20.9 KiB 20.9 KiB 0 B (0.0%) 29.3 KiB ✅ Codex Live turn messages 2 2 0 (0.0%) 8 ✅ Claude Total thread wire 5.0 KiB 5.0 KiB −24 B (−0.5%) 6.8 KiB ✅ Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅ Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB −24 B (−2.0%) 2.0 KiB ✅ Claude Live turn WebSocket decoded 21.2 KiB 21.2 KiB −41 B (−0.2%) 29.3 KiB ✅ Claude Live turn messages 2 1 −1 (−50.0%) 8 ✅ Baseline:
42160f2· PR result:6c0a0a4· Source CI: successScenario and decoded snapshot size
10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
- Codex decoded thread snapshot: 108.5 KiB
- Claude decoded thread snapshot: 108.8 KiB
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed