From 2eb726c274046448ea152c49b46678acb4c58e91 Mon Sep 17 00:00:00 2001 From: Brad Stein Date: Sun, 1 Feb 2026 14:34:00 -0300 Subject: [PATCH] atlasbot: force hottest facts for hottest queries --- atlasbot/engine/answerer.py | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/atlasbot/engine/answerer.py b/atlasbot/engine/answerer.py index e59a327..0b936da 100644 --- a/atlasbot/engine/answerer.py +++ b/atlasbot/engine/answerer.py @@ -266,8 +266,12 @@ class AnswerEngine: scored = await _score_chunks(call_llm, chunks, normalized, sub_questions, plan) selected = _select_chunks(chunks, scored, plan, keyword_tokens) key_facts = _key_fact_lines(summary_lines, keyword_tokens) + hottest_facts = _extract_hottest_facts(summary_lines, normalized) metric_facts = [line for line in key_facts if re.search(r"\d", line)] - if classify.get("question_type") in {"metric", "diagnostic"}: + if hottest_facts: + metric_facts = hottest_facts + key_facts = _merge_fact_lines(metric_facts, key_facts) + if classify.get("question_type") in {"metric", "diagnostic"} and not hottest_facts: metric_candidates = _metric_candidate_lines(summary_lines, keyword_tokens) selected_facts = await _select_metric_facts(call_llm, normalized, metric_candidates, plan) if selected_facts: @@ -1008,6 +1012,34 @@ def _expand_hottest_line(line: str) -> list[str]: return expanded +def _extract_hottest_facts(lines: list[str], question: str) -> list[str]: + if not lines: + return [] + lowered = question.lower() + if not any(term in lowered for term in ("hottest", "highest", "lowest", "most")): + return [] + line = next((item for item in lines if item.lower().startswith("hottest:")), "") + if not line: + return [] + facts = _expand_hottest_line(line) + if not facts: + return [] + wanted = [] + if any(term in lowered for term in ("cpu", "processor")): + wanted.append("hottest_cpu_node") + if any(term in lowered for term in ("ram", "memory")): + wanted.append("hottest_ram_node") + if any(term in lowered for term in ("net", "network", "throughput")): + wanted.append("hottest_net_node") + if "io" in lowered or "i/o" in lowered: + wanted.append("hottest_io_node") + if "disk" in lowered or "storage" in lowered: + wanted.append("hottest_disk_node") + if not wanted: + return facts + return [fact for fact in facts if any(label in fact for label in wanted)] or facts + + def _metric_candidate_lines(lines: list[str], keywords: list[str] | None, limit: int = 40) -> list[str]: if not lines: return []