Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): snoozed threads allow queued automatic wakes #19099

MergedYash-Singh1(GitHub profile, opens in a new tab)merged 2 commits intomain fromrefs/pull/19099/headmerged by Yash-Singh1(GitHub profile, opens in a new tab) View on GitHub

Problem

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 #16233 Closes #15862

Closes discussions

    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. juliusmarminge added labelsmacroscope-review

    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Approved at 6c0a0a4

      Macroscope'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).
    4. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Review in Change Stack →

      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.ts
      • apps/server/src/orchestration-v2/ProviderRuntimeRecoveryService.test.ts
      • apps/server/src/orchestration-v2/ProviderRuntimeRecoveryService.ts
      • apps/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.ts
      The 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.ts
      Runtime 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 · Passed 4
      Passed Passed checks (4 passed)
      Check nameStatusExplanation
      Description checkPassedThe 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 checkPassedThe title clearly and concisely identifies the main change: allowing snoozed threads to retain queued automatic wakes.
      Linked Issues checkPassedThe changes satisfy the coding requirements for #16233 and #15862. thread.snooze now ignores queued notification and delegated-completion messages, while queued user messages still block snooze. The…
      Out of Scope Changes checkPassedThe 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
      Comment `@coderabbitai help` to get the list of available commands.
    5. Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
      CodexThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      CodexLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
      CodexLive turn WebSocket decoded20.9 KiB20.9 KiB0 B (0.0%)29.3 KiB✅
      CodexLive turn messages220 (0.0%)8✅
      ClaudeTotal thread wire5.0 KiB5.0 KiB−24 B (−0.5%)6.8 KiB✅
      ClaudeThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      ClaudeLive turn WebSocket wire1.2 KiB1.2 KiB−24 B (−2.0%)2.0 KiB✅
      ClaudeLive turn WebSocket decoded21.2 KiB21.2 KiB−41 B (−0.2%)29.3 KiB✅
      ClaudeLive turn messages21−1 (−50.0%)8✅

      Baseline: 42160f2 · PR result: 6c0a0a4 · Source CI: success

      Scenario 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.