Протянуть hot handoff в discovery response

This commit is contained in:
2026-05-22 19:33:02 +03:00
parent 5125c747d8
commit e7603a9d29
10 changed files with 111 additions and 16 deletions
@@ -1109,6 +1109,14 @@ function statusFrom(entryPoint) {
}
return "not_applicable";
}
function hasGuardedHotHandoff(entryPoint) {
const bridge = toRecordObject(entryPoint?.bridge);
const handoff = toRecordObject(bridge?.execution_handoff);
return (entryPoint?.hot_runtime_wired === true &&
bridge?.hot_runtime_wired === true &&
handoff?.can_use_guarded_response === true &&
handoff?.must_keep_internal_mechanics_hidden === true);
}
function replyTypeFor(status) {
if (status === "clarification_candidate") {
return "clarification_required";
@@ -1149,9 +1157,12 @@ function buildReplyText(entryPoint, status) {
function buildAssistantMcpDiscoveryResponseCandidate(entryPoint) {
const entry = entryPoint ?? null;
const status = statusFrom(entry);
const guardedHotHandoff = hasGuardedHotHandoff(entry);
const reasonCodes = uniqueStrings(entry?.reason_codes ?? []);
pushReason(reasonCodes, `mcp_discovery_response_candidate_${status}`);
pushReason(reasonCodes, "mcp_discovery_response_candidate_not_hot_wired");
pushReason(reasonCodes, guardedHotHandoff
? "mcp_discovery_response_candidate_guarded_hot_wired"
: "mcp_discovery_response_candidate_not_hot_wired");
const replyText = entry && (status === "ready_for_guarded_use" || status === "checked_sources_only_candidate" || status === "clarification_candidate")
? buildReplyText(entry, status)
: null;
@@ -1159,10 +1170,11 @@ function buildAssistantMcpDiscoveryResponseCandidate(entryPoint) {
schema_version: exports.ASSISTANT_MCP_DISCOVERY_RESPONSE_CANDIDATE_SCHEMA_VERSION,
policy_owner: "assistantMcpDiscoveryResponseCandidate",
candidate_status: replyText ? status : status === "clarification_candidate" ? status : status,
hot_runtime_wired: false,
hot_runtime_wired: guardedHotHandoff,
reply_type: replyTypeFor(status),
reply_text: replyText,
eligible_for_future_hot_runtime: Boolean(replyText) && (status === "ready_for_guarded_use" || status === "checked_sources_only_candidate" || status === "clarification_candidate"),
eligible_for_future_hot_runtime: Boolean(replyText) &&
(status === "ready_for_guarded_use" || status === "checked_sources_only_candidate" || status === "clarification_candidate"),
must_keep_internal_mechanics_hidden: true,
reason_codes: reasonCodes
};
@@ -675,6 +675,9 @@ function applyAssistantMcpDiscoveryResponsePolicy(input) {
if (!candidate.eligible_for_future_hot_runtime) {
pushReason(reasonCodes, "mcp_discovery_response_policy_candidate_not_eligible");
}
if (candidate.hot_runtime_wired) {
pushReason(reasonCodes, "mcp_discovery_response_policy_candidate_guarded_hot_wired");
}
if (!toNonEmptyString(candidate.reply_text)) {
pushReason(reasonCodes, "mcp_discovery_response_policy_candidate_missing_reply_text");
}
@@ -283,7 +283,7 @@ async function runAssistantMcpDiscoveryRuntimeBridge(input) {
schema_version: exports.ASSISTANT_MCP_DISCOVERY_RUNTIME_BRIDGE_SCHEMA_VERSION,
policy_owner: "assistantMcpDiscoveryRuntimeBridge",
bridge_status: bridgeStatus,
hot_runtime_wired: false,
hot_runtime_wired: executionHandoff.can_use_guarded_response,
planner,
pilot,
answer_draft: answerDraft,
@@ -69,12 +69,14 @@ async function runAssistantMcpDiscoveryRuntimeEntryPoint(input) {
});
const reasonCodes = uniqueStrings([...turnInput.reason_codes, ...bridge.reason_codes]);
pushReason(reasonCodes, "runtime_entry_point_bridge_executed");
pushReason(reasonCodes, "runtime_entry_point_not_wired_to_hot_assistant_answer");
pushReason(reasonCodes, bridge.hot_runtime_wired
? "runtime_entry_point_wired_to_guarded_hot_assistant_answer"
: "runtime_entry_point_not_wired_to_hot_assistant_answer");
return {
schema_version: exports.ASSISTANT_MCP_DISCOVERY_RUNTIME_ENTRY_POINT_SCHEMA_VERSION,
policy_owner: "assistantMcpDiscoveryRuntimeEntryPoint",
entry_status: "bridge_executed",
hot_runtime_wired: false,
hot_runtime_wired: bridge.hot_runtime_wired,
discovery_attempted: true,
turn_input: turnInput,
bridge,