Закрепить Y9 selected-object agent loop
This commit is contained in:
@@ -1648,7 +1648,7 @@ function extractAddressFilters(userMessage, intent) {
|
||||
warnings.push("supplier_anchor_derived_for_inventory_documentary_chain");
|
||||
}
|
||||
}
|
||||
const allowGenericCounterpartyAnchor = !isInventoryTraceIntent(intent);
|
||||
const allowGenericCounterpartyAnchor = !isInventoryTraceIntent(intent) && intent !== "inventory_on_hand_as_of_date";
|
||||
const knownFinancialCounterparty = allowGenericCounterpartyAnchor && shouldPreferKnownFinancialCounterpartyAnchor(intent)
|
||||
? extractKnownFinancialCounterpartyAnchor(text)
|
||||
: undefined;
|
||||
|
||||
@@ -376,7 +376,14 @@ function buildFocusObjectFromDebug(debug, resultSetId, createdAt) {
|
||||
}
|
||||
}
|
||||
const objectType = toAddressFocusObjectType(debug.anchor_type);
|
||||
const canonicalType = objectType === "unknown" ? inferDisplayEntityType(toAddressIntent(debug.detected_intent)) : objectType;
|
||||
const detectedIntent = toAddressIntent(debug.detected_intent);
|
||||
if (detectedIntent === "inventory_on_hand_as_of_date") {
|
||||
const organization = (0, assistantContinuityPolicy_1.readAddressDebugOrganization)(debug, toNonEmptyString);
|
||||
if (organization) {
|
||||
return buildFocusObject("organization", organization, resultSetId, createdAt);
|
||||
}
|
||||
}
|
||||
const canonicalType = objectType === "unknown" ? inferDisplayEntityType(detectedIntent) : objectType;
|
||||
if (canonicalType === "item") {
|
||||
const item = (0, assistantContinuityPolicy_1.readAddressDebugItem)(debug, toNonEmptyString);
|
||||
return item ? buildFocusObject(canonicalType, item, resultSetId, createdAt) : null;
|
||||
|
||||
@@ -1629,6 +1629,17 @@ function applyPreExecutionOrganizationScopeGrounding(input) {
|
||||
input.semanticFrame.anchor_value = activeOrganization;
|
||||
}
|
||||
}
|
||||
if (activeOrganization &&
|
||||
sameNormalizedOrganizationScope(input.filters.organization ?? null, activeOrganization) &&
|
||||
referentialOrganizationScopeDetected &&
|
||||
typeof input.filters.counterparty !== "string") {
|
||||
if (!input.warnings.includes("counterparty_cleared_from_referential_organization_scope")) {
|
||||
input.warnings.push("counterparty_cleared_from_referential_organization_scope");
|
||||
}
|
||||
if (!input.baseReasons.includes("counterparty_cleared_from_referential_organization_scope")) {
|
||||
input.baseReasons.push("counterparty_cleared_from_referential_organization_scope");
|
||||
}
|
||||
}
|
||||
if (activeOrganization &&
|
||||
sameNormalizedOrganizationScope(input.filters.organization ?? null, activeOrganization) &&
|
||||
typeof input.filters.counterparty === "string" &&
|
||||
|
||||
@@ -3198,9 +3198,9 @@ function composeFactualReplyBody(intent, rows, options = {}) {
|
||||
const purchaseBasisLabel = vatPurchaseDateBasisLabel(options.purchaseDateBridge?.basis, hasMultiplePurchaseDates);
|
||||
const directVatLine = selectedPurchaseDate
|
||||
? hasMultiplePurchaseDates
|
||||
? `Коротко: если брать ${purchaseBasisLabel} ${formatDateRu(selectedPurchaseDate)}, подтвержденный НДС к уплате за налоговый период${organizationScopeLabel} — ${formatConfirmedMoney(vatToPay)}.`
|
||||
: `Коротко: по дате покупки ${formatDateRu(selectedPurchaseDate)} подтвержденный НДС к уплате за налоговый период${organizationScopeLabel} — ${formatConfirmedMoney(vatToPay)}.`
|
||||
: `Коротко: подтвержденный НДС к уплате за налоговый период${organizationScopeLabel} — ${formatConfirmedMoney(vatToPay)}.`;
|
||||
? `Если брать ${purchaseBasisLabel} ${formatDateRu(selectedPurchaseDate)}, подтвержденный НДС к уплате за налоговый период${organizationScopeLabel} — ${formatConfirmedMoney(vatToPay)}.`
|
||||
: `По дате покупки ${formatDateRu(selectedPurchaseDate)} подтвержденный НДС к уплате за налоговый период${organizationScopeLabel} — ${formatConfirmedMoney(vatToPay)}.`
|
||||
: `Подтвержденный НДС к уплате за налоговый период${organizationScopeLabel} — ${formatConfirmedMoney(vatToPay)}.`;
|
||||
const lines = [
|
||||
directVatLine,
|
||||
"Расчет сделан по подтвержденным строкам книг продаж и покупок.",
|
||||
|
||||
@@ -496,6 +496,9 @@ function createAssistantRoutePolicy(deps) {
|
||||
hasDataRetrievalRequestSignal(repairedRawUserMessage);
|
||||
const llmContractMode = toNonEmptyString(llmPreDecomposeMeta?.predecomposeContract?.mode);
|
||||
const llmFirstAddressCandidate = Boolean(llmContractMode === "address_query" && llmContractIntent && llmContractIntent !== "unknown");
|
||||
const llmSupportedAddressQueryIntent = Boolean(llmContractMode === "address_query" &&
|
||||
llmContractIntent &&
|
||||
ADDRESS_INTENTS_KEEP_ADDRESS_LANE.has(llmContractIntent));
|
||||
const llmFirstUnsupportedCandidate = Boolean(llmContractMode === "unsupported" &&
|
||||
(!llmContractIntent || llmContractIntent === "unknown"));
|
||||
const dangerOrCoercionSignal = hasDangerOrCoercionSignal(rawUserMessage) ||
|
||||
@@ -832,6 +835,7 @@ function createAssistantRoutePolicy(deps) {
|
||||
!capabilityMetaQuery &&
|
||||
!dangerOrCoercionSignal &&
|
||||
!effectiveGroundedValueFlowFollowupContextDetected &&
|
||||
!llmSupportedAddressQueryIntent &&
|
||||
!organizationClarificationContinuationDetected);
|
||||
if (unsupportedCurrentTurnMeaningBoundary) {
|
||||
return {
|
||||
|
||||
@@ -1912,7 +1912,7 @@ export function extractAddressFilters(userMessage: string, intent: AddressIntent
|
||||
}
|
||||
}
|
||||
|
||||
const allowGenericCounterpartyAnchor = !isInventoryTraceIntent(intent);
|
||||
const allowGenericCounterpartyAnchor = !isInventoryTraceIntent(intent) && intent !== "inventory_on_hand_as_of_date";
|
||||
const knownFinancialCounterparty =
|
||||
allowGenericCounterpartyAnchor && shouldPreferKnownFinancialCounterpartyAnchor(intent)
|
||||
? extractKnownFinancialCounterpartyAnchor(text)
|
||||
|
||||
@@ -442,7 +442,14 @@ function buildFocusObjectFromDebug(debug: Record<string, unknown>, resultSetId:
|
||||
}
|
||||
}
|
||||
const objectType = toAddressFocusObjectType(debug.anchor_type);
|
||||
const canonicalType = objectType === "unknown" ? inferDisplayEntityType(toAddressIntent(debug.detected_intent)) : objectType;
|
||||
const detectedIntent = toAddressIntent(debug.detected_intent);
|
||||
if (detectedIntent === "inventory_on_hand_as_of_date") {
|
||||
const organization = readAddressDebugOrganization(debug, toNonEmptyString);
|
||||
if (organization) {
|
||||
return buildFocusObject("organization", organization, resultSetId, createdAt);
|
||||
}
|
||||
}
|
||||
const canonicalType = objectType === "unknown" ? inferDisplayEntityType(detectedIntent) : objectType;
|
||||
if (canonicalType === "item") {
|
||||
const item = readAddressDebugItem(debug, toNonEmptyString);
|
||||
return item ? buildFocusObject(canonicalType, item, resultSetId, createdAt) : null;
|
||||
|
||||
@@ -2012,6 +2012,20 @@ function applyPreExecutionOrganizationScopeGrounding(input: {
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
activeOrganization &&
|
||||
sameNormalizedOrganizationScope(input.filters.organization ?? null, activeOrganization) &&
|
||||
referentialOrganizationScopeDetected &&
|
||||
typeof input.filters.counterparty !== "string"
|
||||
) {
|
||||
if (!input.warnings.includes("counterparty_cleared_from_referential_organization_scope")) {
|
||||
input.warnings.push("counterparty_cleared_from_referential_organization_scope");
|
||||
}
|
||||
if (!input.baseReasons.includes("counterparty_cleared_from_referential_organization_scope")) {
|
||||
input.baseReasons.push("counterparty_cleared_from_referential_organization_scope");
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
activeOrganization &&
|
||||
sameNormalizedOrganizationScope(input.filters.organization ?? null, activeOrganization) &&
|
||||
|
||||
@@ -4094,9 +4094,9 @@ function composeFactualReplyBody(
|
||||
const purchaseBasisLabel = vatPurchaseDateBasisLabel(options.purchaseDateBridge?.basis, hasMultiplePurchaseDates);
|
||||
const directVatLine = selectedPurchaseDate
|
||||
? hasMultiplePurchaseDates
|
||||
? `Коротко: если брать ${purchaseBasisLabel} ${formatDateRu(selectedPurchaseDate)}, подтвержденный НДС к уплате за налоговый период${organizationScopeLabel} — ${formatConfirmedMoney(vatToPay)}.`
|
||||
: `Коротко: по дате покупки ${formatDateRu(selectedPurchaseDate)} подтвержденный НДС к уплате за налоговый период${organizationScopeLabel} — ${formatConfirmedMoney(vatToPay)}.`
|
||||
: `Коротко: подтвержденный НДС к уплате за налоговый период${organizationScopeLabel} — ${formatConfirmedMoney(vatToPay)}.`;
|
||||
? `Если брать ${purchaseBasisLabel} ${formatDateRu(selectedPurchaseDate)}, подтвержденный НДС к уплате за налоговый период${organizationScopeLabel} — ${formatConfirmedMoney(vatToPay)}.`
|
||||
: `По дате покупки ${formatDateRu(selectedPurchaseDate)} подтвержденный НДС к уплате за налоговый период${organizationScopeLabel} — ${formatConfirmedMoney(vatToPay)}.`
|
||||
: `Подтвержденный НДС к уплате за налоговый период${organizationScopeLabel} — ${formatConfirmedMoney(vatToPay)}.`;
|
||||
|
||||
const lines = [
|
||||
directVatLine,
|
||||
|
||||
@@ -584,6 +584,11 @@ export function createAssistantRoutePolicy(deps) {
|
||||
hasDataRetrievalRequestSignal(repairedRawUserMessage);
|
||||
const llmContractMode = toNonEmptyString(llmPreDecomposeMeta?.predecomposeContract?.mode);
|
||||
const llmFirstAddressCandidate = Boolean(llmContractMode === "address_query" && llmContractIntent && llmContractIntent !== "unknown");
|
||||
const llmSupportedAddressQueryIntent = Boolean(
|
||||
llmContractMode === "address_query" &&
|
||||
llmContractIntent &&
|
||||
ADDRESS_INTENTS_KEEP_ADDRESS_LANE.has(llmContractIntent)
|
||||
);
|
||||
const llmFirstUnsupportedCandidate = Boolean(llmContractMode === "unsupported" &&
|
||||
(!llmContractIntent || llmContractIntent === "unknown"));
|
||||
const dangerOrCoercionSignal = hasDangerOrCoercionSignal(rawUserMessage) ||
|
||||
@@ -924,6 +929,7 @@ export function createAssistantRoutePolicy(deps) {
|
||||
!capabilityMetaQuery &&
|
||||
!dangerOrCoercionSignal &&
|
||||
!effectiveGroundedValueFlowFollowupContextDetected &&
|
||||
!llmSupportedAddressQueryIntent &&
|
||||
!organizationClarificationContinuationDetected);
|
||||
if (unsupportedCurrentTurnMeaningBoundary) {
|
||||
return {
|
||||
|
||||
@@ -101,7 +101,7 @@ describe("inventory aging follow-up", () => {
|
||||
);
|
||||
|
||||
expect(reply.responseType).toBe("FACTUAL_SUMMARY");
|
||||
expect(reply.text).toContain("К самым старым закупкам");
|
||||
expect(reply.text).toContain("Среди фактических положительных остатков");
|
||||
expect(reply.text).toContain("Дата среза: 30.09.2021");
|
||||
expect(reply.text).toContain("Позиции от самых старых закупок:");
|
||||
expect(reply.text).toContain("Ограничения:");
|
||||
|
||||
@@ -2138,7 +2138,7 @@ describe("address compose stage utf8 headers", () => {
|
||||
);
|
||||
|
||||
expect(reply.responseType).toBe("FACTUAL_SUMMARY");
|
||||
expect(reply.text).toContain("Коротко: подтвержденный НДС к уплате за налоговый период по организации ООО Альтернатива Плюс");
|
||||
expect(reply.text).toContain("Подтвержденный НДС к уплате за налоговый период по организации ООО Альтернатива Плюс");
|
||||
expect(reply.text).toContain("Расчет сделан по подтвержденным строкам книг продаж и покупок.");
|
||||
expect(reply.text).toContain("- Организация: ООО Альтернатива Плюс.");
|
||||
expect(reply.text).toContain("50.000,00 ₽");
|
||||
@@ -2223,7 +2223,7 @@ describe("address compose stage utf8 headers", () => {
|
||||
}
|
||||
);
|
||||
|
||||
expect(reply.text).toContain("если брать первую подтвержденную дату закупки 05.02.2015");
|
||||
expect(reply.text).toContain("Если брать первую подтвержденную дату закупки 05.02.2015");
|
||||
expect(reply.text).toContain("у позиции несколько подтвержденных дат закупки");
|
||||
expect(reply.text).toContain("05.02.2015..22.07.2015");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user