fix(server): preserve active turns when switching provider instances #22755
Mergedjuliusmarmingemerged 0 commits into
main fromrefs/pull/22755/headmerged by juliusmarminge View on GitHubgithub-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
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:L
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
juliusmarminge added labelsvia-triage
juliusmarminge added labelsbugfix
juliusmarminge removed labelsvia-triage
- apps/server/src/orchestration-v2/Orchestrator.ts line 2964OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -2947,9 +2947,18 @@29472947 }),29482948 ),29492949 );2950- return yield* providerSwitchService2950+ const plan = yield* providerSwitchService29512951 .plan({29522952 projection: providerContext!,29532953 targetModelSelection: command.modelSelection,29542954 })29552955 .pipe(mapDispatchError(command));2956+ if (plan.instanceChanged || plan.releaseProviderSessionIds.length > 0) {2957+ const projection = yield* loadProjectionForCommand(command, ["runs"], {2958+ turnItemTypes: [],2959+ });2960+ if (projection.runs.some(isBlockingRun)) {2961+ return yield* new OrchestratorDispatchError({2962+ commandId: command.commandId,2963+ commandType: command.type,2964+ cause:
juliusmarminge added labelspr:gate-failed
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
- @@ -3792,8 +3802,20 @@37923802 ),37933803 );3794- return yield* providerSwitchService3804+ const plan = yield* providerSwitchService37953805 .plan({37963806 projection: providerContext!,37973807 targetModelSelection: command.modelSelection,37983808 })37993809 .pipe(mapDispatchError(command));3810+ if (plan.instanceChanged || plan.releaseProviderSessionIds.length > 0) {3811+ const projection = yield* loadProjectionForCommand(command, ["runs"], {3812+ turnItemTypes: [],3813+ });3814+ if (projection.runs.some(isActiveRun)) {3815+ return yield* new OrchestratorProviderSelectionBusyError({3816+ commandId: command.commandId,3817+ threadId: command.threadId,3818+ });3819+ }3820+ }3821+ return plan;
juliusmarminge merged this94f54a5
juliusmarminge closed this
Sign in to join this conversation.


Thread transfer impact#
✅ Thread transfer remains within every enforced ceiling.
Baseline:
31bf2f7· PR result:dd9772c· 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.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.