atlasbot: force hotspot namespace reply

This commit is contained in:
Brad Stein 2026-02-02 13:44:57 -03:00
parent a74e5e9fad
commit a166a94003

View File

@ -682,6 +682,29 @@ class AnswerEngine:
else:
reply = f"From the latest snapshot: {ns_line}."
# do not fall through to other overrides
if ("hotspot" in lowered_q or "hottest" in lowered_q) and "namespace" in lowered_q and "node_namespaces_top:" not in reply:
hotspot_node = None
match = re.search(r"(titan-[a-z0-9]+)", reply)
if match:
hotspot_node = match.group(1)
if not hotspot_node:
for fact in metric_facts:
match = re.search(r"hottest_\w+_node: (?P<node>[^\s\[]+)", fact)
if match:
hotspot_node = match.group("node")
break
if hotspot_node:
node_line = next(
(line for line in summary_lines if line.startswith("node_namespaces_top:") and f"{hotspot_node} " in line),
None,
)
if not node_line:
node_line = next(
(line for line in summary_lines if line.startswith("node_pods_top:") and hotspot_node in line),
None,
)
if node_line:
reply = f"Hotspot node: {hotspot_node}. {node_line}."
if classify.get("question_type") in {"metric", "diagnostic"}:
lowered_q = f"{question} {normalized}".lower()