Протянуть 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
@@ -16,7 +16,7 @@ export interface AssistantMcpDiscoveryResponseCandidateContract {
schema_version: typeof ASSISTANT_MCP_DISCOVERY_RESPONSE_CANDIDATE_SCHEMA_VERSION;
policy_owner: "assistantMcpDiscoveryResponseCandidate";
candidate_status: AssistantMcpDiscoveryResponseCandidateStatus;
hot_runtime_wired: false;
hot_runtime_wired: boolean;
reply_type: "partial_coverage" | "clarification_required" | "no_grounded_answer";
reply_text: string | null;
eligible_for_future_hot_runtime: boolean;
@@ -1334,6 +1334,17 @@ function statusFrom(entryPoint: AssistantMcpDiscoveryRuntimeEntryPointContract |
return "not_applicable";
}
function hasGuardedHotHandoff(entryPoint: AssistantMcpDiscoveryRuntimeEntryPointContract | null): boolean {
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: AssistantMcpDiscoveryResponseCandidateStatus
): AssistantMcpDiscoveryResponseCandidateContract["reply_type"] {
@@ -1384,9 +1395,15 @@ export function buildAssistantMcpDiscoveryResponseCandidate(
): AssistantMcpDiscoveryResponseCandidateContract {
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")
@@ -1397,11 +1414,12 @@ export function buildAssistantMcpDiscoveryResponseCandidate(
schema_version: 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"),
Boolean(replyText) &&
(status === "ready_for_guarded_use" || status === "checked_sources_only_candidate" || status === "clarification_candidate"),
must_keep_internal_mechanics_hidden: true,
reason_codes: reasonCodes
};
@@ -910,6 +910,9 @@ export function applyAssistantMcpDiscoveryResponsePolicy(
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");
}
@@ -99,7 +99,7 @@ export interface AssistantMcpDiscoveryRuntimeBridgeContract {
schema_version: typeof ASSISTANT_MCP_DISCOVERY_RUNTIME_BRIDGE_SCHEMA_VERSION;
policy_owner: "assistantMcpDiscoveryRuntimeBridge";
bridge_status: AssistantMcpDiscoveryRuntimeBridgeStatus;
hot_runtime_wired: false;
hot_runtime_wired: boolean;
planner: AssistantMcpDiscoveryPlannerContract;
pilot: AssistantMcpDiscoveryPilotExecutionContract;
answer_draft: AssistantMcpDiscoveryAnswerDraftContract;
@@ -445,7 +445,7 @@ export async function runAssistantMcpDiscoveryRuntimeBridge(
schema_version: 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,
@@ -26,7 +26,7 @@ export interface AssistantMcpDiscoveryRuntimeEntryPointContract {
schema_version: typeof ASSISTANT_MCP_DISCOVERY_RUNTIME_ENTRY_POINT_SCHEMA_VERSION;
policy_owner: "assistantMcpDiscoveryRuntimeEntryPoint";
entry_status: AssistantMcpDiscoveryRuntimeEntryPointStatus;
hot_runtime_wired: false;
hot_runtime_wired: boolean;
discovery_attempted: boolean;
turn_input: AssistantMcpDiscoveryTurnInputContract;
bridge: AssistantMcpDiscoveryRuntimeBridgeContract | null;
@@ -108,13 +108,18 @@ export async function runAssistantMcpDiscoveryRuntimeEntryPoint(
});
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: 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,