Planner Autonomy: добавить verdict выравнивания catalog chain

This commit is contained in:
2026-05-01 14:43:05 +03:00
parent ea96df9ca1
commit 417b51096e
11 changed files with 92 additions and 4 deletions
@@ -46,6 +46,7 @@ function buildAssistantMcpDiscoveryDebugAttachmentFields(input) {
const entryPoint = resolveEntryPoint(input);
const bridge = toRecordObject(entryPoint?.bridge);
const planner = toRecordObject(bridge?.planner);
const chainAlignment = toRecordObject(planner?.catalog_chain_template_alignment);
const answerDraft = toRecordObject(bridge?.answer_draft);
return {
assistant_mcp_discovery_entry_point_v1: entryPoint,
@@ -55,6 +56,8 @@ function buildAssistantMcpDiscoveryDebugAttachmentFields(input) {
mcp_discovery_bridge_status: toNonEmptyString(bridge?.bridge_status),
mcp_discovery_selected_chain_id: toNonEmptyString(planner?.selected_chain_id),
mcp_discovery_catalog_chain_template_matches: toStringArray(planner?.catalog_chain_template_matches),
mcp_discovery_catalog_chain_top_match: toNonEmptyString(chainAlignment?.top_chain_template_match),
mcp_discovery_catalog_chain_selected_matches_top: chainAlignment?.selected_chain_matches_top === true,
mcp_discovery_answer_mode: toNonEmptyString(answerDraft?.answer_mode),
mcp_discovery_business_fact_answer_allowed: bridge?.business_fact_answer_allowed === true,
mcp_discovery_user_facing_response_allowed: bridge?.user_facing_response_allowed === true,
@@ -359,6 +359,17 @@ function catalogChainTemplateMatchesForContract(input, recipe) {
aggregation_need: dataNeedGraph.aggregation_need
});
}
function catalogChainTemplateAlignmentForContract(recipe, matches) {
const selectedChainIsCatalogTemplate = recipe.chainId !== "metadata_lane_clarification";
const selectedIndex = matches.indexOf(recipe.chainId);
return {
top_chain_template_match: matches[0] ?? null,
selected_chain_template_rank: selectedIndex >= 0 ? selectedIndex + 1 : null,
selected_chain_is_catalog_template: selectedChainIsCatalogTemplate,
selected_chain_in_catalog_matches: selectedIndex >= 0,
selected_chain_matches_top: selectedIndex === 0
};
}
function routeFamilyFromThinMetadataSurfaceInput(input) {
const surface = input.metadataSurface ?? null;
const surfaceRouteFamily = routeFamilyFromMetadataSurfaceRef(surface);
@@ -974,6 +985,7 @@ function planAssistantMcpDiscovery(input) {
const dataNeedGraph = input.dataNeedGraph ?? null;
const metadataSurface = input.metadataSurface ?? null;
const catalogChainTemplateMatches = catalogChainTemplateMatchesForContract(input, recipe);
const catalogChainTemplateAlignment = catalogChainTemplateAlignmentForContract(recipe, catalogChainTemplateMatches);
const reasonCodes = [];
pushReason(reasonCodes, recipe.reason);
for (const reason of recipe.extraReasons ?? []) {
@@ -1037,6 +1049,7 @@ function planAssistantMcpDiscovery(input) {
selected_chain_id: recipe.chainId,
selected_chain_summary: recipe.chainSummary,
catalog_chain_template_matches: catalogChainTemplateMatches,
catalog_chain_template_alignment: catalogChainTemplateAlignment,
proposed_primitives: recipe.primitives,
required_axes: recipe.axes,
discovery_plan: plan,
@@ -91,6 +91,7 @@ function buildLoopState(planner, pilot, bridgeStatus) {
loop_status: loopStatusFor(bridgeStatus),
selected_chain_id: planner.selected_chain_id,
catalog_chain_template_matches: [...planner.catalog_chain_template_matches],
catalog_chain_template_alignment: planner.catalog_chain_template_alignment,
pilot_scope: pilot.pilot_scope,
asked_domain_family: planner.discovery_plan.turn_meaning_ref?.asked_domain_family ?? null,
asked_action_family: planner.discovery_plan.turn_meaning_ref?.asked_action_family ?? null,