Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): auto-delivered messages queue between provider turns #15691

MergedGigioxx(GitHub profile, opens in a new tab)merged 6 commits intomain fromrefs/pull/15691/headmerged by maria-rcks View on GitHub

Automatic messages could be rejected while a run was active but its current attempt had no running provider turn. Queue those messages during startup and completion gaps, so they are retained for the next turn. Explicit steering and restart behavior stays the same.

The server policy checks the active attempt, including when a different attempt still has a running turn. This applies to all clients and providers using automatic delivery; no client or wire changes are needed.

Credit: @Gigioxx's original fix in #15691. Maintainer takeover preserves the original commit and merges main without rewriting the contributor's history. The previous takeover's single-use helper was inlined and its comment shortened; the regression cases share one table.

Fixes #15600.

Verification on head 8c2a54f69c:

  • ./node_modules/.bin/vp test run apps/server/src/orchestration-v2/CommandPolicy.test.ts apps/server/src/orchestration-v2/runtimeLayer.test.ts: 110 passed (24 policy, 86 runtime), up from 109 before the final test pass. Temporarily removing the production guard makes all four gap cases fail: absent, pending, completed, and a running turn from a previous attempt. Restoring it makes them pass. Each gap also checks that explicit steering/restart keep their existing intent.
  • Server typecheck (tsc-rs --noEmit -p apps/server/tsconfig.json), targeted lint, formatting and git diff --check passed.
  • Independent whole-PR adversarial review round 1 (Claude Opus 5.5 and GPT-6 Sol): no introduced code findings. GPT-6 Sol correctly kept publication/current-head CI as remaining gates.

Screenshots are not applicable to this server dispatch decision. No interactive client or live provider race was exercised; policy and real runtime-layer tests are the proof. The collaborative browser could not start because this Linux host lacks required browser libraries. macOS, Windows, iOS, Android, and Electron desktop were not verified here.

Implementation: GPT-6.1 Sol and tests: GPT-6 Astra (high), via the Codex harness in T3 Code. Independent reviews: Claude Opus 5.5 and GPT-6 Sol. The resumed prior implementation commit used Claude Fable 5.1.

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

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

      Approvability

      Verdict: Approved at 8c2a54f

      Macroscope's review found this PR approvable — This is a focused server bug fix that changes automatic message dispatch only when an active attempt is between provider turns, preserving explicit steering/restart behavior. The added regression coverage accounts for the relevant lifecycle gaps, with no schema, deployment, default, security, or static-analysis changes.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    3. 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: Repository: pingdotgg/t3code/.coderabbit.yaml
      • Review profile: CHILL
      • Plan: Advanced
      • Run ID: a5d0f455-db3b-4575-965a-ec8def8f1f52
      📥 Commits

      Reviewing files that changed from the base of the PR and between 4ee6bfd50ef4a089440d5c3662db2298da9cc50e and 6f9181fa0d45d580c19df6fffb02e4500c0ac709.

      📒 Files selected for processing (2)
      • apps/server/src/orchestration-v2/CommandPolicy.test.ts
      • apps/server/src/orchestration-v2/CommandPolicy.ts

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

      📝 Walkthrough

      Automatic message dispatch now queues messages when the active run has no running provider turn for its active attempt. Tests cover pending and completed turns, and the absence of provider turns.

      Changes: Automatic dispatch

      Layer / File(s)Summary
      Queue dispatch when no provider turn is running
      apps/server/src/orchestration-v2/CommandPolicy.ts, apps/server/src/orchestration-v2/CommandPolicy.test.ts
      Automatic delivery selects queue_after_active when the run is preparing or starting, or when no running provider turn matches its active attempt. Tests cover pending, completed, and absent provider turns.

      Priority: ⬇️ Low

      Estimated code review effort: 2 (Simple) | ~10 minutes

      Change: Bug fix · Severity of issue fixed: Low

      Suggested reviewers: juliusmarminge

      Merge Risk: ⚪ Minimal · up to 6f918

      Automatic messages sent between provider turns can queue behind the active run. No merge-blocking issue was identified.

      Security architecture risk: 🔵 Low · up to 6f918

      The change reuses existing message queuing without adding an entrypoint or granting new privileges. Risk is limited to message lifecycle behavior. Source checks support the existing safeguards, but real-client races and provider-specific recovery remain unverified.

      Retained concerns No architecture-level concerns identified.

      Security review details

      Security Blast Radius

      • inferred — The demonstrated change affects scheduling and persisted queued state within the command's thread. The inspected delta adds no production entrypoint, credential authority, or cross-service sink; broader authentication and deployment boundaries were not audited in this pass.

      Trust Boundaries and Controls

      • observed — The queue path retains provider capability enforcement, requires an applicable provider thread, and rejects pending merge-back transfers. Dispatch receipt replay also checks thread identity, rejecting reuse of an accepted command ID against a different thread.

      Resilience and Maintainability Implications

      • observed — Dispatch planning is serialized by thread. Accepted commands submit events and effects through commitCommand, and existing receipts provide same-command replay behavior. This does not establish messageId uniqueness across different command IDs.
      Pre-merge checks: Passed 4 · Failed 1
      Failed Failed checks: 1 warning
      Check nameStatusExplanationResolution
      Docstring CoverageWarningDocstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files.Write docstrings for the functions missing them to satisfy the coverage threshold.
      Passed Passed checks: 4 passed
      Check nameStatusExplanation
      Linked Issues checkPassed[#15600] requires auto dispatch to avoid steering when the active run has no running provider turn. CommandPolicy.ts now returns queue_after_active unless a running turn matches `activeRun.activ…
      Out of Scope Changes checkPassedAll changes are limited to automatic dispatch policy and focused policy tests for [#15600]. No unrelated changes appear in the pull request diff.
      Title checkPassedThe title clearly and concisely describes the main change: automatic messages now queue between provider turns.
      Description checkPassedThe description covers the problem, implementation, scope, linked issue, verification results, limitations, and agent details. It provides specific test commands and observed outcomes.
      Full details: Linked Issues check

      Explanation

      [#15600] requires auto dispatch to avoid steering when the active run has no running provider turn. CommandPolicy.ts now returns queue_after_active unless a running turn matches activeRun.activeAttemptId. Tests cover pending, completed, and absent turns; the existing running-turn case still steers. The explicit steer and restart branches are unchanged.

      • Fix all pre-merge checks with AI
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create a new PR
      • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
      Comment `@coderabbitai help` to get the list of available commands.
    4. juliusmarminge added labelsmacroscope-review

    5. juliusmarminge assignedjuliusmarminge

    6. Taking over this one. I'll rebuild on top of your branch, bring in main, and push here.

    7. maria-rcks merged thisb6295dd

    8. maria-rcks closed this

Sign in to join this conversation.