From 387eea1399e52ddf6298572c6750f644799b88a8 Mon Sep 17 00:00:00 2001 From: Brad Stein Date: Sun, 1 Feb 2026 05:17:53 -0300 Subject: [PATCH] atlasbot: enforce metric facts --- atlasbot/engine/answerer.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/atlasbot/engine/answerer.py b/atlasbot/engine/answerer.py index 29efcb2..50673c0 100644 --- a/atlasbot/engine/answerer.py +++ b/atlasbot/engine/answerer.py @@ -405,7 +405,7 @@ class AnswerEngine: model=plan.model, tag="focus_fix", ) - if classify.get("question_type") in {"metric", "diagnostic"} and metric_facts and not re.search(r"\\d", reply): + if classify.get("question_type") in {"metric", "diagnostic"} and metric_facts: best_line = None lowered_keywords = [kw.lower() for kw in keyword_tokens if kw] for line in metric_facts: @@ -414,7 +414,10 @@ class AnswerEngine: best_line = line break best_line = best_line or metric_facts[0] - reply = f"From the latest snapshot: {best_line}." + reply_numbers = set(re.findall(r"\\d+(?:\\.\\d+)?", reply)) + fact_numbers = set(re.findall(r"\\d+(?:\\.\\d+)?", " ".join(metric_facts))) + if not reply_numbers or (fact_numbers and not (reply_numbers & fact_numbers)): + reply = f"From the latest snapshot: {best_line}." if plan.use_critic: if observer: