Закрепить широкий phase12 agent replay

This commit is contained in:
2026-06-02 10:02:12 +03:00
parent b52279d19e
commit 7995980215
8 changed files with 435 additions and 10 deletions
@@ -435,6 +435,17 @@ export const ROOT_EXACT_CAPABILITY_CONTRACTS: readonly AssistantCapabilityContra
resultShape: "open_contracts_snapshot",
answerObjectShape: "open_contracts_snapshot"
}),
rootExactCapability({
capability_id: "address_open_items_by_counterparty_or_contract",
domainId: "contracts",
intent_ids: ["open_items_by_counterparty_or_contract"],
transitions: ["T1", "T2", "T6", "T7"],
requiredAnchors: [],
optionalAnchors: ["organization", "date_scope", "account", "counterparty", "contract"],
resultShape: "open_items_by_account_counterparty_or_contract",
answerObjectShape: "open_items_snapshot",
scenarioFamilies: ["canonical", "colloquial", "account_scope", "exact_negative_answer"]
}),
rootExactCapability({
capability_id: "confirmed_vat_payable_as_of_date",
domainId: "vat",
@@ -84,6 +84,37 @@ export function createAssistantTransitionPolicy(deps) {
);
}
function hasExplicitDateScopeSignal(...values) {
return values
.map((value) => normalizeFollowupText(value))
.some((normalized) => {
if (!normalized) {
return false;
}
return /(?:\b(?:19|20)\d{2}\b|\b\d{1,2}[./-]\d{1,2}[./-]\d{2,4}\b|\b\d{4}[./-]\d{1,2}[./-]\d{1,2}\b|за\s+(?:период|месяц|год|квартал)|на\s+(?:дат|конец|сегодня)|январ|феврал|март|апрел|ма(?:й|я|е)|июн|июл|август|сентябр|октябр|ноябр|декабр|same\s+period|this\s+period|that\s+period)/iu.test(
normalized
);
});
}
function shouldClearStaleDateScopeForCounterpartyDocsRoot(
targetIntent,
sourceIntentHint,
userMessage,
alternateMessage
) {
if (targetIntent !== "list_documents_by_counterparty") {
return false;
}
if (sourceIntentHint === "list_documents_by_counterparty" || sourceIntentHint === "list_documents_by_contract") {
return false;
}
if (hasSamePeriodReferenceCue(userMessage, alternateMessage) || hasExplicitDateScopeSignal(userMessage, alternateMessage)) {
return false;
}
return true;
}
function hasBankOperationsPivotCue(text) {
const normalized = normalizeFollowupText(text);
if (!normalized) {
@@ -1663,6 +1694,25 @@ export function createAssistantTransitionPolicy(deps) {
if (!previousIntent && !previousAnchor && Object.keys(previousFilters).length === 0) {
return null;
}
const predecomposeIntent = deps.toNonEmptyString(llmPreDecomposeMeta?.predecomposeContract?.intent);
const carryoverTargetIntentPreview = explicitIntent ?? predecomposeIntent ?? previousIntent;
if (
shouldClearStaleDateScopeForCounterpartyDocsRoot(
carryoverTargetIntentPreview,
sourceIntentHint,
userMessage,
alternateMessage
)
) {
delete previousFilters.as_of_date;
delete previousFilters.period_from;
delete previousFilters.period_to;
delete previousFilters.purchase_date_bridge_selected;
delete previousFilters.purchase_date_bridge_first;
delete previousFilters.purchase_date_bridge_last;
delete previousFilters.purchase_date_bridge_basis;
delete previousFilters.purchase_date_bridge_has_multiple;
}
const shouldAttachInventoryRootFrame = Boolean(
inventoryRootFrame &&
(rootScopedPivot ||
@@ -1681,7 +1731,6 @@ export function createAssistantTransitionPolicy(deps) {
const previousHasPeriodWindow = Boolean(
deps.toNonEmptyString(previousFilters.period_from) || deps.toNonEmptyString(previousFilters.period_to)
);
const predecomposeIntent = deps.toNonEmptyString(llmPreDecomposeMeta?.predecomposeContract?.intent);
const shouldRetargetVatSamePeriod =
previousHasPeriodWindow &&
hasSamePeriodReferenceCue(userMessage, alternateMessage) &&