ARCH: проверить и расширить gate ответа MCP discovery
This commit is contained in:
+14
-2
@@ -65,18 +65,30 @@ function isUnsupportedCurrentTurnBoundary(input) {
|
||||
input.livingChatSource === "deterministic_unsupported_current_turn_boundary" ||
|
||||
input.currentReplySource === "deterministic_unsupported_current_turn_boundary");
|
||||
}
|
||||
function isDiscoveryReadyChatCandidate(input, entryPoint) {
|
||||
const turnInput = toRecordObject(entryPoint?.turn_input);
|
||||
return (entryPoint?.entry_status === "bridge_executed" &&
|
||||
entryPoint.discovery_attempted === true &&
|
||||
turnInput?.should_run_discovery === true &&
|
||||
(input.livingChatSource === "llm_chat" || input.currentReplySource === "llm_chat"));
|
||||
}
|
||||
function applyAssistantMcpDiscoveryResponsePolicy(input) {
|
||||
const currentReply = String(input.currentReply ?? "");
|
||||
const currentReplySource = toNonEmptyString(input.currentReplySource) ?? toNonEmptyString(input.livingChatSource) ?? "unknown";
|
||||
const entryPoint = resolveEntryPoint(input);
|
||||
const candidate = (0, assistantMcpDiscoveryResponseCandidate_1.buildAssistantMcpDiscoveryResponseCandidate)(entryPoint);
|
||||
const reasonCodes = [...candidate.reason_codes];
|
||||
const unsupportedBoundary = isUnsupportedCurrentTurnBoundary(input);
|
||||
const discoveryReadyChatCandidate = isDiscoveryReadyChatCandidate(input, entryPoint);
|
||||
if (!entryPoint) {
|
||||
pushReason(reasonCodes, "mcp_discovery_response_policy_no_entry_point");
|
||||
}
|
||||
if (!isUnsupportedCurrentTurnBoundary(input)) {
|
||||
if (!unsupportedBoundary) {
|
||||
pushReason(reasonCodes, "mcp_discovery_response_policy_not_unsupported_boundary");
|
||||
}
|
||||
if (!discoveryReadyChatCandidate) {
|
||||
pushReason(reasonCodes, "mcp_discovery_response_policy_not_discovery_ready_chat_candidate");
|
||||
}
|
||||
if (!ALLOWED_CANDIDATE_STATUSES.has(candidate.candidate_status)) {
|
||||
pushReason(reasonCodes, "mcp_discovery_response_policy_candidate_status_not_allowed");
|
||||
}
|
||||
@@ -90,7 +102,7 @@ function applyAssistantMcpDiscoveryResponsePolicy(input) {
|
||||
pushReason(reasonCodes, "mcp_discovery_response_policy_candidate_contains_internal_mechanics");
|
||||
}
|
||||
const canApply = Boolean(entryPoint) &&
|
||||
isUnsupportedCurrentTurnBoundary(input) &&
|
||||
(unsupportedBoundary || discoveryReadyChatCandidate) &&
|
||||
ALLOWED_CANDIDATE_STATUSES.has(candidate.candidate_status) &&
|
||||
candidate.eligible_for_future_hot_runtime &&
|
||||
Boolean(toNonEmptyString(candidate.reply_text)) &&
|
||||
|
||||
Reference in New Issue
Block a user