Закрепить широкий phase12 agent replay
This commit is contained in:
@@ -407,6 +407,17 @@ exports.ROOT_EXACT_CAPABILITY_CONTRACTS = [
|
||||
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",
|
||||
|
||||
@@ -33,6 +33,28 @@ function createAssistantTransitionPolicy(deps) {
|
||||
.some((normalized) => normalized &&
|
||||
/(?:\b(?:same|this|that)\s+period\b|(?:за|на)\s+(?:этот|тот|такой\s+же|тот\s+же)\s+период|(?:Р·Р°|РЅР°)\s+(?:этот|тот|такой\s+Р¶Рµ|тот\s+Р¶Рµ)\s+период)/iu.test(normalized));
|
||||
}
|
||||
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) {
|
||||
@@ -1224,6 +1246,18 @@ 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 ||
|
||||
deps.isInventoryRootFrameIntent(sourceIntentHint) ||
|
||||
@@ -1238,7 +1272,6 @@ function createAssistantTransitionPolicy(deps) {
|
||||
hasSelectedObjectInventorySignalPrimary ||
|
||||
hasSelectedObjectInventorySignalAlternate));
|
||||
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) &&
|
||||
(explicitIntent === "vat_payable_confirmed_as_of_date" ||
|
||||
|
||||
@@ -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) &&
|
||||
|
||||
@@ -4944,6 +4944,27 @@ describe("address decompose stage follow-up carryover", () => {
|
||||
expect(result?.baseReasons).toContain("organization_from_followup_context");
|
||||
});
|
||||
|
||||
it("does not inherit stale debt date when a new counterparty documents root starts", () => {
|
||||
const result = runAddressDecomposeStage("покажи документы по свк", {
|
||||
previous_intent: "receivables_confirmed_as_of_date",
|
||||
previous_filters: {
|
||||
organization: 'ООО "Альтернатива Плюс"',
|
||||
period_from: "2017-05-01",
|
||||
period_to: "2017-05-31",
|
||||
as_of_date: "2017-05-31"
|
||||
},
|
||||
previous_anchor_type: "unknown",
|
||||
previous_anchor_value: null
|
||||
});
|
||||
expect(result).not.toBeNull();
|
||||
expect(result?.intent.intent).toBe("list_documents_by_counterparty");
|
||||
expect(result?.filters.extracted_filters.counterparty).toBe("свк");
|
||||
expect(result?.filters.extracted_filters.organization).toBe('ООО "Альтернатива Плюс"');
|
||||
expect(result?.filters.extracted_filters.as_of_date).toBeUndefined();
|
||||
expect(result?.filters.extracted_filters.period_from).toBeUndefined();
|
||||
expect(result?.filters.extracted_filters.period_to).toBeUndefined();
|
||||
});
|
||||
|
||||
it("inherits as_of_date from previous period for same-date balance follow-up", () => {
|
||||
const result = runAddressDecomposeStage("а по счету 60.01 на ту же дату", {
|
||||
previous_intent: "list_documents_by_counterparty",
|
||||
|
||||
@@ -107,6 +107,16 @@ describe("assistant runtime contract registry", () => {
|
||||
expect(contract?.execution_adapter).toBe("AddressQueryService");
|
||||
});
|
||||
|
||||
it("declares open-items account/counterparty capability as a contracted runtime route", () => {
|
||||
const contract = getAssistantCapabilityContractByIntent("open_items_by_counterparty_or_contract");
|
||||
|
||||
expect(contract?.capability_id).toBe("address_open_items_by_counterparty_or_contract");
|
||||
expect(contract?.runtime_lane).toBe("address_exact");
|
||||
expect(contract?.supported_transition_classes).toEqual(["T1", "T2", "T6", "T7"]);
|
||||
expect(contract?.result_shape).toBe("open_items_by_account_counterparty_or_contract");
|
||||
expect(contract?.required_scenario_families).toContain("exact_negative_answer");
|
||||
});
|
||||
|
||||
it("declares counterparty document and value-flow contracts used by semantic dialog authority replay", () => {
|
||||
const documents = getAssistantCapabilityContractByIntent("list_documents_by_counterparty");
|
||||
expect(documents?.capability_id).toBe("documents_drilldown");
|
||||
|
||||
Reference in New Issue
Block a user