From 2c7490288da2ada97f497d4430e47275315cd47e Mon Sep 17 00:00:00 2001 From: Brad Stein Date: Tue, 3 Feb 2026 15:01:23 -0300 Subject: [PATCH] evidence: inject hardware context --- atlasbot/engine/answerer.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/atlasbot/engine/answerer.py b/atlasbot/engine/answerer.py index 9ccf1d8..2acc480 100644 --- a/atlasbot/engine/answerer.py +++ b/atlasbot/engine/answerer.py @@ -477,6 +477,10 @@ class AnswerEngine: runbook_fix = _needs_runbook_fix(reply, runbook_paths) runbook_needed = _needs_runbook_reference(normalized, runbook_paths, reply) needs_evidence = _needs_evidence_fix(reply, classify) + hardware_terms = ("rpi", "raspberry", "jetson", "amd64", "arm64", "hardware") + hardware_line = _line_starting_with(summary_lines, "hardware_nodes:") + if any(term in lowered_question for term in hardware_terms) and hardware_line: + needs_evidence = True if classify.get("question_type") in {"open_ended", "planning"} and metric_facts: needs_evidence = True resolved_runbook = None @@ -507,6 +511,8 @@ class AnswerEngine: extra_bits.append("ResolvedRunbook: " + resolved_runbook) if metric_facts: extra_bits.append("MustUseFacts: " + "; ".join(metric_facts[:4])) + if hardware_line: + extra_bits.append("HardwareNodes: " + hardware_line) if allowed_nodes: extra_bits.append("AllowedNodes: " + ", ".join(allowed_nodes)) if allowed_namespaces: @@ -1623,6 +1629,16 @@ def _best_keyword_line(lines: list[str], keywords: list[str]) -> str | None: return best if best_score > 0 else None +def _line_starting_with(lines: list[str], prefix: str) -> str | None: + if not lines or not prefix: + return None + lower_prefix = prefix.lower() + for line in lines: + if str(line).lower().startswith(lower_prefix): + return line + return None + + def _lexicon_context(summary: dict[str, Any]) -> str: # noqa: C901 if not isinstance(summary, dict): return ""