fix(server): queued task completions keep the current model#23164

closed4
main
fix/issue-22577
opened11d agobyJJulius Marminge
View on GitHubTwo-way sync enabledPR last imported 2d ago

Problem

A delegated-task completion that queues behind another parent turn retains the model from queue time. If the thread's persisted model changes before the queue drains, delivery reverts that choice and starts the completion on the old model. Reproduced in the real Linux web dev app by delegating an async child, starting a second parent turn, and persisting Sonnet while the completion waited on Opus.

Change

Delegated completions follow the thread's current selection and provider conversation through the existing monitor-update queue policy. User-authored queued messages retain their chosen selection. Focused regression cases cover model changes, provider-instance routing, current-provider usage limits and disabled-instance holds.

Scope and approval

Fixes #22577 GitCafe: https://git.cafe/pingdotgg/t3code/issues/22577 Triaged bug via the automated issue flow: #22577, GitCafe mirror. One server queue-policy defect; no contract or client changes. Two isolated final reviewers returned MERGE; the final proof audit returned SUFFICIENT. This PR must not auto-land.

Verification

  • Red first: the original regression fails on 0df2b9c89d, with the thread reverting from gpt-5.5 to gpt-5.4. The four final cases fail against the base implementation for model rollback, wrong-instance routing, wrong-provider usage-limit checks and disabled-instance execution. Original raw failure, four-case raw failures.
  • Final merged head 6a8e8de1eb: vp test run for runtimeLayer, DelegatedCompletionDelivery, SteeringCompletion.integration, ClaudeAutomaticDelivery.integration, ProviderContinuationService, QueuedRunOrder, SelectionRestart.integration, ProviderSwitchService, ProjectionRecovery, RunCompletionReads, TurnStartReads and ThreadDeletion: 12 files, 175 tests passed. Output.
  • Server tsc-rs --noEmit passed on the final test revision before merging main. Targeted test lint passed; orchestrator lint reports only an existing unused layerUnavailable warning. Formatting and diff whitespace checks passed.
  • Evidence index and fixture matrix. Server-only exemption: visual matrix 0/0, no changed render paths; proof is red/green tests and real-runtime transcripts.
EvidenceBeforeAfter
Real app, Linux x64, collaborative Chrome 1280×800, isolated dev state; async child sleep 150s, second parent sleep 240s, persisted model change while completion queued70e5e384da: transcript; queue delivery writes Opus over Sonnetd1736d5221: transcript, correlated native-model proof; the same completion starts and completes on Sonnet, and the thread remains on Sonnet

The runtime-tested orchestrator is byte-identical at the final merged head; later changes add tests and merge upstream main. The picker alone changes the composer draft during an active turn, so the reproduction persisted the selection through the app's metadata command. Delivery timing remains unchanged. No render changes are claimed.

Not exercised: live cross-provider switching, native desktop/mobile, reconnects, or remote/relay/tunnel connections. Cross-instance routing and queue guards have deterministic server coverage; no platform-specific code changed. All reproduction servers were stopped.

Implementation and tests: Claude Opus 5.5 through Claude Code in T3 Code. Triage, runtime verification, evidence and proof: GPT-6.1-Sol through Codex in T3 Code; isolated reviews by GPT-6.1-Sol and Claude Opus 5.5.

Checks

21 successful · 16 skipped · 1 neutral
All checks passed
6a8e8de

Added 4 commits

  • test(server): queued delegated completion keeps the current thread selection0df2b9c
  • test(server): delegated completions route and hold on the current provider55ac62b
  • Merge main into fix/issue-225776a8e8de
  • fix(server): queued delegated completions follow the thread's current modeld1736d5
Synced from GitHub

Approvability

Verdict: Needs Human Approval

Macroscope's review found this PR requires human approval — This is a focused server bug fix that keeps queued delegated completions aligned with the thread’s current model and provider, with targeted coverage for routing and queue guards. The PR explicitly requests that it not auto-land, so manual review is appropriate.

You can add or adjust custom eligibility rules. Learn more.

Synced from GitHub

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

ProviderMetricMain baselineThis PRImpactPR ceiling
CodexTotal thread wire5.0 KiB5.0 KiB+7 B (+0.1%)6.8 KiB✅
CodexThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
CodexLive turn WebSocket wire1.2 KiB1.2 KiB+7 B (+0.6%)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 KiB0 B (0.0%)6.8 KiB✅
ClaudeThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
ClaudeLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
ClaudeLive turn WebSocket decoded21.2 KiB21.2 KiB0 B (0.0%)29.3 KiB✅
ClaudeLive turn messages220 (0.0%)8✅

Baseline: 89fe509 · PR result: 6a8e8de · 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.

Synced from GitHub

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: f16b1845-435c-4207-9eed-3742ab56fd93
📥 Commits

Reviewing files that changed from the base of the PR and between 89fe509232e787b51d0cf695861afe73316ce85b and 6a8e8de1eb474ae8d9c8542bbe3bd8e567eac1be.

📒 Files selected for processing: 2
  • apps/server/src/orchestration-v2/Orchestrator.ts
  • apps/server/src/orchestration-v2/runtimeLayer.test.ts

Limit details: You’ve used all 10 included reviews currently available.

📝 Walkthrough

Queued delegated completions now use the thread’s current model selection when they start. Runtime tests cover provider selection, usage-limit holds, and disabled provider instances.

Changes: Queued delegated completions

Layer / File(s)Summary
Selection rule and queued completion validation
apps/server/src/orchestration-v2/Orchestrator.ts, apps/server/src/orchestration-v2/runtimeLayer.test.ts
Delegated completions now follow the thread’s current model selection, as unbuffered monitor notifications do. Tests cover selected provider instances, provider-thread reuse when only the model changes, usage-limit holds, and disabled provider instances.

Priority: ➖ Normal

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

Change: Bug fix

Possibly related issues

  • pingdotgg/t3code#21705 — The changes relate to queued selection behavior, but the reported cross-account hold release remains separate.

Suggested reviewers: voltcrash

Merge Risk: ⚪ Minimal · up to 6a8e8

Queued delegated completions follow the thread’s current model selection, while the inspected hold checks remain aligned with that selection. No issue identified here needs resolution before merge.

Pre-merge checks: Passed 4
Check nameStatusExplanation
Title checkPassedThe title clearly and concisely describes the main server fix: queued task completions now keep the current model.
Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
Description checkPassedThe pull request description includes all required sections: Problem, Change, Scope and approval, and Verification. It explains the defect, the implementation, issue and approval references, focused r…
Full details: Description check

Explanation

The pull request description includes all required sections: Problem, Change, Scope and approval, and Verification. It explains the defect, the implementation, issue and approval references, focused regression coverage, test results, runtime evidence, limitations, and agent details.

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