ARCH: приоритизировать discovery-period в planner follow-up
This commit is contained in:
@@ -425,6 +425,8 @@ function resolveAddressDebugCarryoverFilters(debug, toNonEmptyString = fallbackT
|
||||
const extractedFilters = readAddressDebugFilters(debug);
|
||||
const nextFilters = extractedFilters ? { ...extractedFilters } : {};
|
||||
const discoveryDateScope = readDiscoveryDateScopeFilters(debug, toNonEmptyString);
|
||||
const preferGroundedDiscoveryDateScope = hasGroundedDiscoveryBusinessAnswer(debug, toNonEmptyString) &&
|
||||
Boolean(discoveryDateScope.asOfDate || discoveryDateScope.periodFrom || discoveryDateScope.periodTo);
|
||||
const counterparty = readAddressDebugCounterparty(debug, toNonEmptyString);
|
||||
const organization = readAddressDebugOrganization(debug, toNonEmptyString);
|
||||
if (counterparty && !toNonEmptyString(nextFilters.counterparty)) {
|
||||
@@ -433,14 +435,19 @@ function resolveAddressDebugCarryoverFilters(debug, toNonEmptyString = fallbackT
|
||||
if (organization && !toNonEmptyString(nextFilters.organization)) {
|
||||
nextFilters.organization = organization;
|
||||
}
|
||||
if (discoveryDateScope.asOfDate && !toNonEmptyString(nextFilters.as_of_date)) {
|
||||
if (discoveryDateScope.asOfDate && (preferGroundedDiscoveryDateScope || !toNonEmptyString(nextFilters.as_of_date))) {
|
||||
nextFilters.as_of_date = discoveryDateScope.asOfDate;
|
||||
delete nextFilters.period_from;
|
||||
delete nextFilters.period_to;
|
||||
}
|
||||
if (discoveryDateScope.periodFrom && !toNonEmptyString(nextFilters.period_from)) {
|
||||
if (discoveryDateScope.periodFrom &&
|
||||
(preferGroundedDiscoveryDateScope || !toNonEmptyString(nextFilters.period_from))) {
|
||||
nextFilters.period_from = discoveryDateScope.periodFrom;
|
||||
}
|
||||
if (discoveryDateScope.periodTo && !toNonEmptyString(nextFilters.period_to)) {
|
||||
if (discoveryDateScope.periodTo &&
|
||||
(preferGroundedDiscoveryDateScope || !toNonEmptyString(nextFilters.period_to))) {
|
||||
nextFilters.period_to = discoveryDateScope.periodTo;
|
||||
delete nextFilters.as_of_date;
|
||||
}
|
||||
const inventoryRootFrame = buildInventoryRootFrameFromAddressDebug(debug, toNonEmptyString);
|
||||
const rootFilters = inventoryRootFrame?.filters && typeof inventoryRootFrame.filters === "object"
|
||||
|
||||
@@ -622,6 +622,9 @@ export function resolveAddressDebugCarryoverFilters(
|
||||
const extractedFilters = readAddressDebugFilters(debug);
|
||||
const nextFilters = extractedFilters ? { ...extractedFilters } : {};
|
||||
const discoveryDateScope = readDiscoveryDateScopeFilters(debug, toNonEmptyString);
|
||||
const preferGroundedDiscoveryDateScope =
|
||||
hasGroundedDiscoveryBusinessAnswer(debug, toNonEmptyString) &&
|
||||
Boolean(discoveryDateScope.asOfDate || discoveryDateScope.periodFrom || discoveryDateScope.periodTo);
|
||||
const counterparty = readAddressDebugCounterparty(debug, toNonEmptyString);
|
||||
const organization = readAddressDebugOrganization(debug, toNonEmptyString);
|
||||
if (counterparty && !toNonEmptyString(nextFilters.counterparty)) {
|
||||
@@ -630,14 +633,23 @@ export function resolveAddressDebugCarryoverFilters(
|
||||
if (organization && !toNonEmptyString(nextFilters.organization)) {
|
||||
nextFilters.organization = organization;
|
||||
}
|
||||
if (discoveryDateScope.asOfDate && !toNonEmptyString(nextFilters.as_of_date)) {
|
||||
if (discoveryDateScope.asOfDate && (preferGroundedDiscoveryDateScope || !toNonEmptyString(nextFilters.as_of_date))) {
|
||||
nextFilters.as_of_date = discoveryDateScope.asOfDate;
|
||||
delete nextFilters.period_from;
|
||||
delete nextFilters.period_to;
|
||||
}
|
||||
if (discoveryDateScope.periodFrom && !toNonEmptyString(nextFilters.period_from)) {
|
||||
if (
|
||||
discoveryDateScope.periodFrom &&
|
||||
(preferGroundedDiscoveryDateScope || !toNonEmptyString(nextFilters.period_from))
|
||||
) {
|
||||
nextFilters.period_from = discoveryDateScope.periodFrom;
|
||||
}
|
||||
if (discoveryDateScope.periodTo && !toNonEmptyString(nextFilters.period_to)) {
|
||||
if (
|
||||
discoveryDateScope.periodTo &&
|
||||
(preferGroundedDiscoveryDateScope || !toNonEmptyString(nextFilters.period_to))
|
||||
) {
|
||||
nextFilters.period_to = discoveryDateScope.periodTo;
|
||||
delete nextFilters.as_of_date;
|
||||
}
|
||||
const inventoryRootFrame = buildInventoryRootFrameFromAddressDebug(debug, toNonEmptyString);
|
||||
const rootFilters =
|
||||
|
||||
@@ -192,6 +192,44 @@ describe("assistantContinuityPolicy organization authority", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("prefers grounded discovery date scope over stale exact-route date filters in carryover", () => {
|
||||
const debug = {
|
||||
execution_lane: "address_query",
|
||||
extracted_filters: {
|
||||
counterparty: "Группа СВК",
|
||||
period_to: "2026-04-22"
|
||||
},
|
||||
mcp_discovery_response_applied: true,
|
||||
assistant_mcp_discovery_entry_point_v1: {
|
||||
schema_version: "assistant_mcp_discovery_runtime_entry_point_v1",
|
||||
entry_status: "bridge_executed",
|
||||
turn_input: {
|
||||
turn_meaning_ref: {
|
||||
asked_action_family: "payout",
|
||||
explicit_entity_candidates: ["Группа СВК"],
|
||||
explicit_date_scope: "2020"
|
||||
}
|
||||
},
|
||||
bridge: {
|
||||
bridge_status: "answer_draft_ready",
|
||||
business_fact_answer_allowed: true,
|
||||
pilot: {
|
||||
pilot_scope: "counterparty_supplier_payout_query_movements_v1"
|
||||
},
|
||||
answer_draft: {
|
||||
answer_mode: "confirmed_with_bounded_inference"
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
expect(resolveAddressDebugCarryoverFilters(debug)).toEqual({
|
||||
counterparty: "Группа СВК",
|
||||
period_from: "2020-01-01",
|
||||
period_to: "2020-12-31"
|
||||
});
|
||||
});
|
||||
|
||||
it("prefers the resolved entity from grounded entity-resolution discovery for counterparty carryover", () => {
|
||||
const debug = {
|
||||
execution_lane: "living_chat",
|
||||
|
||||
Reference in New Issue
Block a user