atlasbot: expand hottest node facts

This commit is contained in:
Brad Stein 2026-02-01 14:06:42 -03:00
parent 85fd5fb70f
commit 6727c26ffe
2 changed files with 27 additions and 0 deletions

View File

@ -981,6 +981,28 @@ def _merge_fact_lines(primary: list[str], fallback: list[str]) -> list[str]:
return merged return merged
def _expand_hottest_line(line: str) -> list[str]:
if not line:
return []
if not line.lower().startswith("hottest:"):
return []
expanded: list[str] = []
payload = line.split("hottest:", 1)[1]
for part in payload.split(";"):
part = part.strip()
if not part or "=" not in part:
continue
metric, rest = part.split("=", 1)
metric = metric.strip()
match = re.search(r"(?P<node>[^\\s\\[]+).*\\((?P<value>[^)]+)\\)", rest)
if not match:
continue
node = match.group("node").strip()
value = match.group("value").strip()
expanded.append(f"hottest_{metric}_node: {node} ({value})")
return expanded
def _metric_candidate_lines(lines: list[str], keywords: list[str] | None, limit: int = 40) -> list[str]: def _metric_candidate_lines(lines: list[str], keywords: list[str] | None, limit: int = 40) -> list[str]:
if not lines: if not lines:
return [] return []
@ -1003,6 +1025,10 @@ def _metric_candidate_lines(lines: list[str], keywords: list[str] | None, limit:
"pressure", "pressure",
} }
candidates: list[str] = [] candidates: list[str] = []
for line in lines:
if line.lower().startswith("hottest:"):
candidates.extend(_expand_hottest_line(line))
break
for line in lines: for line in lines:
line_lower = line.lower() line_lower = line.lower()
if line_lower.startswith("lexicon_") or line_lower.startswith("units:"): if line_lower.startswith("lexicon_") or line_lower.startswith("units:"):

View File

@ -216,6 +216,7 @@ FACT_SELECT_SYSTEM = (
FACT_SELECT_PROMPT = ( FACT_SELECT_PROMPT = (
"Pick up to {max_lines} lines from Candidates that best answer the question. " "Pick up to {max_lines} lines from Candidates that best answer the question. "
"If the question asks for highest/hottest and Candidates include a line starting with 'hottest:', you must include that line. " "If the question asks for highest/hottest and Candidates include a line starting with 'hottest:', you must include that line. "
"If Candidates include hottest_*_node lines, prefer those for node hottest questions. "
"If the question mentions nodes and a 'hottest:' line exists, prefer node-level facts over pod-level lines. " "If the question mentions nodes and a 'hottest:' line exists, prefer node-level facts over pod-level lines. "
"Avoid pod_* lines unless the question explicitly mentions pods. " "Avoid pod_* lines unless the question explicitly mentions pods. "
"Exclude lexicon/definition lines; choose lines with concrete numeric values. " "Exclude lexicon/definition lines; choose lines with concrete numeric values. "