From 6727c26ffe6894f398b2b8985caee8305255b126 Mon Sep 17 00:00:00 2001 From: Brad Stein Date: Sun, 1 Feb 2026 14:06:42 -0300 Subject: [PATCH] atlasbot: expand hottest node facts --- atlasbot/engine/answerer.py | 26 ++++++++++++++++++++++++++ atlasbot/llm/prompts.py | 1 + 2 files changed, 27 insertions(+) diff --git a/atlasbot/engine/answerer.py b/atlasbot/engine/answerer.py index e557f7a..229e07e 100644 --- a/atlasbot/engine/answerer.py +++ b/atlasbot/engine/answerer.py @@ -981,6 +981,28 @@ def _merge_fact_lines(primary: list[str], fallback: list[str]) -> list[str]: 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[^\\s\\[]+).*\\((?P[^)]+)\\)", 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]: if not lines: return [] @@ -1003,6 +1025,10 @@ def _metric_candidate_lines(lines: list[str], keywords: list[str] | None, limit: "pressure", } candidates: list[str] = [] + for line in lines: + if line.lower().startswith("hottest:"): + candidates.extend(_expand_hottest_line(line)) + break for line in lines: line_lower = line.lower() if line_lower.startswith("lexicon_") or line_lower.startswith("units:"): diff --git a/atlasbot/llm/prompts.py b/atlasbot/llm/prompts.py index 590c915..c469f39 100644 --- a/atlasbot/llm/prompts.py +++ b/atlasbot/llm/prompts.py @@ -216,6 +216,7 @@ FACT_SELECT_SYSTEM = ( FACT_SELECT_PROMPT = ( "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 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. " "Avoid pod_* lines unless the question explicitly mentions pods. " "Exclude lexicon/definition lines; choose lines with concrete numeric values. "