From 36596b51cbc6dcf278a60ea4a2fde20ab57583df Mon Sep 17 00:00:00 2001 From: Brad Stein Date: Mon, 2 Feb 2026 12:08:55 -0300 Subject: [PATCH] fix: clean hotspot replies and hide helper tags --- atlasbot/engine/answerer.py | 12 +++++++----- atlasbot/llm/prompts.py | 3 ++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/atlasbot/engine/answerer.py b/atlasbot/engine/answerer.py index 9116f09..f6c9ec0 100644 --- a/atlasbot/engine/answerer.py +++ b/atlasbot/engine/answerer.py @@ -288,6 +288,7 @@ class AnswerEngine: key_facts = _key_fact_lines(summary_lines, keyword_tokens) hottest_facts = _extract_hottest_facts(summary_lines, f"{question} {normalized}") hardware_facts = _extract_hardware_usage_facts(summary_lines, f"{question} {normalized}") + hotspot_line = next((line for line in summary_lines if line.startswith("hottest:")), None) if not hardware_facts: hardware_tokens = ("hardware", "class", "type", "rpi", "jetson", "amd64", "arm64") lowered_q = f"{question} {normalized}".lower() @@ -368,11 +369,9 @@ class AnswerEngine: if pressure_lines: metric_facts = pressure_lines[:2] key_facts = _merge_fact_lines(metric_facts, key_facts) - if hotspot_request: - hottest_line = next((line for line in summary_lines if line.startswith("hottest:")), None) - if hottest_line: - metric_facts = [hottest_line] - key_facts = _merge_fact_lines(metric_facts, key_facts) + if hotspot_request and hotspot_line: + metric_facts = [hotspot_line] + key_facts = _merge_fact_lines(metric_facts, key_facts) if self._settings.debug_pipeline: scored_preview = sorted( [{"id": c["id"], "score": scored.get(c["id"], 0.0), "summary": c["summary"]} for c in chunks], @@ -560,6 +559,9 @@ class AnswerEngine: if note: reply = f"{reply}\n\n{note}" + if hotspot_request and hotspot_line: + reply = f"Current hotspots: {hotspot_line}." + if classify.get("question_type") in {"metric", "diagnostic"} and metric_facts: reply = _metric_fact_guard(reply, metric_facts, keyword_tokens) diff --git a/atlasbot/llm/prompts.py b/atlasbot/llm/prompts.py index fcd536a..174e6d7 100644 --- a/atlasbot/llm/prompts.py +++ b/atlasbot/llm/prompts.py @@ -5,7 +5,8 @@ CLUSTER_SYSTEM = ( "If a fact is not in context, say you do not know. " "Be conversational and grounded. " "Avoid commands unless the user asks for them. " - "Do not mention the context or knowledge base unless asked." + "Do not mention the context or knowledge base unless asked. " + "Never repeat helper tags or scaffolding labels (e.g., MustUseFacts, AllowedNodes, AllowedNamespaces, KeyFacts, ClusterSnapshot, SnapshotSummary)." ) NORMALIZE_SYSTEM = (