Архитектура: вынести address-vs-deep fallback arbitration в assistantRoutePolicy и уменьшить top-level decision pressure
This commit is contained in:
parent
ac3757bc59
commit
f3099a2c4b
|
|
@ -477,6 +477,15 @@ Still open after the accepted phase12 replay:
|
||||||
- this matters because the top-level `run address lane vs keep chat` gate is now structurally closer to the same route-policy owner that already arbitrates memory/meta/follow-up/deep transitions, instead of remaining split across `assistantService` glue and route policy heuristics;
|
- this matters because the top-level `run address lane vs keep chat` gate is now structurally closer to the same route-policy owner that already arbitrates memory/meta/follow-up/deep transitions, instead of remaining split across `assistantService` glue and route policy heuristics;
|
||||||
- the route policy still accepts an override in tests, so regression coverage remains narrow and controllable, but the production runtime no longer depends on a duplicate service-local decision block;
|
- the route policy still accepts an override in tests, so regression coverage remains narrow and controllable, but the production runtime no longer depends on a duplicate service-local decision block;
|
||||||
- targeted `assistantRoutePolicy`, `assistantContinuityPolicy`, and `assistantTransitionPolicy` suites are green after the move, and a fresh live rerun of `address_truth_harness_phase12_wider_saved_session_pool` on `2026-04-19` remains accepted `20/20`, which is the proof that the flagship mixed path survives after lifting the gate out of `assistantService`.
|
- targeted `assistantRoutePolicy`, `assistantContinuityPolicy`, and `assistantTransitionPolicy` suites are green after the move, and a fresh live rerun of `address_truth_harness_phase12_wider_saved_session_pool` on `2026-04-19` remains accepted `20/20`, which is the proof that the flagship mixed path survives after lifting the gate out of `assistantService`.
|
||||||
|
- the next route-arbitration pass now extracts one more dense decision tower from the top-level orchestration hot path:
|
||||||
|
- `assistantRoutePolicy` now owns `resolveAddressFallbackToDeepArbitration(...)`, so the four critical fallback verdicts are produced by one explicit helper instead of being recalculated as a scattered inline boolean block:
|
||||||
|
- `unsupported_address_intent_fallback_to_deep`
|
||||||
|
- `deep_analysis_signal_fallback_to_deep`
|
||||||
|
- `aggregate_analytics_signal_fallback_to_deep`
|
||||||
|
- `deep_session_continuation_fallback_to_deep`
|
||||||
|
- this matters because `address vs deep` arbitration is one of the last heavy control-plane seams in the project: it decides whether the assistant stays in exact-data mode or escalates into deep-analysis mode, and leaving that logic as a long inline branch makes future domain expansion much more likely to reintroduce contradictory fallback rules;
|
||||||
|
- the move does not change the route owner, but it makes the owner explicit and testable as one decision unit inside route policy rather than a fragile chain of local booleans;
|
||||||
|
- targeted route/continuity/transition suites remain green after the move, and a fresh live rerun of `address_truth_harness_phase12_wider_saved_session_pool` on `2026-04-19` remains accepted `20/20`, which is the proof that the flagship mixed contour survives the extraction of the deep fallback arbitration seam.
|
||||||
|
|
||||||
## Next Execution Slice (2026-04-18)
|
## Next Execution Slice (2026-04-18)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,49 @@ const ADDRESS_INTENTS_ALLOW_STRICT_DEEP_INVESTIGATION_BYPASS = new Set([
|
||||||
function shouldBypassStrictDeepInvestigationCueForAddressIntent(intent) {
|
function shouldBypassStrictDeepInvestigationCueForAddressIntent(intent) {
|
||||||
return Boolean(intent && ADDRESS_INTENTS_ALLOW_STRICT_DEEP_INVESTIGATION_BYPASS.has(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) {
|
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;
|
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) {
|
function resolveBaseAddressToolGateDecision(addressInputMessage, followupContext, llmPreDecomposeMeta = null, rawUserMessage = null) {
|
||||||
|
|
@ -778,19 +821,6 @@ function createAssistantRoutePolicy(deps) {
|
||||||
(rootContextOnlyFollowup &&
|
(rootContextOnlyFollowup &&
|
||||||
resolvedIntentResolution.intent === "unknown" &&
|
resolvedIntentResolution.intent === "unknown" &&
|
||||||
(!llmContractIntent || llmContractIntent === "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) ||
|
const deepAnalysisPreferenceDetected = Boolean(hasDeepAnalysisPreferenceSignal(rawUserMessage) ||
|
||||||
hasDeepAnalysisPreferenceSignal(repairedRawUserMessage) ||
|
hasDeepAnalysisPreferenceSignal(repairedRawUserMessage) ||
|
||||||
hasDeepAnalysisPreferenceSignal(effectiveAddressUserMessage) ||
|
hasDeepAnalysisPreferenceSignal(effectiveAddressUserMessage) ||
|
||||||
|
|
@ -818,33 +848,40 @@ function createAssistantRoutePolicy(deps) {
|
||||||
const vatEvaluativeFollowupSignal = Boolean(followupContext &&
|
const vatEvaluativeFollowupSignal = Boolean(followupContext &&
|
||||||
toNonEmptyString(followupContext.previous_intent) === "vat_payable_forecast" &&
|
toNonEmptyString(followupContext.previous_intent) === "vat_payable_forecast" &&
|
||||||
/(?:^|\s)(?:это\s+)?много\s+или\s+мало(?:\?|$)|(?:^|\s)(?:это\s+)?нормально(?:\?|$)|(?:^|\s)(?:это\s+)?плохо(?:\?|$)|(?:^|\s)(?:это\s+)?хорошо(?:\?|$)/iu.test(compactWhitespace(`${repairedRawUserMessage} ${repairedEffectiveAddressUserMessage}`)));
|
/(?:^|\s)(?:это\s+)?много\s+или\s+мало(?:\?|$)|(?:^|\s)(?:это\s+)?нормально(?:\?|$)|(?:^|\s)(?:это\s+)?плохо(?:\?|$)|(?:^|\s)(?:это\s+)?хорошо(?:\?|$)/iu.test(compactWhitespace(`${repairedRawUserMessage} ${repairedEffectiveAddressUserMessage}`)));
|
||||||
const deepAnalysisSignalFallbackToDeep = Boolean(baseToolGate?.runAddressLane &&
|
const hasDeepSessionContinuationSignalDetected = hasDeepSessionContinuationSignal({
|
||||||
!llmRuntimeUnavailableDetected &&
|
rawUserMessage,
|
||||||
(deepAnalysisPreferenceDetected || semanticDeepInvestigationHintDetected) &&
|
repairedRawUserMessage,
|
||||||
!protectAddressLaneFromFallback &&
|
effectiveAddressUserMessage,
|
||||||
!vatExplainFollowupSignal &&
|
repairedEffectiveAddressUserMessage,
|
||||||
(!followupContext || !dataRetrievalSignal || followupSemanticOverrideToDeepAllowed));
|
sessionItems
|
||||||
const aggregateAnalyticsFallbackToDeep = Boolean(baseToolGate?.runAddressLane &&
|
});
|
||||||
!llmRuntimeUnavailableDetected &&
|
const finalizedDeepFallbackArbitration = resolveAddressFallbackToDeepArbitration({
|
||||||
aggregateBusinessAnalyticsSignal &&
|
baseToolGateRunAddressLane: Boolean(baseToolGate?.runAddressLane),
|
||||||
!protectAddressLaneFromFallback &&
|
llmRuntimeUnavailableDetected,
|
||||||
(!followupContext ||
|
unsupportedIntentOrMode,
|
||||||
llmContractMode === "unsupported" ||
|
strongDataSignal,
|
||||||
llmContractMode === null ||
|
rootContextOnlyFollowup,
|
||||||
semanticAggregateShapeDetected ||
|
llmContractMode,
|
||||||
!semanticApplyCanonicalRecommended ||
|
strictDeepInvestigationCueDetected,
|
||||||
standaloneAddressTopicSignal));
|
semanticDeepInvestigationHintDetected,
|
||||||
const deepSessionContinuationFallbackToDeep = Boolean(!followupContext &&
|
aggregateBusinessAnalyticsSignal,
|
||||||
baseToolGate?.runAddressLane &&
|
preserveAddressLaneSignal,
|
||||||
!llmRuntimeUnavailableDetected &&
|
supportedAddressRouteCandidateDetected,
|
||||||
!protectAddressLaneFromFallback &&
|
followupContext,
|
||||||
hasDeepSessionContinuationSignal({
|
followupSemanticOverrideToDeepAllowed,
|
||||||
rawUserMessage,
|
deepAnalysisPreferenceDetected,
|
||||||
repairedRawUserMessage,
|
protectAddressLaneFromFallback,
|
||||||
effectiveAddressUserMessage,
|
dataRetrievalSignal,
|
||||||
repairedEffectiveAddressUserMessage,
|
vatExplainFollowupSignal,
|
||||||
sessionItems
|
semanticAggregateShapeDetected,
|
||||||
}));
|
semanticApplyCanonicalRecommended,
|
||||||
|
standaloneAddressTopicSignal,
|
||||||
|
hasDeepSessionContinuationSignalDetected
|
||||||
|
});
|
||||||
|
const unsupportedAddressIntentFallbackToDeep = finalizedDeepFallbackArbitration.unsupportedAddressIntentFallbackToDeep;
|
||||||
|
const deepAnalysisSignalFallbackToDeep = finalizedDeepFallbackArbitration.deepAnalysisSignalFallbackToDeep;
|
||||||
|
const aggregateAnalyticsFallbackToDeep = finalizedDeepFallbackArbitration.aggregateAnalyticsFallbackToDeep;
|
||||||
|
const deepSessionContinuationFallbackToDeep = finalizedDeepFallbackArbitration.deepSessionContinuationFallbackToDeep;
|
||||||
const hasPriorAddressAnswerContext = Boolean(lastGroundedAddressDebug ||
|
const hasPriorAddressAnswerContext = Boolean(lastGroundedAddressDebug ||
|
||||||
continuitySnapshot.hasGroundedAddressContext ||
|
continuitySnapshot.hasGroundedAddressContext ||
|
||||||
toNonEmptyString(followupContext?.previous_intent));
|
toNonEmptyString(followupContext?.previous_intent));
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,72 @@ const ADDRESS_INTENTS_ALLOW_STRICT_DEEP_INVESTIGATION_BYPASS = new Set([
|
||||||
function shouldBypassStrictDeepInvestigationCueForAddressIntent(intent) {
|
function shouldBypassStrictDeepInvestigationCueForAddressIntent(intent) {
|
||||||
return Boolean(intent && ADDRESS_INTENTS_ALLOW_STRICT_DEEP_INVESTIGATION_BYPASS.has(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
|
||||||
|
};
|
||||||
|
}
|
||||||
export function createAssistantRoutePolicy(deps) {
|
export function createAssistantRoutePolicy(deps) {
|
||||||
const {
|
const {
|
||||||
repairAddressMojibake,
|
repairAddressMojibake,
|
||||||
|
|
@ -819,19 +885,6 @@ export function createAssistantRoutePolicy(deps) {
|
||||||
(rootContextOnlyFollowup &&
|
(rootContextOnlyFollowup &&
|
||||||
resolvedIntentResolution.intent === "unknown" &&
|
resolvedIntentResolution.intent === "unknown" &&
|
||||||
(!llmContractIntent || llmContractIntent === "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) ||
|
const deepAnalysisPreferenceDetected = Boolean(hasDeepAnalysisPreferenceSignal(rawUserMessage) ||
|
||||||
hasDeepAnalysisPreferenceSignal(repairedRawUserMessage) ||
|
hasDeepAnalysisPreferenceSignal(repairedRawUserMessage) ||
|
||||||
hasDeepAnalysisPreferenceSignal(effectiveAddressUserMessage) ||
|
hasDeepAnalysisPreferenceSignal(effectiveAddressUserMessage) ||
|
||||||
|
|
@ -859,33 +912,40 @@ export function createAssistantRoutePolicy(deps) {
|
||||||
const vatEvaluativeFollowupSignal = Boolean(followupContext &&
|
const vatEvaluativeFollowupSignal = Boolean(followupContext &&
|
||||||
toNonEmptyString(followupContext.previous_intent) === "vat_payable_forecast" &&
|
toNonEmptyString(followupContext.previous_intent) === "vat_payable_forecast" &&
|
||||||
/(?:^|\s)(?:это\s+)?много\s+или\s+мало(?:\?|$)|(?:^|\s)(?:это\s+)?нормально(?:\?|$)|(?:^|\s)(?:это\s+)?плохо(?:\?|$)|(?:^|\s)(?:это\s+)?хорошо(?:\?|$)/iu.test(compactWhitespace(`${repairedRawUserMessage} ${repairedEffectiveAddressUserMessage}`)));
|
/(?:^|\s)(?:это\s+)?много\s+или\s+мало(?:\?|$)|(?:^|\s)(?:это\s+)?нормально(?:\?|$)|(?:^|\s)(?:это\s+)?плохо(?:\?|$)|(?:^|\s)(?:это\s+)?хорошо(?:\?|$)/iu.test(compactWhitespace(`${repairedRawUserMessage} ${repairedEffectiveAddressUserMessage}`)));
|
||||||
const deepAnalysisSignalFallbackToDeep = Boolean(baseToolGate?.runAddressLane &&
|
const hasDeepSessionContinuationSignalDetected = hasDeepSessionContinuationSignal({
|
||||||
!llmRuntimeUnavailableDetected &&
|
rawUserMessage,
|
||||||
(deepAnalysisPreferenceDetected || semanticDeepInvestigationHintDetected) &&
|
repairedRawUserMessage,
|
||||||
!protectAddressLaneFromFallback &&
|
effectiveAddressUserMessage,
|
||||||
!vatExplainFollowupSignal &&
|
repairedEffectiveAddressUserMessage,
|
||||||
(!followupContext || !dataRetrievalSignal || followupSemanticOverrideToDeepAllowed));
|
sessionItems
|
||||||
const aggregateAnalyticsFallbackToDeep = Boolean(baseToolGate?.runAddressLane &&
|
});
|
||||||
!llmRuntimeUnavailableDetected &&
|
const finalizedDeepFallbackArbitration = resolveAddressFallbackToDeepArbitration({
|
||||||
aggregateBusinessAnalyticsSignal &&
|
baseToolGateRunAddressLane: Boolean(baseToolGate?.runAddressLane),
|
||||||
!protectAddressLaneFromFallback &&
|
llmRuntimeUnavailableDetected,
|
||||||
(!followupContext ||
|
unsupportedIntentOrMode,
|
||||||
llmContractMode === "unsupported" ||
|
strongDataSignal,
|
||||||
llmContractMode === null ||
|
rootContextOnlyFollowup,
|
||||||
semanticAggregateShapeDetected ||
|
llmContractMode,
|
||||||
!semanticApplyCanonicalRecommended ||
|
strictDeepInvestigationCueDetected,
|
||||||
standaloneAddressTopicSignal));
|
semanticDeepInvestigationHintDetected,
|
||||||
const deepSessionContinuationFallbackToDeep = Boolean(!followupContext &&
|
aggregateBusinessAnalyticsSignal,
|
||||||
baseToolGate?.runAddressLane &&
|
preserveAddressLaneSignal,
|
||||||
!llmRuntimeUnavailableDetected &&
|
supportedAddressRouteCandidateDetected,
|
||||||
!protectAddressLaneFromFallback &&
|
followupContext,
|
||||||
hasDeepSessionContinuationSignal({
|
followupSemanticOverrideToDeepAllowed,
|
||||||
rawUserMessage,
|
deepAnalysisPreferenceDetected,
|
||||||
repairedRawUserMessage,
|
protectAddressLaneFromFallback,
|
||||||
effectiveAddressUserMessage,
|
dataRetrievalSignal,
|
||||||
repairedEffectiveAddressUserMessage,
|
vatExplainFollowupSignal,
|
||||||
sessionItems
|
semanticAggregateShapeDetected,
|
||||||
}));
|
semanticApplyCanonicalRecommended,
|
||||||
|
standaloneAddressTopicSignal,
|
||||||
|
hasDeepSessionContinuationSignalDetected
|
||||||
|
});
|
||||||
|
const unsupportedAddressIntentFallbackToDeep = finalizedDeepFallbackArbitration.unsupportedAddressIntentFallbackToDeep;
|
||||||
|
const deepAnalysisSignalFallbackToDeep = finalizedDeepFallbackArbitration.deepAnalysisSignalFallbackToDeep;
|
||||||
|
const aggregateAnalyticsFallbackToDeep = finalizedDeepFallbackArbitration.aggregateAnalyticsFallbackToDeep;
|
||||||
|
const deepSessionContinuationFallbackToDeep = finalizedDeepFallbackArbitration.deepSessionContinuationFallbackToDeep;
|
||||||
const hasPriorAddressAnswerContext = Boolean(lastGroundedAddressDebug ||
|
const hasPriorAddressAnswerContext = Boolean(lastGroundedAddressDebug ||
|
||||||
continuitySnapshot.hasGroundedAddressContext ||
|
continuitySnapshot.hasGroundedAddressContext ||
|
||||||
toNonEmptyString(followupContext?.previous_intent));
|
toNonEmptyString(followupContext?.previous_intent));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue