ARCH: закрепить open-scope continuity для org clarification
This commit is contained in:
@@ -127,6 +127,14 @@ function explicitDateScope(pilot) {
|
||||
const normalized = value.trim();
|
||||
return normalized.length > 0 ? normalized : null;
|
||||
}
|
||||
function explicitOrganizationScope(pilot) {
|
||||
const value = pilot.evidence.query_plan.turn_meaning_ref?.explicit_organization_scope;
|
||||
if (typeof value !== "string") {
|
||||
return null;
|
||||
}
|
||||
const normalized = value.trim();
|
||||
return normalized.length > 0 ? normalized : null;
|
||||
}
|
||||
function documentOrMovementScopeRu(pilot) {
|
||||
const entity = firstEntityCandidate(pilot);
|
||||
const period = explicitDateScope(pilot);
|
||||
@@ -151,6 +159,12 @@ function isBidirectionalValueFlowComparisonClarification(pilot) {
|
||||
return (pilot.reason_codes.includes("planner_selected_bidirectional_value_flow_comparison_from_data_need_graph") ||
|
||||
pilot.dry_run.reason_codes.includes("planner_selected_bidirectional_value_flow_comparison_from_data_need_graph"));
|
||||
}
|
||||
function isOpenScopeValueFlowClarification(pilot) {
|
||||
return (pilot.reason_codes.includes("planner_selected_open_scope_value_flow_total_from_data_need_graph") ||
|
||||
pilot.reason_codes.includes("planner_selected_monthly_open_scope_value_flow_total_from_data_need_graph") ||
|
||||
pilot.dry_run.reason_codes.includes("planner_selected_open_scope_value_flow_total_from_data_need_graph") ||
|
||||
pilot.dry_run.reason_codes.includes("planner_selected_monthly_open_scope_value_flow_total_from_data_need_graph"));
|
||||
}
|
||||
function isDocumentLaneClarification(pilot) {
|
||||
return (isDocumentPilot(pilot) ||
|
||||
pilot.reason_codes.includes("planner_selected_document_recipe") ||
|
||||
@@ -172,6 +186,16 @@ function dryRunMissingAxis(pilot, axis) {
|
||||
return pilot.dry_run.execution_steps.some((step) => step.missing_axis_options.some((option) => option.includes(axis)));
|
||||
}
|
||||
function clarificationNeedRu(pilot) {
|
||||
const organizationScopedOpenTotal = pilot.reason_codes.includes("data_need_graph_open_scope_total_needs_organization") ||
|
||||
pilot.dry_run.reason_codes.includes("data_need_graph_open_scope_total_needs_organization") ||
|
||||
pilot.reason_codes.includes("planner_requires_organization_scope_from_data_need_graph") ||
|
||||
pilot.dry_run.reason_codes.includes("planner_requires_organization_scope_from_data_need_graph");
|
||||
if (organizationScopedOpenTotal) {
|
||||
return {
|
||||
subject: "\u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u044e",
|
||||
verb: "\u043d\u0443\u0436\u043d\u043e"
|
||||
};
|
||||
}
|
||||
const hasCounterparty = dryRunHasAxis(pilot, "counterparty");
|
||||
const hasAccount = dryRunHasAxis(pilot, "account");
|
||||
const needsPeriod = dryRunMissingAxis(pilot, "period");
|
||||
@@ -188,9 +212,16 @@ function clarificationNeedRu(pilot) {
|
||||
return { subject: "контекст проверки", verb: "нужно" };
|
||||
}
|
||||
function clarificationNextStepLine(pilot, laneLabel) {
|
||||
const organizationScopedOpenTotal = pilot.reason_codes.includes("data_need_graph_open_scope_total_needs_organization") ||
|
||||
pilot.dry_run.reason_codes.includes("data_need_graph_open_scope_total_needs_organization") ||
|
||||
pilot.reason_codes.includes("planner_requires_organization_scope_from_data_need_graph") ||
|
||||
pilot.dry_run.reason_codes.includes("planner_requires_organization_scope_from_data_need_graph");
|
||||
const needsPeriod = dryRunMissingAxis(pilot, "period");
|
||||
const needsOrganization = dryRunMissingAxis(pilot, "organization");
|
||||
const scopeSuffix = laneScopeSuffix(pilot);
|
||||
if (organizationScopedOpenTotal && !needsPeriod) {
|
||||
return `Уточните организацию, и я продолжу поиск по ${laneLabel}${scopeSuffix} в 1С.`;
|
||||
}
|
||||
if (needsPeriod && needsOrganization) {
|
||||
return `Уточните период и организацию, и я продолжу поиск по ${laneLabel}${scopeSuffix} в 1С.`;
|
||||
}
|
||||
@@ -298,6 +329,10 @@ function headlineFor(mode, pilot) {
|
||||
const need = clarificationNeedRu(pilot);
|
||||
return `Могу посчитать ranking по денежному потоку между контрагентами, но для bounded поиска в 1С ${need.verb} ${need.subject}.`;
|
||||
}
|
||||
if (mode === "needs_clarification" && isOpenScopeValueFlowClarification(pilot)) {
|
||||
const need = clarificationNeedRu(pilot);
|
||||
return `Могу посчитать общий денежный поток в проверяемом окне, но для bounded поиска в 1С ${need.verb} ${need.subject}.`;
|
||||
}
|
||||
if (mode === "needs_clarification") {
|
||||
return "Нужно уточнить контекст перед поиском в 1С.";
|
||||
}
|
||||
@@ -337,6 +372,9 @@ function nextStepFor(mode, pilot) {
|
||||
if (mode === "needs_clarification" && isRankedValueFlowClarification(pilot)) {
|
||||
return clarificationNextStepLine(pilot, "ranking-поиску между контрагентами");
|
||||
}
|
||||
if (mode === "needs_clarification" && isOpenScopeValueFlowClarification(pilot)) {
|
||||
return clarificationNextStepLine(pilot, "денежному потоку");
|
||||
}
|
||||
if (mode === "needs_clarification") {
|
||||
return "Уточните контрагента, период или организацию, и я смогу выполнить проверку по 1С.";
|
||||
}
|
||||
@@ -541,6 +579,8 @@ function derivedValueFlowConfirmedLine(pilot) {
|
||||
if (!flow) {
|
||||
return null;
|
||||
}
|
||||
const organizationScope = explicitOrganizationScope(pilot);
|
||||
const organization = organizationScope ? ` по организации ${organizationScope}` : "";
|
||||
const counterparty = flow.counterparty ? ` по контрагенту ${flow.counterparty}` : "";
|
||||
const period = flow.period_scope ? ` за период ${flow.period_scope}` : " в проверенном окне";
|
||||
const movementLabel = flow.value_flow_direction === "outgoing_supplier_payout"
|
||||
|
||||
+41
-3
@@ -85,6 +85,30 @@ function comparisonNeedFor(action) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function hasOpenScopeOneSidedValueTotalHint(rawUtterance, action) {
|
||||
if (!rawUtterance) {
|
||||
return false;
|
||||
}
|
||||
if (action === "turnover") {
|
||||
return /(?:\bсколько\s+(?:мы\s+)?(?:получили|получено|входящих(?:\s+денег)?|поступлений|денег\s+пришло)\b|(?:сумма|объем)\s+(?:входящих|поступлений)|поступлений\s+за\b)/iu.test(rawUtterance);
|
||||
}
|
||||
if (action === "payout") {
|
||||
return /(?:\bсколько\s+(?:мы\s+)?(?:заплатили|выплатили|потратили|исходящих(?:\s+денег)?|платежей|списаний)\b|(?:сумма|объем)\s+(?:исходящих|платежей|списаний)|(?:платежей|списаний)\s+за\b)/iu.test(rawUtterance);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function hasOpenScopeOneSidedValueTotalHintUtf8Safe(rawUtterance, action) {
|
||||
if (!rawUtterance) {
|
||||
return false;
|
||||
}
|
||||
if (action === "turnover") {
|
||||
return /(?:\u0441\u043a\u043e\u043b\u044c\u043a\u043e\s+(?:\u043c\u044b\s+)?(?:\u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438|\u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043e|\u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445(?:\s+\u0434\u0435\u043d\u0435\u0433)?|\u043f\u043e\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0439|\u0434\u0435\u043d\u0435\u0433\s+\u043f\u0440\u0438\u0448\u043b\u043e)|(?:\u0441\u0443\u043c\u043c\u0430|\u043e\u0431\u044a\u0435\u043c)\s+(?:\u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445|\u043f\u043e\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0439)|\u043f\u043e\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0439\s+\u0437\u0430)/u.test(rawUtterance);
|
||||
}
|
||||
if (action === "payout") {
|
||||
return /(?:\u0441\u043a\u043e\u043b\u044c\u043a\u043e\s+(?:\u043c\u044b\s+)?(?:\u0437\u0430\u043f\u043b\u0430\u0442\u0438\u043b\u0438|\u0432\u044b\u043f\u043b\u0430\u0442\u0438\u043b\u0438|\u043f\u043e\u0442\u0440\u0430\u0442\u0438\u043b\u0438|\u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0445(?:\s+\u0434\u0435\u043d\u0435\u0433)?|\u043f\u043b\u0430\u0442\u0435\u0436\u0435\u0439|\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u0439)|(?:\u0441\u0443\u043c\u043c\u0430|\u043e\u0431\u044a\u0435\u043c)\s+(?:\u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0445|\u043f\u043b\u0430\u0442\u0435\u0436\u0435\u0439|\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u0439)|(?:\u043f\u043b\u0430\u0442\u0435\u0436\u0435\u0439|\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u0439)\s+\u0437\u0430)/u.test(rawUtterance);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function supportsOrganizationScopedOpenTotal(action) {
|
||||
return action === "turnover" || action === "payout";
|
||||
}
|
||||
@@ -95,7 +119,7 @@ function allowsOpenScopeWithoutSubject(input) {
|
||||
if (input.rankingNeed || input.comparisonNeed === "incoming_vs_outgoing") {
|
||||
return true;
|
||||
}
|
||||
return Boolean(input.organizationScope && supportsOrganizationScopedOpenTotal(input.action));
|
||||
return Boolean(supportsOrganizationScopedOpenTotal(input.action) && (input.organizationScope || input.oneSidedOpenScopeTotalHint));
|
||||
}
|
||||
function rankingNeedFromRawUtterance(value) {
|
||||
const text = lower(value);
|
||||
@@ -229,19 +253,30 @@ function buildAssistantMcpDiscoveryDataNeedGraph(input) {
|
||||
const aggregationNeed = aggregationNeedFor(aggregationAxis);
|
||||
const comparisonNeed = comparisonNeedFor(action);
|
||||
const rankingNeed = rankingNeedFromRawUtterance(rawUtterance);
|
||||
const oneSidedOpenScopeTotalHint = hasOpenScopeOneSidedValueTotalHintUtf8Safe(rawUtterance, action);
|
||||
const openScopeWithoutSubject = subjectCandidates.length === 0 &&
|
||||
allowsOpenScopeWithoutSubject({
|
||||
family: businessFactFamily,
|
||||
action,
|
||||
organizationScope: explicitOrganizationScope,
|
||||
comparisonNeed,
|
||||
rankingNeed
|
||||
rankingNeed,
|
||||
oneSidedOpenScopeTotalHint
|
||||
});
|
||||
const clarificationGaps = [];
|
||||
if (unsupported === "metadata_lane_choice_clarification" || action === "resolve_next_lane") {
|
||||
pushUnique(clarificationGaps, "lane_family_choice");
|
||||
}
|
||||
if (subjectCandidates.length === 0 && businessFactFamily !== "schema_surface" && !openScopeWithoutSubject) {
|
||||
if (subjectCandidates.length === 0 &&
|
||||
businessFactFamily === "value_flow" &&
|
||||
openScopeWithoutSubject &&
|
||||
!rankingNeed &&
|
||||
!comparisonNeed &&
|
||||
oneSidedOpenScopeTotalHint &&
|
||||
!explicitOrganizationScope) {
|
||||
pushUnique(clarificationGaps, "organization");
|
||||
}
|
||||
else if (subjectCandidates.length === 0 && businessFactFamily !== "schema_surface" && !openScopeWithoutSubject) {
|
||||
pushUnique(clarificationGaps, "subject");
|
||||
}
|
||||
const timeScopeNeed = timeScopeNeedFor({
|
||||
@@ -279,6 +314,9 @@ function buildAssistantMcpDiscoveryDataNeedGraph(input) {
|
||||
if (openScopeWithoutSubject && !rankingNeed && !comparisonNeed) {
|
||||
pushReason(reasonCodes, "data_need_graph_open_scope_total_without_subject");
|
||||
}
|
||||
if (clarificationGaps.includes("organization")) {
|
||||
pushReason(reasonCodes, "data_need_graph_open_scope_total_needs_organization");
|
||||
}
|
||||
if (clarificationGaps.length > 0) {
|
||||
pushReason(reasonCodes, "data_need_graph_has_clarification_gaps");
|
||||
}
|
||||
|
||||
@@ -41,6 +41,9 @@ function hasEntity(meaning) {
|
||||
function hasSubjectCandidates(graph) {
|
||||
return (graph?.subject_candidates.length ?? 0) > 0;
|
||||
}
|
||||
function hasReasonCode(graph, reasonCode) {
|
||||
return (graph?.reason_codes ?? []).includes(reasonCode);
|
||||
}
|
||||
function aggregationAxis(meaning) {
|
||||
return toNonEmptyString(meaning?.asked_aggregation_axis)?.toLowerCase() ?? null;
|
||||
}
|
||||
@@ -87,6 +90,9 @@ function recipeFor(input) {
|
||||
const graphAggregation = lower(dataNeedGraph?.aggregation_need);
|
||||
const graphClarificationGaps = (dataNeedGraph?.clarification_gaps ?? []).map((item) => lower(item));
|
||||
const organizationScope = toNonEmptyString(meaning?.explicit_organization_scope);
|
||||
const openScopeTotalWithoutSubject = graphFactFamily === "value_flow" &&
|
||||
!hasSubjectCandidates(dataNeedGraph) &&
|
||||
hasReasonCode(dataNeedGraph, "data_need_graph_open_scope_total_without_subject");
|
||||
const combined = `${domain} ${action} ${unsupported}`.trim();
|
||||
const axes = [];
|
||||
const requestedAggregationAxis = aggregationAxis(meaning);
|
||||
@@ -133,7 +139,8 @@ function recipeFor(input) {
|
||||
: "planner_selected_top_ranked_value_flow_from_data_need_graph"
|
||||
};
|
||||
}
|
||||
if (!hasSubjectCandidates(dataNeedGraph) && organizationScope) {
|
||||
if (openScopeTotalWithoutSubject) {
|
||||
pushUnique(axes, "organization");
|
||||
pushUnique(axes, "aggregate_axis");
|
||||
pushUnique(axes, "amount");
|
||||
pushUnique(axes, "coverage_target");
|
||||
@@ -354,7 +361,27 @@ function planAssistantMcpDiscovery(input) {
|
||||
maxProbeCount: budgetOverride.maxProbeCount
|
||||
});
|
||||
const review = (0, assistantMcpCatalogIndex_1.reviewAssistantMcpDiscoveryPlanAgainstCatalog)(plan);
|
||||
const plannerStatus = statusFrom(plan, review);
|
||||
const organizationClarificationRequired = (dataNeedGraph?.clarification_gaps ?? []).includes("organization") &&
|
||||
!toNonEmptyString(input.turnMeaning?.explicit_organization_scope);
|
||||
const adjustedReview = organizationClarificationRequired && recipe.primitives.includes("query_movements")
|
||||
? {
|
||||
...review,
|
||||
review_status: "needs_more_axes",
|
||||
missing_axes_by_primitive: {
|
||||
...review.missing_axes_by_primitive,
|
||||
query_movements: review.missing_axes_by_primitive.query_movements?.length
|
||||
? review.missing_axes_by_primitive.query_movements
|
||||
: [["organization"]]
|
||||
},
|
||||
reason_codes: review.reason_codes.includes("catalog_requires_organization_scope_from_data_need_graph")
|
||||
? review.reason_codes
|
||||
: [...review.reason_codes, "catalog_requires_organization_scope_from_data_need_graph"]
|
||||
}
|
||||
: review;
|
||||
const plannerStatus = organizationClarificationRequired ? "needs_clarification" : statusFrom(plan, adjustedReview);
|
||||
if (organizationClarificationRequired) {
|
||||
pushReason(reasonCodes, "planner_requires_organization_scope_from_data_need_graph");
|
||||
}
|
||||
if (plannerStatus === "ready_for_execution") {
|
||||
pushReason(reasonCodes, "planner_ready_for_guarded_mcp_execution");
|
||||
}
|
||||
@@ -375,7 +402,7 @@ function planAssistantMcpDiscovery(input) {
|
||||
proposed_primitives: recipe.primitives,
|
||||
required_axes: recipe.axes,
|
||||
discovery_plan: plan,
|
||||
catalog_review: review,
|
||||
catalog_review: adjustedReview,
|
||||
reason_codes: reasonCodes
|
||||
};
|
||||
}
|
||||
|
||||
@@ -138,6 +138,19 @@ function readDiscoveryTurnMeaning(entryPoint) {
|
||||
const turnInput = toRecordObject(entryPoint?.turn_input);
|
||||
return toRecordObject(turnInput?.turn_meaning_ref);
|
||||
}
|
||||
function readDiscoveryDataNeedGraph(entryPoint) {
|
||||
const turnInput = toRecordObject(entryPoint?.turn_input);
|
||||
return toRecordObject(turnInput?.data_need_graph);
|
||||
}
|
||||
function isOpenScopeValueFlowWithoutSubject(entryPoint) {
|
||||
const graph = readDiscoveryDataNeedGraph(entryPoint);
|
||||
const businessFactFamily = toNonEmptyString(graph?.business_fact_family);
|
||||
const subjectCandidates = Array.isArray(graph?.subject_candidates) ? graph.subject_candidates : [];
|
||||
const reasonCodes = Array.isArray(graph?.reason_codes) ? graph.reason_codes : [];
|
||||
return (businessFactFamily === "value_flow" &&
|
||||
subjectCandidates.length === 0 &&
|
||||
reasonCodes.some((reason) => toNonEmptyString(reason) === "data_need_graph_open_scope_total_without_subject"));
|
||||
}
|
||||
function readTruthAnswerShape(input) {
|
||||
const directShape = toRecordObject(input.addressRuntimeMeta?.answer_shape_contract);
|
||||
if (directShape) {
|
||||
@@ -197,6 +210,9 @@ function hasAlignedFactualAddressReply(input, entryPoint) {
|
||||
if (!hasEffectivelyFactualAddressReply(input)) {
|
||||
return false;
|
||||
}
|
||||
if (hasSemanticConflictWithDiscoveryTurnMeaning(input, entryPoint)) {
|
||||
return false;
|
||||
}
|
||||
const detectedIntent = toNonEmptyString(input.addressRuntimeMeta?.detected_intent);
|
||||
return isDetectedIntentAlignedWithTurnMeaning(detectedIntent, readDiscoveryTurnMeaning(entryPoint));
|
||||
}
|
||||
@@ -218,6 +234,10 @@ function hasSemanticConflictWithDiscoveryTurnMeaning(input, entryPoint) {
|
||||
if (!detectedIntent || (!askedDomain && !askedAction && !unsupportedFamily)) {
|
||||
return false;
|
||||
}
|
||||
if (detectedIntent === "customer_revenue_and_payments" &&
|
||||
isOpenScopeValueFlowWithoutSubject(entryPoint)) {
|
||||
return true;
|
||||
}
|
||||
return !isDetectedIntentAlignedWithTurnMeaning(detectedIntent, turnMeaning);
|
||||
}
|
||||
function hasMatchedFactualAddressContinuationTarget(input, entryPoint) {
|
||||
|
||||
+41
-5
@@ -313,6 +313,17 @@ function hasOrganizationScopeSignalUtf8(text) {
|
||||
/\b(?:llc|inc|corp|company|organization|organisation)\b/iu.test(text) ||
|
||||
/(?:\u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446|\u043a\u043e\u043c\u043f\u0430\u043d)/iu.test(text));
|
||||
}
|
||||
function extractOrganizationScopeFromRawText(value) {
|
||||
const text = toNonEmptyString(value);
|
||||
if (!text) {
|
||||
return null;
|
||||
}
|
||||
const match = text.match(/(?:^|[\s,;:])(?:\u043f\u043e|for|in|within)?\s*((?:\u041e\u041e\u041e|\u0418\u041f|\u0410\u041e|\u041f\u0410\u041e|\u0417\u0410\u041e|LLC|Inc|LTD|Corp)\s+[^\n,.;:!?]+)/u);
|
||||
if (!match?.[1]) {
|
||||
return null;
|
||||
}
|
||||
return toNonEmptyString(match[1]);
|
||||
}
|
||||
function hasMonthlyAggregationSignal(text) {
|
||||
return /(?:\u043f\u043e\s+\u043c\u0435\u0441\u044f\u0446\u0430\u043c|\u043f\u043e\u043c\u0435\u0441\u044f\u0447\u043d\u043e|\u0435\u0436\u0435\u043c\u0435\u0441\u044f\u0447\u043d\u043e|month\s+by\s+month|by\s+month|monthly)/iu.test(text);
|
||||
}
|
||||
@@ -590,12 +601,25 @@ function buildAssistantMcpDiscoveryTurnInput(input) {
|
||||
const explicitIntentCandidate = toNonEmptyString(assistantTurnMeaning?.explicit_intent_candidate);
|
||||
const assistantTurnMeaningDateScope = toNonEmptyString(assistantTurnMeaning?.explicit_date_scope);
|
||||
const assistantTurnMeaningOrganizationScope = toNonEmptyString(assistantTurnMeaning?.explicit_organization_scope);
|
||||
const rawOrganizationMentionSignal = hasOrganizationScopeSignalUtf8(rawText);
|
||||
const rawOrganizationScope = extractOrganizationScopeFromRawText(rawUserText ?? rawEffectiveText ?? rawSignalSourceText);
|
||||
const explicitOrganizationScopeSignal = Boolean(rawOrganizationMentionSignal &&
|
||||
(rawOrganizationScope ?? predecomposeEntities.organization ?? assistantTurnMeaningOrganizationScope));
|
||||
const organizationClarificationFollowupApplicable = Boolean(followupSeed.domain === "counterparty_value" &&
|
||||
!followupSeed.counterparty &&
|
||||
rawOrganizationMentionSignal &&
|
||||
(rawOrganizationScope || followupSeed.organization) &&
|
||||
!rawLifecycleSignal &&
|
||||
!rawValueFlowSignal &&
|
||||
!rawMetadataSignal);
|
||||
const rawOpenScopeValueFlowOrganizationSignal = Boolean(rawValueFlowSignal &&
|
||||
!rawBidirectionalValueFlowSignal &&
|
||||
hasOrganizationScopeSignalUtf8(rawText) &&
|
||||
(predecomposeEntities.organization ?? assistantTurnMeaningOrganizationScope));
|
||||
explicitOrganizationScopeSignal);
|
||||
const predecomposeOrganizationMirrorsCounterparty = sameScopedName(predecomposeEntities.counterparty, predecomposeEntities.organization);
|
||||
const organizationMirrorsPredecomposeCounterparty = Boolean((rawBidirectionalValueFlowSignal || hasValueRankingSignal(rawText) || rawOpenScopeValueFlowOrganizationSignal) &&
|
||||
const organizationMirrorsPredecomposeCounterparty = Boolean((rawBidirectionalValueFlowSignal ||
|
||||
hasValueRankingSignal(rawText) ||
|
||||
rawOpenScopeValueFlowOrganizationSignal ||
|
||||
explicitOrganizationScopeSignal) &&
|
||||
(sameScopedName(predecomposeEntities.counterparty, assistantTurnMeaningOrganizationScope) ||
|
||||
predecomposeOrganizationMirrorsCounterparty));
|
||||
const normalizedPredecomposeCounterparty = organizationMirrorsPredecomposeCounterparty
|
||||
@@ -605,7 +629,11 @@ function buildAssistantMcpDiscoveryTurnInput(input) {
|
||||
const followupDiscoverySeedApplicable = Boolean(followupSeed.domain &&
|
||||
!rawLifecycleSignal &&
|
||||
!rawValueFlowSignal &&
|
||||
(monthlyAggregationSignal || explicitDateScopeLiteralDetected || predecomposeDateScope));
|
||||
(monthlyAggregationSignal ||
|
||||
explicitDateScopeLiteralDetected ||
|
||||
predecomposeDateScope ||
|
||||
explicitOrganizationScopeSignal ||
|
||||
organizationClarificationFollowupApplicable));
|
||||
const metadataFollowupSeedApplicable = Boolean(followupSeed.domain === "metadata" &&
|
||||
!rawLifecycleSignal &&
|
||||
!rawValueFlowSignal &&
|
||||
@@ -844,13 +872,17 @@ function buildAssistantMcpDiscoveryTurnInput(input) {
|
||||
Boolean(bidirectionalValueFlowSignal ||
|
||||
hasValueRankingSignal(rawText) ||
|
||||
rawOpenScopeValueFlowOrganizationSignal ||
|
||||
explicitOrganizationScopeSignal ||
|
||||
followupSeed.organization);
|
||||
if (openScopeValueFlowWithoutCounterparty && !valueFlowOrganizationStaysScope) {
|
||||
pushUnique(entityCandidates, predecomposeEntities.organization);
|
||||
pushUnique(entityCandidates, followupSeed.organization);
|
||||
}
|
||||
const explicitOrganizationScope = valueFlowOrganizationStaysScope || !openScopeValueFlowWithoutCounterparty
|
||||
? predecomposeEntities.organization ?? assistantTurnMeaningOrganizationScope ?? followupSeed.organization
|
||||
? rawOrganizationScope ??
|
||||
predecomposeEntities.organization ??
|
||||
assistantTurnMeaningOrganizationScope ??
|
||||
followupSeed.organization
|
||||
: null;
|
||||
if (valueFlowOrganizationStaysScope && explicitOrganizationScope) {
|
||||
for (let index = entityCandidates.length - 1; index >= 0; index -= 1) {
|
||||
@@ -976,6 +1008,7 @@ function buildAssistantMcpDiscoveryTurnInput(input) {
|
||||
metadataGroundedDocumentLaneApplicable ||
|
||||
groundedValueFlowFollowupApplicable,
|
||||
forceDiscoveryOverExplicitIntent: Boolean(entityResolutionClarificationCandidate) ||
|
||||
organizationClarificationFollowupApplicable ||
|
||||
metadataAmbiguityLaneClarificationApplicable ||
|
||||
metadataGroundedMovementLaneApplicable ||
|
||||
metadataGroundedDocumentLaneApplicable ||
|
||||
@@ -1025,6 +1058,9 @@ function buildAssistantMcpDiscoveryTurnInput(input) {
|
||||
if (entityResolutionClarificationCandidate) {
|
||||
pushReason(reasonCodes, "mcp_discovery_entity_resolution_clarification_candidate_selected");
|
||||
}
|
||||
if (organizationClarificationFollowupApplicable) {
|
||||
pushReason(reasonCodes, "mcp_discovery_organization_clarification_followup_from_followup_context");
|
||||
}
|
||||
if (payoutSignal) {
|
||||
pushReason(reasonCodes, "mcp_discovery_payout_signal_detected");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user