Очистить память ассистента от ролевых фрагментов контрагентов

This commit is contained in:
2026-06-15 18:57:11 +03:00
parent 1507ca2bb9
commit bbb3620956
6 changed files with 204 additions and 8 deletions
@@ -105,6 +105,68 @@ describe("address navigation state", () => {
expect(evolved.session_context.date_scope.period_to).toBe("2020-12-31");
});
it("does not store broad money role wording as a counterparty focus object", () => {
const base = createEmptyAddressNavigationState("asst-bo-money", "2026-04-12T10:00:00.000Z");
const organization = 'ООО "Альтернатива Плюс"';
const assistantItem = {
message_id: "msg-bo-money",
session_id: "asst-bo-money",
role: "assistant",
text:
"По компании ООО \"Альтернатива Плюс\" за 2020 получили 47 628 853,03 руб.; крупнейший небанковский входящий контрагент: Группа СВК.",
reply_type: "partial_coverage",
created_at: "2026-04-12T10:11:00.000Z",
trace_id: "address-bo-money",
debug: {
detected_mode: "address_query",
detected_intent: "unknown",
selected_recipe: null,
extracted_filters: {
counterparty: "и главный поставщик в",
organization,
period_from: "2020-01-01",
period_to: "2020-12-31"
},
anchor_type: "unknown",
mcp_discovery_response_applied: true,
mcp_discovery_selected_chain_id: "business_overview",
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_domain_family: "business_overview",
asked_action_family: "broad_evaluation",
explicit_organization_scope: organization,
explicit_date_scope: "2020"
},
data_need_graph: {
business_fact_family: "business_overview",
subject_candidates: []
}
},
bridge: {
bridge_status: "answer_draft_ready",
answer_draft: {
answer_mode: "confirmed_with_bounded_inference"
}
}
},
dialog_continuation_contract_v2: {
decision: "continue_previous"
}
}
} as any;
const evolved = evolveAddressNavigationStateWithAssistantItem(base, assistantItem, 2);
expect(evolved.result_sets[0]?.filters.counterparty).toBeUndefined();
expect(evolved.result_sets[0]?.filters.organization).toBe(organization);
expect(evolved.session_context.active_focus_object?.object_type).toBe("organization");
expect(evolved.session_context.active_focus_object?.label).toBe(organization);
expect(evolved.navigation_history[0]?.target_object_id).toBe(`organization:${organization}`.toLowerCase());
});
it("captures counterparty focus from applied discovery turns even when the response stayed in chat mode", () => {
const base = createEmptyAddressNavigationState("asst-vf", "2026-04-12T10:00:00.000Z");
const assistantItem = {
@@ -150,6 +150,33 @@ describe("assistantContinuityPolicy organization authority", () => {
});
});
it("does not expose broad money role fragments as counterparty carryover", () => {
const debug = {
execution_lane: "address_query",
detected_intent: "business_overview",
extracted_filters: {
counterparty: "и главный поставщик в",
organization: 'ООО "Альтернатива Плюс"',
period_from: "2020-01-01",
period_to: "2020-12-31"
},
anchor_type: "counterparty",
anchor_value_raw: "и главный поставщик в",
anchor_value_resolved: "и главный поставщик в"
};
expect(readAddressDebugCounterparty(debug)).toBeNull();
expect(resolveAddressDebugCarryoverFilters(debug)).toEqual({
organization: 'ООО "Альтернатива Плюс"',
period_from: "2020-01-01",
period_to: "2020-12-31"
});
expect(resolveAddressDebugAnchorContext(debug)).toEqual({
anchorType: "counterparty",
anchorValue: null
});
});
it("hydrates intent and carryover filters from grounded MCP discovery payout scope", () => {
const debug = {
execution_lane: "living_chat",