diff --git a/atlasbot/engine/answerer.py b/atlasbot/engine/answerer.py index a9e6e85..a35e58e 100644 --- a/atlasbot/engine/answerer.py +++ b/atlasbot/engine/answerer.py @@ -329,11 +329,23 @@ class AnswerEngine: metric_facts = hottest_facts key_facts = _merge_fact_lines(metric_facts, key_facts) if "namespace" in lowered_q and any(term in lowered_q for term in ("hotspot", "hot spot", "hottest")): - for line in summary_lines: - if line.startswith("node_pods_top:"): - metric_facts = _merge_fact_lines([line], metric_facts) - key_facts = _merge_fact_lines([line], key_facts) - break + hotspot_node = None + if hottest_facts: + match = re.search(r"hottest_\w+_node: (?P[^\s\[]+)", hottest_facts[0]) + if match: + hotspot_node = match.group("node") + if hotspot_node: + for line in summary_lines: + if line.startswith("node_namespaces_top:") and f"{hotspot_node} " in line: + metric_facts = _merge_fact_lines([line], metric_facts) + key_facts = _merge_fact_lines([line], key_facts) + break + if not hotspot_node or not any(line.startswith("node_namespaces_top:") for line in metric_facts): + for line in summary_lines: + if line.startswith("node_pods_top:"): + metric_facts = _merge_fact_lines([line], metric_facts) + key_facts = _merge_fact_lines([line], key_facts) + break if classify.get("question_type") in {"metric", "diagnostic"} and not hottest_facts and not hardware_facts: metric_candidates = _metric_candidate_lines(summary_lines, keyword_tokens) selected_facts = await _select_metric_facts(call_llm, normalized, metric_candidates, plan) diff --git a/atlasbot/snapshot/builder.py b/atlasbot/snapshot/builder.py index c31b972..7340919 100644 --- a/atlasbot/snapshot/builder.py +++ b/atlasbot/snapshot/builder.py @@ -828,6 +828,13 @@ def _append_node_pods(lines: list[str], summary: dict[str, Any]) -> None: if ns_label: label = f"{label} ({ns_label})" lines.append("node_pods_max: " + label) + for item in top: + node = item.get("node") + namespaces = item.get("namespaces_top") or [] + if not node or not namespaces: + continue + ns_label = ", ".join([f"{name}={count}" for name, count in namespaces]) + lines.append(f"node_namespaces_top: {node} ({ns_label})") def _append_pod_issues(lines: list[str], summary: dict[str, Any]) -> None: