Feat/mid thread provider switching #9392
ClosedBandaySajid(GitHub profile, opens in a new tab)wants to merge 7 commits into
main fromrefs/pull/9392/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- apps/server/src/orchestration/Layers/ProviderCommandReactor.ts line 630OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -599,4 +615,16 @@599615 });600616 }601617 const preferredProvider: ProviderDriverKind = desiredDriverKind;602- if (options?.pendingTurnStart === true && thread.session?.status !== "running") {618+619+ const isDriverChanged = currentInfo.driverKind !== desiredInfo.driverKind;620+ const isContinuationIncompatible =621+ currentInfo.continuationIdentity.continuationKey !==622+ desiredInfo.continuationIdentity.continuationKey;623+ const isHandoffSwitch =624+ (thread.session !== null || thread.messages.length > 0) &&625+ requestedModelSelection !== undefined &&626+ requestedModelSelection.instanceId !== currentInstanceId &&627+ (isDriverChanged || isContinuationIncompatible);628+629+ if (isHandoffSwitch) {630+ threadContinuityPending.add(threadId);
- apps/server/src/orchestration/Layers/ProviderCommandReactor.ts line 1016Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -807,0 +980,21 @@980+ });981+ const currentRequestChars = normalizedInput982+ ? CURRENT_REQUEST_PREFIX.length + normalizedInput.length983+ : 0;984+ const continuityContext = formatThreadContinuityContext({985+ messages: priorMessages,986+ maxChars: PROVIDER_SEND_TURN_MAX_INPUT_CHARS - currentRequestChars,987+ });988+ if (continuityContext.length > 0) {989+ continuityContextIncluded = true;990+ threadContinuityPending.delete(input.threadId);991+ effectiveInput = normalizedInput992+ ? `${continuityContext}${CURRENT_REQUEST_PREFIX}${normalizedInput}`993+ : continuityContext;994+ effectiveAttachments = [995+ ...collectThreadContinuityAttachments(priorMessages, normalizedAttachments),996+ ...normalizedAttachments,997+ ];998+ } else {999+ threadContinuityPending.delete(input.threadId);1000+ }
- apps/server/src/orchestration/Layers/ProviderCommandReactor.ts line 1005Resolvedby BandaySajid(GitHub profile, opens in a new tab)@@ -807,0 +985,21 @@985+ needsContinuityContext ? "thread-model-handoff" : "thread-model-selection",986+ ),987+ threadId: input.threadId,988+ modelSelection: input.modelSelection,989+ });990+ }991+ let effectiveInput = normalizedInput;992+ let effectiveAttachments = normalizedAttachments;993+ let continuityContextIncluded = false;994+ if (needsContinuityContext) {995+ const priorMessages = priorConversationMessages({996+ messages: thread.messages,997+ currentMessageId: input.messageId,998+ currentMessageText: input.messageText,999+ });1000+ const currentRequestChars = normalizedInput1001+ ? CURRENT_REQUEST_PREFIX.length + normalizedInput.length1002+ : 0;1003+ const continuityContext = formatThreadContinuityContext({1004+ messages: priorMessages,1005+ maxChars: PROVIDER_SEND_TURN_MAX_INPUT_CHARS - currentRequestChars,
juliusmarminge closed this
Sign in to join this conversation.


macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed