diff --git a/.github/scripts/agent_delegation_policy.js b/.github/scripts/agent_delegation_policy.js index 9252427f8..4396ad98f 100644 --- a/.github/scripts/agent_delegation_policy.js +++ b/.github/scripts/agent_delegation_policy.js @@ -246,6 +246,7 @@ function decideNextAgent({ reason: explicitAgent ? 'explicit-label' : 'default', shouldSwitch: false, alternatives: [], + delegationSource: 'static', }; } @@ -282,6 +283,7 @@ function decideNextAgent({ reason: 'no-agents-available', shouldSwitch: false, alternatives: [], + delegationSource: 'static', }; } @@ -294,6 +296,7 @@ function decideNextAgent({ reason: 'initial-selection', shouldSwitch: false, alternatives: availableAgents.filter((a) => a !== initialAgent), + delegationSource: 'static', }; } @@ -306,6 +309,7 @@ function decideNextAgent({ shouldSwitch: true, previousAgent: currentAgent, alternatives: availableAgents.filter((agent) => agent !== nextAgent), + delegationSource: 'static', }; } @@ -325,6 +329,7 @@ function decideNextAgent({ reason: `effective (${effectiveness.summary})`, shouldSwitch: false, alternatives: availableAgents.filter((a) => a !== currentAgent), + delegationSource: 'static', }; } @@ -335,6 +340,7 @@ function decideNextAgent({ reason: `cooldown (${5 - roundsSinceSwitch} rounds remaining)`, shouldSwitch: false, alternatives: availableAgents.filter((a) => a !== currentAgent), + delegationSource: 'static', }; } @@ -373,7 +379,7 @@ function decideNextAgent({ reason: `stalled-no-alternatives (${sourceSuffix})`, shouldSwitch: false, alternatives: [], - delegationSource: 'static', + delegationSource, }; } core?.info?.(`Switching from ${currentAgent} to ${nextAgent} due to stall (${sourceSuffix})`); diff --git a/scripts/langchain/issue_dedup.py b/scripts/langchain/issue_dedup.py index 44bf86398..a3290d1df 100755 --- a/scripts/langchain/issue_dedup.py +++ b/scripts/langchain/issue_dedup.py @@ -6,6 +6,7 @@ from __future__ import annotations import logging +import math import os from collections.abc import Iterable, Mapping from dataclasses import dataclass @@ -198,16 +199,19 @@ def find_similar_issues( min_score = _resolve_threshold(threshold) matches: list[IssueMatch] = [] for doc, raw_score in results: + float_score = float(raw_score) + if not math.isfinite(float_score): + continue metadata = getattr(doc, "metadata", {}) or {} fallback_title = getattr(doc, "page_content", None) issue = _issue_from_metadata(metadata, fallback_title) - similarity = _similarity_from_score(float(raw_score), score_type) + similarity = _similarity_from_score(float_score, score_type) if similarity >= min_score: matches.append( IssueMatch( issue=issue, score=similarity, - raw_score=float(raw_score), + raw_score=float_score, score_type=score_type, ) ) @@ -217,6 +221,9 @@ def find_similar_issues( def _format_similarity(score: float) -> str: + """Format finite scores as percentages; invalid scores provide no similarity.""" + if not math.isfinite(score): + return "0%" clamped = min(max(score, 0.0), 1.0) return f"{round(clamped * 100):d}%"