ГЛОБАЛЬНЫЙ РЕФАКТОРИНГ АРХИТЕКТУРЫ - Рефакторинг этапов Stage 3.2 В оркестрации добавлено семантический арбитраж fallbackов (учет guard_hints и extraction) и followup-override для aggregate/unsupported кейсов. \ Убрано залипание в address_lane при carryover-контексте для кейса типа какие обороты ... за 2020, но сохранил защиту поддержанных интентов (list_open_contracts и т.п.), кроме strict deep-диагностики.

This commit is contained in:
2026-04-11 17:04:50 +03:00
parent a7ccc92a9c
commit c2fa360eb9
5 changed files with 332 additions and 16 deletions
+41 -8
View File
@@ -3429,13 +3429,35 @@ function resolveAssistantOrchestrationDecision(input) {
hasAddressFollowupContextSignal(effectiveAddressUserMessage) ||
hasAddressFollowupContextSignal(repairedRawUserMessage) ||
hasAddressFollowupContextSignal(repairedEffectiveAddressUserMessage));
const unsupportedIntentOrMode = modeDetection.mode !== "address_query" &&
(intentResolution.intent === "unknown" || llmContractMode === "unsupported");
const unsupportedAddressIntentFallbackToDeep = Boolean(!followupContext &&
baseToolGate?.runAddressLane &&
const supportedAddressIntentDetected = !strictDeepInvestigationCueDetected &&
Boolean((intentResolution.intent && ADDRESS_INTENTS_KEEP_ADDRESS_LANE.has(intentResolution.intent)) ||
(llmContractIntent && ADDRESS_INTENTS_KEEP_ADDRESS_LANE.has(llmContractIntent)));
const semanticGuardHints = semanticExtractionContract?.guard_hints &&
typeof semanticExtractionContract.guard_hints === "object"
? semanticExtractionContract.guard_hints
: null;
const semanticExtraction = semanticExtractionContract?.extraction &&
typeof semanticExtractionContract.extraction === "object"
? semanticExtractionContract.extraction
: null;
const semanticDeepInvestigationHintDetected = semanticGuardHints?.deep_investigation_signal_detected === true;
const semanticAggregateShapeDetected = semanticExtraction?.query_shape === "AGGREGATE_LOOKUP" ||
semanticExtraction?.aggregation_profile === "management_profile";
const followupSemanticOverrideToDeepAllowed = Boolean(followupContext &&
!supportedAddressIntentDetected &&
(llmContractMode === "unsupported" ||
semanticAggregateShapeDetected ||
semanticDeepInvestigationHintDetected ||
!semanticApplyCanonicalRecommended));
const unsupportedIntentOrMode = (modeDetection.mode !== "address_query" && intentResolution.intent === "unknown") ||
llmContractMode === "unsupported";
const unsupportedAddressIntentFallbackToDeep = Boolean(baseToolGate?.runAddressLane &&
unsupportedIntentOrMode &&
strongDataSignal &&
!preserveAddressLaneSignal);
!preserveAddressLaneSignal &&
!keepAddressLaneByIntent &&
!supportedAddressIntentDetected &&
(!followupContext || followupSemanticOverrideToDeepAllowed));
const deepAnalysisPreferenceDetected = Boolean(hasDeepAnalysisPreferenceSignal(rawUserMessage) ||
hasDeepAnalysisPreferenceSignal(repairedRawUserMessage) ||
hasDeepAnalysisPreferenceSignal(effectiveAddressUserMessage) ||
@@ -3448,14 +3470,19 @@ function resolveAssistantOrchestrationDecision(input) {
toNonEmptyString(followupContext.previous_intent) === "vat_payable_forecast" &&
/(?:\u043f\u043e\u0447\u0435\u043c\u0443|why).*(?:\u043f\u0440\u043e\u0433\u043d\u043e\u0437|forecast).*(?:\u0443\u043f\u043b\u0430\u0442|payable|\b0\b)/iu.test(compactWhitespace(`${repairedRawUserMessage} ${repairedEffectiveAddressUserMessage}`)));
const deepAnalysisSignalFallbackToDeep = Boolean(baseToolGate?.runAddressLane &&
deepAnalysisPreferenceDetected &&
(deepAnalysisPreferenceDetected || semanticDeepInvestigationHintDetected) &&
!keepAddressLaneByIntent &&
!supportedAddressIntentDetected &&
!vatExplainFollowupSignal &&
(!followupContext || !dataRetrievalSignal));
(!followupContext || !dataRetrievalSignal || followupSemanticOverrideToDeepAllowed));
const aggregateAnalyticsFallbackToDeep = Boolean(baseToolGate?.runAddressLane &&
aggregateBusinessAnalyticsSignal &&
!keepAddressLaneByIntent &&
!followupContext);
!supportedAddressIntentDetected &&
(!followupContext ||
llmContractMode === "unsupported" ||
semanticAggregateShapeDetected ||
!semanticApplyCanonicalRecommended));
const deepSessionContinuationFallbackToDeep = Boolean(!followupContext &&
baseToolGate?.runAddressLane &&
hasDeepSessionContinuationSignal({
@@ -3541,6 +3568,12 @@ function resolveAssistantOrchestrationDecision(input) {
semantic_contract_valid: semanticContractValid,
semantic_apply_canonical_recommended: semanticApplyCanonicalRecommended,
semantic_reason_codes: semanticReasonCodes,
semantic_route_arbitration: {
supported_address_intent_detected: supportedAddressIntentDetected,
semantic_deep_investigation_hint_detected: semanticDeepInvestigationHintDetected,
semantic_aggregate_shape_detected: semanticAggregateShapeDetected,
followup_semantic_override_to_deep_allowed: followupSemanticOverrideToDeepAllowed
},
followup_context_detected: Boolean(followupContext),
unsupported_address_intent_fallback_to_deep: unsupportedAddressIntentFallbackToDeep,
deep_analysis_signal_fallback_to_deep: deepAnalysisSignalFallbackToDeep,