Укрепить семантическую арбитрацию follow-up после жирного прогона

This commit is contained in:
2026-05-08 21:57:41 +03:00
parent ba23b056b8
commit a15cbb3fcb
18 changed files with 898 additions and 37 deletions
@@ -522,6 +522,9 @@ function shouldRestoreInventoryRootFrame(userMessage, intent, extractedFilters,
return hasTemporalPatch;
}
function hasSelectedObjectInventorySignal(text) {
if (/(?:по\s+выбранному\s+объекту|по\s+этой\s+позиции|по\s+этому\s+товару|по\s+ней|по\s+нему|по\s+ним|for\s+selected\s+object|selected\s+object)/iu.test(String(text ?? ""))) {
return true;
}
return /(?:по\s+выбранному\s+объекту|по\s+этой\s+позиции|по\s+этому\s+товару|по\s+ней|по\s+нему|по\s+ним|for\s+selected\s+object|selected\s+object)/iu.test(String(text ?? ""));
}
function hasSelectedObjectInlineSnapshotMetadata(text) {
@@ -590,6 +593,12 @@ function hasAddressFollowupContextSignal(text) {
if (/(?:по\s+выбранному\s+объекту|по\s+этой\s+позиции|по\s+этому\s+товару|по\s+ней|по\s+нему|по\s+ним|for\s+selected\s+object|selected\s+object)/iu.test(normalized)) {
return true;
}
if (/(?:по\s+выбранному\s+объекту|по\s+этой\s+позиции|по\s+этому\s+товару|по\s+ней|по\s+нему|по\s+ним|for\s+selected\s+object|selected\s+object)/iu.test(normalized)) {
return true;
}
if (/(?:^|\s)(?:и|а\s+еще|а\s+ещё|еще|ещё|также|а\s+теперь|теперь|по\s+этому|по\s+тому|это\s+же|в\s+этом|тот\s+же|also|same|that|then|now)/iu.test(normalized)) {
return true;
}
if (hasAllTimeHint(normalized)) {
return true;
}
@@ -1201,7 +1210,17 @@ function deriveIntentWithFollowupContext(detectedIntent, userMessage, followupCo
followupContext.current_frame_kind === "inventory_drilldown";
const inventorySelectedObjectFollowup = inventoryLineageActive &&
(hasSelectedObjectInventorySignal(normalizedMessage) || (previousIsInventoryFamily && hasFollowupSignal));
const previousCounterpartyLaneActive = hasPreviousCounterparty &&
(followupContext.previous_anchor_type === "counterparty" ||
sourceIntent === "list_documents_by_counterparty" ||
sourceIntent === "list_contracts_by_counterparty" ||
sourceIntent === "bank_operations_by_counterparty" ||
sourceIntent === "customer_revenue_and_payments" ||
sourceIntent === "supplier_payouts_profile" ||
sourceIntent === "counterparty_activity_lifecycle" ||
sourceIntent === "open_items_by_counterparty_or_contract");
const hasExplicitInventoryItemReference = /(?:товар|номенклатур|позици|склад|остат|sku|item|product|товар|номенклатур|позици|склад|остат)/iu.test(normalizedMessage) || hasSelectedObjectInlineSnapshotMetadata(normalizedMessage);
const staleInventoryLineageCanYieldToCounterparty = previousCounterpartyLaneActive && !hasExplicitInventoryItemReference;
const inventoryPurchaseDateVatBridge = inventorySelectedObjectFollowup && hasInventoryPurchaseDateVatBridgeCue(normalizedMessage);
if (inventoryPurchaseDateVatBridge &&
(detectedIntent.intent === "unknown" ||
@@ -1236,14 +1255,20 @@ function deriveIntentWithFollowupContext(detectedIntent, userMessage, followupCo
reasons: [...detectedIntent.reasons, "intent_adjusted_to_vat_followup_context"]
};
}
if (!inventoryLineageActive &&
if ((!inventoryLineageActive || staleInventoryLineageCanYieldToCounterparty) &&
hasAnyPartyAnchor &&
!hasExplicitInventoryItemReference &&
detectedIntent.intent === "inventory_purchase_documents_for_item") {
(detectedIntent.intent === "inventory_purchase_documents_for_item" ||
(staleInventoryLineageCanYieldToCounterparty && hasInventoryPurchaseDocumentsFollowupCue(normalizedMessage)))) {
return {
intent: hasPreviousContract && !hasPreviousCounterparty ? "list_documents_by_contract" : "list_documents_by_counterparty",
confidence: "low",
reasons: [...detectedIntent.reasons, "intent_adjusted_from_non_inventory_followup_context"]
reasons: [
...detectedIntent.reasons,
staleInventoryLineageCanYieldToCounterparty
? "intent_adjusted_from_stale_inventory_context_to_counterparty_documents"
: "intent_adjusted_from_non_inventory_followup_context"
]
};
}
const allowOpenItemsFollowupFallback = detectedIntent.intent === "unknown" && !isVatFollowup;