fix(server): queued delegated completions keep a newer model choice #22579
main fromrefs/pull/22579/head·merged by maria-rcks View on GitHubProblem#
A delegated-task completion notice that waits in the queue reverts the thread's model when it starts. If the model changes while the notice waits, with the picker or t3_thread_configure, the notice's turn and the turns after it run on the old model. The expected behavior is that the notice starts on the thread's current model and leaves it unchanged.
Change#
ProviderContinuationService queues the notice with no modelSelection, so message.dispatch stores a copy of the thread's selection on the run. At start, queuedRunModelSelection returned that copy, and the start wrote it back to the thread. A queued delegated completion now starts on the thread's current selection and conversation. #21314 gave queued PR-watch updates the same rule. The change adds one condition to followsCurrentConversation and drops a comment that named only monitor updates.
Queued messages that a user sends carry the composer's selection and keep it, as #19376 intends.
The late-steer follow-up in EffectWorker passes its run's selection when it dispatches. If that follow-up waits in the queue, it now also starts on the thread's current selection. If it starts at once, it uses its run's selection as before. The two selections differ only when the model changed while the steered run was active.
Scope and approval#
Fixes #22577, which has the diagnosis and the reproduction steps and is awaiting triage. The change also qualifies as a small, focused fix for an obvious bug. A notice that the app created reverted a model that a user or an agent had chosen. The fix applies #21314's rule to one more kind of app-owned queued update. It changes no contract, client, provider adapter or user-message behavior.
Verification#
- On a 0.0.46 nightly, two queued completion runs on one thread each started in the same millisecond as a
thread.model-selection-updatedevent with no command. Each event restored the enqueue-time selection over at3_thread_configurechange from about a minute earlier. #22577 has the event log. - The new test in
runtimeLayer.test.ts, "starts a queued delegated completion on a selection set while it waited", queues a notice shaped likeProviderContinuationService's delivery. It then changes the thread's model, completes the active run and starts the queue. It has two cases, a model change on the same provider instance and a switch to another instance.- Against
main(4f651cb10), both cases fail. The run starts ongpt-5.4instead ofgpt-5.5, andthread.modelSelectionreverts togpt-5.4. - With the fix, both cases pass.
- Against
- To check the user-message boundary, I made every queued run follow the thread. 11 existing tests failed, including "keeps queued user selections and pauses only the limited provider".
vp test runpasses 177 of 177 tests in the 8 related files:runtimeLayer,DelegatedCompletionDelivery,SteeringCompletion.integration,ProviderContinuationService,QueuedRunOrder,testkit/ProviderSwitch.integration,ClaudeAutomaticDelivery.integrationandEffectWorker.- The server typecheck passes.
vp fmt --checkandvp lintpass on the changed files, apart from one existing warning on an untouched line. - I did not check a full app run with a live provider and a real
delegate_taskchild.
Created with Claude Opus 5.5 in Claude Code (T3 Code).
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XS
Note
Written by
gpt-6.1-solon behalf of MariaVerified in a real dev environment#
Verified as-is at
282206f98e4520a734c9f76eb8e82b19f71d755c. Reproduced first ongithub/mainat15fe283272in a separate worktree. Ran one dev server at a time, repository Playwright with/usr/bin/google-chrome, and real Codexgpt-6.1-solturns through this VM's local proxy. Created the project and threads through the web app against a real git repository. No mocks or seeded fixtures.The real delegated child finished while another parent turn was active. I requested the child through authenticated
orchestration.dispatchCommandwithcompletionWake=settled_onlyso its genuine completion notice queued rather than taking the active-steering path. While it waited, I changedmodelSelectionfrom high to low reasoning throughthread.model-selection.set. This keeps every provider turn on the requested model while exercising the selection overwrite.- Main: queued high at 20:10:49 UTC, changed to low at 20:10:58, then queued start at 20:11:50 restored high.
- PR: queued high at 20:16:39, changed to low at 20:16:49, started at 20:17:43 and completed at 20:17:46 on low. The thread stayed low. A second live run reproduced the passing result.
- Nearby behavior: the next user turn ran on low and recalled the earlier parent marker. A queued user message retained its explicit high selection after the thread changed to low, started on high, and returned
USER_SELECTION_HIGH. Active steering also delivered a real follow-up successfully. - Blacksmith: all 177 tests passed across the eight related orchestration files. No source changes or pushes were needed.
Main after the erroneous overwrite:

PR after the genuine queued completion finishes:

20-second recording of the queued notice starting and finishing while low remains selected:

Command and persisted-event transcript. The transcript includes queued, starting, and completed run selections from read-only database inspection.
Not verified#
Native iOS/Android and Electron clients, macOS/Windows, relay/tunnel connections, other providers, a different model ID, and a different provider instance were not exercised on this Linux VM. The live selection change used reasoning options on
gpt-6.1-sol; different-model and different-instance cases passed the existing focused regression tests.maria-rcks merged this5731c02
maria-rcks closed this
Sign in to join this conversation.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
566583c1-3e0b-4dd3-86e9-421f08e80ac4📥 Commits
Reviewing files that changed from the base of the PR and between 6a6c84f9906cbdfa7f533fecfc39ce18c2f4c273 and 282206f98e4520a734c9f76eb8e82b19f71d755c.
📒 Files selected for processing: 2
apps/server/src/orchestration-v2/Orchestrator.tsapps/server/src/orchestration-v2/runtimeLayer.test.tsIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
📝 Walkthrough
The orchestrator now treats delegated-completion messages as following the current conversation. A regression test verifies that a queued completion uses the model selection and provider instance configured while it waited.
Changes: Queued delegated-completion model selection
apps/server/src/orchestration-v2/Orchestrator.ts,apps/server/src/orchestration-v2/runtimeLayer.test.tsPriority: ➖ Normal
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Medium
Suggested reviewers:
voltcrashMerge Risk: ⚪ Minimal · up to
28220The queued-completion selection change appears ready to merge after normal checks; no merge-blocking issue was identified.
Architecture risk: 🔵 Low · up to
28220The change affects 1 system.
Changed systems:
apps/serverArchitecture concerns No architecture-level concerns identified.
Review details
Systems and components
Before / after behavior
followsCurrentConversationnow returns true for messages with a delegated completion, as well as non-buffered monitor notifications.queuedRunModelSelection; executable model-selection behavior was unchanged.Pre-merge checks:
4
#22577].followsCurrentConversationnow includes delegated-completion messages, so a queued completion uses the thread's current selection and con…#22577]. The evide…Full details: Linked Issues check
Explanation
The PR satisfies the active coding requirements in [
#22577].followsCurrentConversationnow includes delegated-completion messages, so a queued completion uses the thread's current selection and conversation instead of its enqueue-time copy. The addedruntimeLayer.test.tsregression test covers model changes within the same provider instance and across provider instances. The described behavior preserves queued user-message selections from contextual [#19376] and preserves immediate late-steer behavior.Full details: Out of Scope Changes check
Explanation
The reported changes are limited to the delegated-completion queue-selection condition, its related comment removal, and a focused regression test. These changes directly implement [
#22577]. The evidence shows no unrelated contract, client, provider-adapter, or user-message changes.✨ Finishing Touches
🧪 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.