Архитектура: вернуть company activity assessment в address lane и убрать ложный organization anchor из root-scoped carryover

This commit is contained in:
2026-04-18 22:24:41 +03:00
parent 8111586d8d
commit c605fae3a3
12 changed files with 400 additions and 28 deletions
@@ -65,8 +65,10 @@ function hasUnicodeCounterpartyActivityLifecycleSignal(text) {
if (!normalized) {
return false;
}
const hasActivityAssessmentCue = /(?:\u043a\u0430\u043a\s+[\p{L}\d_-]+\s+\u043e\u0446\u0435\u043d(?:\u0438\u0448\u044c|\u0438\u0442\u044c|\u0438\u0432\u0430\u0435\u0448\u044c)|\u043e\u0446\u0435\u043d(?:\u0438\u0442\u044c|\u043a\u0430)|\u043e\u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0437(?:\u0443\u0435\u0448\u044c|\u043e\u0432\u0430\u0442\u044c)|\u0447\u0442\u043e\s+\u043c\u043e\u0436\u043d\u043e\s+\u0441\u043a\u0430\u0437\u0430\u0442\u044c\s+\u043e)/iu.test(normalized) &&
/(?:\u0434\u0435\u044f\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442|\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442|\u0440\u0430\u0431\u043e\u0442)/iu.test(normalized);
const hasActivityAgeCue = /(?:\u0441\u043a\u043e\u043b\u044c\u043a\u043e\s+\u043b\u0435\u0442\s+\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438|\u0441\u043a\u043e\u043b\u044c\u043a\u043e\s+\u043b\u0435\u0442\s+\u0432\s+\u0431\u0430\u0437\u0435|\u0432\u043e\u0437\u0440\u0430\u0441\u0442\s+\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438|\u043f\u0435\u0440\u0432(?:\u0430\u044f|\u044b\u0439|\u043e\u0435)\s+(?:\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c|\u043f\u043b\u0430\u0442\u0435\u0436|\u043f\u043e\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435|\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442)|\u043f\u043e\u0441\u043b\u0435\u0434\u043d(?:\u044f\u044f|\u0438\u0439|\u0435\u0435)\s+\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c|\u0441\s+\u043a\u0430\u043a\u043e\u0433\u043e\s+\u0433\u043e\u0434\u0430\s+\u0430\u043a\u0442\u0438\u0432)/iu.test(normalized);
if (!hasActivityAgeCue) {
if (!hasActivityAgeCue && !hasActivityAssessmentCue) {
return false;
}
const hasOneCLexeme = /(?:\u0432\s+\u0431\u0430\u0437\u0435\s+1[\u0441c]|\u0432\s+1[\u0441c]\s+\u0431\u0430\u0437\u0435|\u0438\u0437\s+1[\u0441c])/iu.test(normalized);
@@ -721,6 +721,20 @@ function createAssistantRoutePolicy(deps) {
let runAddressLane = Boolean(baseToolGate?.runAddressLane);
let toolGateDecision = String(baseToolGate?.decision ?? "skip_address_lane");
let toolGateReason = String(baseToolGate?.reason ?? "no_address_signal_after_l0");
const semanticAddressLaneRecovery = Boolean(!runAddressLane &&
supportedAddressRouteCandidateDetected &&
!deepAnalysisPreferenceDetected &&
!unsupportedAddressIntentFallbackToDeep &&
!deepAnalysisSignalFallbackToDeep &&
!aggregateAnalyticsFallbackToDeep &&
!deepSessionContinuationFallbackToDeep);
if (semanticAddressLaneRecovery) {
runAddressLane = true;
toolGateDecision = "run_address_lane";
toolGateReason = resolvedIntentResolution.intent !== "unknown" || llmContractIntent
? "address_intent_resolver_detected"
: "address_signal_detected";
}
if (unsupportedAddressIntentFallbackToDeep) {
runAddressLane = false;
toolGateDecision = "skip_address_lane";
+4 -9
View File
@@ -73,6 +73,7 @@ const assistantBoundaryPolicy_1 = __importStar(require("./assistantBoundaryPolic
const assistantLivingModePolicy_1 = __importStar(require("./assistantLivingModePolicy"));
const assistantMetaFollowupPolicy_1 = __importStar(require("./assistantMetaFollowupPolicy"));
const assistantMemoryRecapPolicy_1 = __importStar(require("./assistantMemoryRecapPolicy"));
const assistantContinuityPolicy_1 = __importStar(require("./assistantContinuityPolicy"));
const assistantProviderExecutionPolicy_1 = __importStar(require("./assistantProviderExecutionPolicy"));
const assistantRoutePolicy_1 = __importStar(require("./assistantRoutePolicy"));
const assistantTransitionPolicy_1 = __importStar(require("./assistantTransitionPolicy"));
@@ -2512,18 +2513,12 @@ function buildAddressFollowupOffer(addressDebug) {
if (!Array.isArray(suggestedIntents) || suggestedIntents.length === 0) {
return null;
}
const anchorType = toNonEmptyString(addressDebug.anchor_type);
const anchorValue = toNonEmptyString(addressDebug.anchor_value_resolved) ??
toNonEmptyString(addressDebug.anchor_value_raw) ??
readAddressInventoryItemFilter(addressDebug) ??
readAddressFilterString(addressDebug, "counterparty") ??
readAddressFilterString(addressDebug, "contract") ??
readAddressFilterString(addressDebug, "account");
const anchorContext = (0, assistantContinuityPolicy_1.resolveAddressDebugAnchorContext)(addressDebug, toNonEmptyString);
return {
enabled: true,
source_intent: intent,
anchor_type: anchorType ?? "unknown",
anchor_value: anchorValue,
anchor_type: anchorContext.anchorType ?? "unknown",
anchor_value: anchorContext.anchorValue,
suggested_intents: suggestedIntents
};
}
@@ -344,10 +344,11 @@ function createAssistantTransitionPolicy(deps) {
const organizationClarificationCandidates = Array.isArray(organizationAuthority.organizationClarificationCandidates)
? organizationAuthority.organizationClarificationCandidates
: [];
const organizationClarificationSelection = deps.resolveOrganizationSelectionFromMessage(userMessage, organizationClarificationCandidates) ??
const explicitOrganizationClarificationSelection = deps.resolveOrganizationSelectionFromMessage(userMessage, organizationClarificationCandidates) ??
(deps.toNonEmptyString(alternateMessage)
? deps.resolveOrganizationSelectionFromMessage(String(alternateMessage ?? ""), organizationClarificationCandidates)
: null) ??
: null);
const organizationClarificationSelection = explicitOrganizationClarificationSelection ??
deps.normalizeOrganizationScopeValue(organizationAuthority.organizationClarificationSelectionFromScope);
const hasOrganizationClarificationContinuation = Boolean(lastOrganizationClarificationDebug && organizationClarificationSelection);
const followupOffer = previousAddressDebug ? deps.buildAddressFollowupOffer(previousAddressDebug) : null;
@@ -798,9 +799,9 @@ function createAssistantTransitionPolicy(deps) {
previousAnchor = selectedObjectLabel;
}
}
if (organizationClarificationSelection && !previousAnchor) {
if (explicitOrganizationClarificationSelection && !previousAnchor) {
previousAnchorType = "organization";
previousAnchor = organizationClarificationSelection;
previousAnchor = explicitOrganizationClarificationSelection;
}
if (inventoryRootFrame &&
organizationClarificationSelection &&