Архитектура: вынести address-vs-deep fallback arbitration в assistantRoutePolicy и уменьшить top-level decision pressure
This commit is contained in:
+77
-40
@@ -46,6 +46,49 @@ const ADDRESS_INTENTS_ALLOW_STRICT_DEEP_INVESTIGATION_BYPASS = new Set([
|
||||
function shouldBypassStrictDeepInvestigationCueForAddressIntent(intent) {
|
||||
return Boolean(intent && ADDRESS_INTENTS_ALLOW_STRICT_DEEP_INVESTIGATION_BYPASS.has(intent));
|
||||
}
|
||||
function resolveAddressFallbackToDeepArbitration(input) {
|
||||
const { baseToolGateRunAddressLane, llmRuntimeUnavailableDetected, unsupportedIntentOrMode, strongDataSignal, rootContextOnlyFollowup, llmContractMode, strictDeepInvestigationCueDetected, semanticDeepInvestigationHintDetected, aggregateBusinessAnalyticsSignal, preserveAddressLaneSignal, supportedAddressRouteCandidateDetected, followupContext, followupSemanticOverrideToDeepAllowed, deepAnalysisPreferenceDetected, protectAddressLaneFromFallback, dataRetrievalSignal, vatExplainFollowupSignal, semanticAggregateShapeDetected, semanticApplyCanonicalRecommended, standaloneAddressTopicSignal, hasDeepSessionContinuationSignalDetected } = input;
|
||||
const unsupportedAddressIntentFallbackToDeep = Boolean(baseToolGateRunAddressLane &&
|
||||
!llmRuntimeUnavailableDetected &&
|
||||
unsupportedIntentOrMode &&
|
||||
strongDataSignal &&
|
||||
(rootContextOnlyFollowup ||
|
||||
llmContractMode === "deep_analysis" ||
|
||||
!dataRetrievalSignal ||
|
||||
strictDeepInvestigationCueDetected ||
|
||||
semanticDeepInvestigationHintDetected ||
|
||||
aggregateBusinessAnalyticsSignal) &&
|
||||
!preserveAddressLaneSignal &&
|
||||
!supportedAddressRouteCandidateDetected &&
|
||||
(!followupContext || followupSemanticOverrideToDeepAllowed));
|
||||
const deepAnalysisSignalFallbackToDeep = Boolean(baseToolGateRunAddressLane &&
|
||||
!llmRuntimeUnavailableDetected &&
|
||||
(deepAnalysisPreferenceDetected || semanticDeepInvestigationHintDetected) &&
|
||||
!protectAddressLaneFromFallback &&
|
||||
!vatExplainFollowupSignal &&
|
||||
(!followupContext || !dataRetrievalSignal || followupSemanticOverrideToDeepAllowed));
|
||||
const aggregateAnalyticsFallbackToDeep = Boolean(baseToolGateRunAddressLane &&
|
||||
!llmRuntimeUnavailableDetected &&
|
||||
aggregateBusinessAnalyticsSignal &&
|
||||
!protectAddressLaneFromFallback &&
|
||||
(!followupContext ||
|
||||
llmContractMode === "unsupported" ||
|
||||
llmContractMode === null ||
|
||||
semanticAggregateShapeDetected ||
|
||||
!semanticApplyCanonicalRecommended ||
|
||||
standaloneAddressTopicSignal));
|
||||
const deepSessionContinuationFallbackToDeep = Boolean(!followupContext &&
|
||||
baseToolGateRunAddressLane &&
|
||||
!llmRuntimeUnavailableDetected &&
|
||||
!protectAddressLaneFromFallback &&
|
||||
hasDeepSessionContinuationSignalDetected);
|
||||
return {
|
||||
unsupportedAddressIntentFallbackToDeep,
|
||||
deepAnalysisSignalFallbackToDeep,
|
||||
aggregateAnalyticsFallbackToDeep,
|
||||
deepSessionContinuationFallbackToDeep
|
||||
};
|
||||
}
|
||||
function createAssistantRoutePolicy(deps) {
|
||||
const { repairAddressMojibake, findLastGroundedAddressAnswerDebug, findLastOrganizationClarificationAddressDebug, mergeKnownOrganizations, normalizeOrganizationScopeValue, resolveOrganizationSelectionFromMessage, resolveMetaSignalSet, resolveHardMetaMode, isMetaFollowupOverGroundedAnswer, isAnswerInspectionFollowupOverGroundedAnswer, hasDataRetrievalRequestSignal, hasOrganizationFactLookupSignal, hasOrganizationFactFollowupSignal, hasAggregateBusinessAnalyticsSignal, hasStandaloneAddressTopicSignal, hasOpenContractsAddressSignal, detectAddressQuestionMode, resolveAddressIntent, toNonEmptyString, hasStrictDeepInvestigationCue, hasStrongDataIntentSignal, hasAccountingSignal, hasDangerOrCoercionSignal, hasAddressFollowupContextSignal, hasShortDebtMirrorFollowupSignal, isInventorySelectedObjectIntent, hasShortInventoryObjectFollowupSignal, isGroundedInventoryContextDebug, resolveRouteMemorySignals, findLastAddressAssistantItem, resolveAddressToolGateDecision: resolveAddressToolGateDecisionOverride, hasAddressLlmPreDecomposeCandidate, hasSameDateAccountFollowupSignalForPredecompose, hasLooseAllTimeAddressLookupSignal, hasDeepAnalysisPreferenceSignal, hasDirectDeepAnalysisSignal, compactWhitespace, hasDeepSessionContinuationSignal, resolveLivingAssistantModeDecision, resolveProviderExecutionState } = deps;
|
||||
function resolveBaseAddressToolGateDecision(addressInputMessage, followupContext, llmPreDecomposeMeta = null, rawUserMessage = null) {
|
||||
@@ -778,19 +821,6 @@ function createAssistantRoutePolicy(deps) {
|
||||
(rootContextOnlyFollowup &&
|
||||
resolvedIntentResolution.intent === "unknown" &&
|
||||
(!llmContractIntent || llmContractIntent === "unknown"));
|
||||
const unsupportedAddressIntentFallbackToDeep = Boolean(baseToolGate?.runAddressLane &&
|
||||
!llmRuntimeUnavailableDetected &&
|
||||
unsupportedIntentOrMode &&
|
||||
strongDataSignal &&
|
||||
(rootContextOnlyFollowup ||
|
||||
llmContractMode === "deep_analysis" ||
|
||||
!dataRetrievalSignal ||
|
||||
strictDeepInvestigationCueDetected ||
|
||||
semanticDeepInvestigationHintDetected ||
|
||||
aggregateBusinessAnalyticsSignal) &&
|
||||
!preserveAddressLaneSignal &&
|
||||
!supportedAddressRouteCandidateDetected &&
|
||||
(!followupContext || followupSemanticOverrideToDeepAllowed));
|
||||
const deepAnalysisPreferenceDetected = Boolean(hasDeepAnalysisPreferenceSignal(rawUserMessage) ||
|
||||
hasDeepAnalysisPreferenceSignal(repairedRawUserMessage) ||
|
||||
hasDeepAnalysisPreferenceSignal(effectiveAddressUserMessage) ||
|
||||
@@ -818,33 +848,40 @@ function createAssistantRoutePolicy(deps) {
|
||||
const vatEvaluativeFollowupSignal = Boolean(followupContext &&
|
||||
toNonEmptyString(followupContext.previous_intent) === "vat_payable_forecast" &&
|
||||
/(?:^|\s)(?:это\s+)?много\s+или\s+мало(?:\?|$)|(?:^|\s)(?:это\s+)?нормально(?:\?|$)|(?:^|\s)(?:это\s+)?плохо(?:\?|$)|(?:^|\s)(?:это\s+)?хорошо(?:\?|$)/iu.test(compactWhitespace(`${repairedRawUserMessage} ${repairedEffectiveAddressUserMessage}`)));
|
||||
const deepAnalysisSignalFallbackToDeep = Boolean(baseToolGate?.runAddressLane &&
|
||||
!llmRuntimeUnavailableDetected &&
|
||||
(deepAnalysisPreferenceDetected || semanticDeepInvestigationHintDetected) &&
|
||||
!protectAddressLaneFromFallback &&
|
||||
!vatExplainFollowupSignal &&
|
||||
(!followupContext || !dataRetrievalSignal || followupSemanticOverrideToDeepAllowed));
|
||||
const aggregateAnalyticsFallbackToDeep = Boolean(baseToolGate?.runAddressLane &&
|
||||
!llmRuntimeUnavailableDetected &&
|
||||
aggregateBusinessAnalyticsSignal &&
|
||||
!protectAddressLaneFromFallback &&
|
||||
(!followupContext ||
|
||||
llmContractMode === "unsupported" ||
|
||||
llmContractMode === null ||
|
||||
semanticAggregateShapeDetected ||
|
||||
!semanticApplyCanonicalRecommended ||
|
||||
standaloneAddressTopicSignal));
|
||||
const deepSessionContinuationFallbackToDeep = Boolean(!followupContext &&
|
||||
baseToolGate?.runAddressLane &&
|
||||
!llmRuntimeUnavailableDetected &&
|
||||
!protectAddressLaneFromFallback &&
|
||||
hasDeepSessionContinuationSignal({
|
||||
rawUserMessage,
|
||||
repairedRawUserMessage,
|
||||
effectiveAddressUserMessage,
|
||||
repairedEffectiveAddressUserMessage,
|
||||
sessionItems
|
||||
}));
|
||||
const hasDeepSessionContinuationSignalDetected = hasDeepSessionContinuationSignal({
|
||||
rawUserMessage,
|
||||
repairedRawUserMessage,
|
||||
effectiveAddressUserMessage,
|
||||
repairedEffectiveAddressUserMessage,
|
||||
sessionItems
|
||||
});
|
||||
const finalizedDeepFallbackArbitration = resolveAddressFallbackToDeepArbitration({
|
||||
baseToolGateRunAddressLane: Boolean(baseToolGate?.runAddressLane),
|
||||
llmRuntimeUnavailableDetected,
|
||||
unsupportedIntentOrMode,
|
||||
strongDataSignal,
|
||||
rootContextOnlyFollowup,
|
||||
llmContractMode,
|
||||
strictDeepInvestigationCueDetected,
|
||||
semanticDeepInvestigationHintDetected,
|
||||
aggregateBusinessAnalyticsSignal,
|
||||
preserveAddressLaneSignal,
|
||||
supportedAddressRouteCandidateDetected,
|
||||
followupContext,
|
||||
followupSemanticOverrideToDeepAllowed,
|
||||
deepAnalysisPreferenceDetected,
|
||||
protectAddressLaneFromFallback,
|
||||
dataRetrievalSignal,
|
||||
vatExplainFollowupSignal,
|
||||
semanticAggregateShapeDetected,
|
||||
semanticApplyCanonicalRecommended,
|
||||
standaloneAddressTopicSignal,
|
||||
hasDeepSessionContinuationSignalDetected
|
||||
});
|
||||
const unsupportedAddressIntentFallbackToDeep = finalizedDeepFallbackArbitration.unsupportedAddressIntentFallbackToDeep;
|
||||
const deepAnalysisSignalFallbackToDeep = finalizedDeepFallbackArbitration.deepAnalysisSignalFallbackToDeep;
|
||||
const aggregateAnalyticsFallbackToDeep = finalizedDeepFallbackArbitration.aggregateAnalyticsFallbackToDeep;
|
||||
const deepSessionContinuationFallbackToDeep = finalizedDeepFallbackArbitration.deepSessionContinuationFallbackToDeep;
|
||||
const hasPriorAddressAnswerContext = Boolean(lastGroundedAddressDebug ||
|
||||
continuitySnapshot.hasGroundedAddressContext ||
|
||||
toNonEmptyString(followupContext?.previous_intent));
|
||||
|
||||
Reference in New Issue
Block a user