Planner Autonomy: скрыть внутренние MCP-ошибки в checked-source ответах
This commit is contained in:
+27
-3
@@ -35,7 +35,12 @@ function formatNamedChoiceList(values) {
|
||||
}
|
||||
function isInternalMechanicsLine(value) {
|
||||
const text = value.toLowerCase();
|
||||
return (text.includes("primitive") ||
|
||||
return (text.includes("mcp fetch failed") ||
|
||||
text.includes("this operation was aborted") ||
|
||||
text.includes("entity-resolution") ||
|
||||
text.includes("could not continue") ||
|
||||
text.includes("checked catalog search step") ||
|
||||
text.includes("primitive") ||
|
||||
text.includes("query_documents") ||
|
||||
text.includes("query_movements") ||
|
||||
text.includes("resolve_entity_reference") ||
|
||||
@@ -50,6 +55,12 @@ function isInternalMechanicsLine(value) {
|
||||
text.includes("needs more scope before execution") ||
|
||||
text.includes("mcp_execution_performed"));
|
||||
}
|
||||
function isMcpTransportFailureLine(value) {
|
||||
const text = value.toLowerCase();
|
||||
return (text.includes("mcp fetch failed") ||
|
||||
text.includes("this operation was aborted") ||
|
||||
text.includes("operation was aborted"));
|
||||
}
|
||||
function userFacingUnknowns(values) {
|
||||
return uniqueStrings(values).filter((value) => !isInternalMechanicsLine(value));
|
||||
}
|
||||
@@ -62,7 +73,20 @@ function rankedValueFlowUnknownLines(pilot) {
|
||||
return [`Полный рейтинг контрагентов вне ${period} этим поиском не подтвержден.`];
|
||||
}
|
||||
function userFacingLimitations(values) {
|
||||
return uniqueStrings(values).filter((value) => !isInternalMechanicsLine(value));
|
||||
const result = [];
|
||||
for (const value of uniqueStrings(values)) {
|
||||
if (isMcpTransportFailureLine(value)) {
|
||||
const line = "Доступ к 1С во время проверки оборвался; подтвержденные строки не получены.";
|
||||
if (!result.includes(line)) {
|
||||
result.push(line);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (!isInternalMechanicsLine(value)) {
|
||||
result.push(value);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function modeFor(pilot) {
|
||||
if (pilot.pilot_status === "blocked") {
|
||||
@@ -452,7 +476,7 @@ function nextStepFor(mode, pilot) {
|
||||
}
|
||||
}
|
||||
if (mode === "checked_sources_only" && pilot.query_limitations.length > 0) {
|
||||
return "Можно повторить проверку после восстановления MCP-доступа или сузить вопрос до конкретного контрагента/периода.";
|
||||
return "Можно повторить проверку после восстановления доступа к 1С или сузить вопрос до конкретного контрагента/периода.";
|
||||
}
|
||||
if (mode === "blocked") {
|
||||
return "Нужно сначала снять policy/blocking причину, иначе данные 1С использовать нельзя.";
|
||||
|
||||
+6
-1
@@ -48,7 +48,12 @@ function uniqueStrings(values) {
|
||||
}
|
||||
function hasInternalMechanics(value) {
|
||||
const text = value.toLowerCase();
|
||||
return (text.includes("query_documents") ||
|
||||
return (text.includes("mcp fetch failed") ||
|
||||
text.includes("this operation was aborted") ||
|
||||
text.includes("entity-resolution") ||
|
||||
text.includes("could not continue") ||
|
||||
text.includes("checked catalog search step") ||
|
||||
text.includes("query_documents") ||
|
||||
text.includes("query_movements") ||
|
||||
text.includes("primitive") ||
|
||||
text.includes("pilot_") ||
|
||||
|
||||
+6
-1
@@ -38,7 +38,12 @@ function pushReason(target, value) {
|
||||
}
|
||||
function hasInternalMechanics(value) {
|
||||
const text = value.toLowerCase();
|
||||
return (text.includes("query_documents") ||
|
||||
return (text.includes("mcp fetch failed") ||
|
||||
text.includes("this operation was aborted") ||
|
||||
text.includes("entity-resolution") ||
|
||||
text.includes("could not continue") ||
|
||||
text.includes("checked catalog search step") ||
|
||||
text.includes("query_documents") ||
|
||||
text.includes("query_movements") ||
|
||||
text.includes("primitive") ||
|
||||
text.includes("pilot_") ||
|
||||
|
||||
@@ -62,6 +62,11 @@ function formatNamedChoiceList(values: string[]): string {
|
||||
function isInternalMechanicsLine(value: string): boolean {
|
||||
const text = value.toLowerCase();
|
||||
return (
|
||||
text.includes("mcp fetch failed") ||
|
||||
text.includes("this operation was aborted") ||
|
||||
text.includes("entity-resolution") ||
|
||||
text.includes("could not continue") ||
|
||||
text.includes("checked catalog search step") ||
|
||||
text.includes("primitive") ||
|
||||
text.includes("query_documents") ||
|
||||
text.includes("query_movements") ||
|
||||
@@ -79,6 +84,15 @@ function isInternalMechanicsLine(value: string): boolean {
|
||||
);
|
||||
}
|
||||
|
||||
function isMcpTransportFailureLine(value: string): boolean {
|
||||
const text = value.toLowerCase();
|
||||
return (
|
||||
text.includes("mcp fetch failed") ||
|
||||
text.includes("this operation was aborted") ||
|
||||
text.includes("operation was aborted")
|
||||
);
|
||||
}
|
||||
|
||||
function userFacingUnknowns(values: string[]): string[] {
|
||||
return uniqueStrings(values).filter((value) => !isInternalMechanicsLine(value));
|
||||
}
|
||||
@@ -93,7 +107,20 @@ function rankedValueFlowUnknownLines(pilot: AssistantMcpDiscoveryPilotExecutionC
|
||||
}
|
||||
|
||||
function userFacingLimitations(values: string[]): string[] {
|
||||
return uniqueStrings(values).filter((value) => !isInternalMechanicsLine(value));
|
||||
const result: string[] = [];
|
||||
for (const value of uniqueStrings(values)) {
|
||||
if (isMcpTransportFailureLine(value)) {
|
||||
const line = "Доступ к 1С во время проверки оборвался; подтвержденные строки не получены.";
|
||||
if (!result.includes(line)) {
|
||||
result.push(line);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (!isInternalMechanicsLine(value)) {
|
||||
result.push(value);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function modeFor(pilot: AssistantMcpDiscoveryPilotExecutionContract): AssistantMcpDiscoveryAnswerMode {
|
||||
@@ -554,7 +581,7 @@ function nextStepFor(mode: AssistantMcpDiscoveryAnswerMode, pilot: AssistantMcpD
|
||||
}
|
||||
}
|
||||
if (mode === "checked_sources_only" && pilot.query_limitations.length > 0) {
|
||||
return "Можно повторить проверку после восстановления MCP-доступа или сузить вопрос до конкретного контрагента/периода.";
|
||||
return "Можно повторить проверку после восстановления доступа к 1С или сузить вопрос до конкретного контрагента/периода.";
|
||||
}
|
||||
if (mode === "blocked") {
|
||||
return "Нужно сначала снять policy/blocking причину, иначе данные 1С использовать нельзя.";
|
||||
|
||||
@@ -75,6 +75,11 @@ function uniqueStrings(values: string[]): string[] {
|
||||
function hasInternalMechanics(value: string): boolean {
|
||||
const text = value.toLowerCase();
|
||||
return (
|
||||
text.includes("mcp fetch failed") ||
|
||||
text.includes("this operation was aborted") ||
|
||||
text.includes("entity-resolution") ||
|
||||
text.includes("could not continue") ||
|
||||
text.includes("checked catalog search step") ||
|
||||
text.includes("query_documents") ||
|
||||
text.includes("query_movements") ||
|
||||
text.includes("primitive") ||
|
||||
|
||||
@@ -71,6 +71,11 @@ function pushReason(target: string[], value: string): void {
|
||||
function hasInternalMechanics(value: string): boolean {
|
||||
const text = value.toLowerCase();
|
||||
return (
|
||||
text.includes("mcp fetch failed") ||
|
||||
text.includes("this operation was aborted") ||
|
||||
text.includes("entity-resolution") ||
|
||||
text.includes("could not continue") ||
|
||||
text.includes("checked catalog search step") ||
|
||||
text.includes("query_documents") ||
|
||||
text.includes("query_movements") ||
|
||||
text.includes("primitive") ||
|
||||
|
||||
@@ -110,8 +110,10 @@ describe("assistant MCP discovery answer adapter", () => {
|
||||
|
||||
expect(draft.answer_mode).toBe("checked_sources_only");
|
||||
expect(draft.confirmed_lines).toEqual([]);
|
||||
expect(draft.limitation_lines).toContain("MCP fetch failed: timeout");
|
||||
expect(draft.next_step_line).toContain("MCP");
|
||||
expect(draft.limitation_lines).toContain("Доступ к 1С во время проверки оборвался; подтвержденные строки не получены.");
|
||||
expect(draft.limitation_lines).not.toContain("MCP fetch failed: timeout");
|
||||
expect(draft.next_step_line).toContain("доступа к 1С");
|
||||
expect(draft.next_step_line).not.toContain("MCP");
|
||||
expect(draft.must_not_claim).toContain("Do not claim a confirmed business fact when confirmed_facts is empty.");
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user