From 97fa07ed983596723e496345440b0d5a70957ebb Mon Sep 17 00:00:00 2001 From: Brad Stein Date: Sun, 1 Feb 2026 11:54:27 -0300 Subject: [PATCH] atlasbot: tighten metric candidates --- atlasbot/engine/answerer.py | 27 +++++++++++++++++++++++---- atlasbot/llm/prompts.py | 1 + 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/atlasbot/engine/answerer.py b/atlasbot/engine/answerer.py index 263805f..e9c33c4 100644 --- a/atlasbot/engine/answerer.py +++ b/atlasbot/engine/answerer.py @@ -982,16 +982,35 @@ def _metric_candidate_lines(lines: list[str], keywords: list[str] | None, limit: if not lines: return [] lowered = [kw.lower() for kw in (keywords or []) if kw] + metric_tokens = { + "cpu", + "ram", + "memory", + "net", + "network", + "io", + "disk", + "load", + "usage", + "utilization", + "hottest", + "p95", + "percent", + "pressure", + } candidates: list[str] = [] for line in lines: line_lower = line.lower() + if "hottest:" in line_lower: + candidates.append(line) + continue if lowered and any(kw in line_lower for kw in lowered): candidates.append(line) - elif re.search(r"\d", line): + continue + if any(token in line_lower for token in metric_tokens) and re.search(r"\d", line_lower): candidates.append(line) - if len(candidates) >= limit: - break - return candidates + continue + return candidates[:limit] async def _select_metric_facts( diff --git a/atlasbot/llm/prompts.py b/atlasbot/llm/prompts.py index 5aebf5c..caf7a54 100644 --- a/atlasbot/llm/prompts.py +++ b/atlasbot/llm/prompts.py @@ -215,6 +215,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:', prefer that line. " "Return JSON with field: lines (list of strings). If none apply, return {\"lines\": []}." )