Закрепить Y9 selected-object agent loop

This commit is contained in:
2026-06-02 09:14:30 +03:00
parent 5245a8aeea
commit f3649e4a7d
15 changed files with 363 additions and 23 deletions
@@ -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 {