From be82109d4e43af3cd80e3137fe623e29d3b91d1f Mon Sep 17 00:00:00 2001 From: Brad Stein Date: Wed, 28 Jan 2026 03:17:46 -0300 Subject: [PATCH] atlasbot: enforce fast answer body --- services/comms/scripts/atlasbot/bot.py | 28 ++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/services/comms/scripts/atlasbot/bot.py b/services/comms/scripts/atlasbot/bot.py index 43f578b..7d47423 100644 --- a/services/comms/scripts/atlasbot/bot.py +++ b/services/comms/scripts/atlasbot/bot.py @@ -2926,6 +2926,7 @@ def _open_ended_system() -> str: "If the question asks for a list, embed the list inline in a sentence (comma-separated). " "If the question is ambiguous, pick a reasonable interpretation and state it briefly. " "Avoid repeating the exact same observation as the last response if possible; vary across metrics, workload, or hardware details. " + "Always include at least one substantive answer sentence before the score lines. " "When the fact pack includes hottest_cpu/ram/net/io lines, use them to answer hottest/busiest node questions. " "When the fact pack includes postgres_hottest_db, use it for questions about the busiest database. " "Do not invent numbers or facts. " @@ -3801,6 +3802,24 @@ def _fast_fact_lines( return selected +def _has_body_lines(answer: str) -> bool: + lines = [line.strip() for line in (answer or "").splitlines() if line.strip()] + for line in lines: + lowered = line.lower() + if lowered.startswith("confidence"): + continue + if lowered.startswith("relevance"): + continue + if lowered.startswith("satisfaction"): + continue + if lowered.startswith("hallucinationrisk"): + continue + if lowered.startswith("hallucination risk"): + continue + return True + return False + + def _open_ended_fast_single( prompt: str, *, @@ -3818,6 +3837,15 @@ def _open_ended_fast_single( system_override=_open_ended_system(), model=model, ) + if not _has_body_lines(reply): + reply = _ollama_call( + ("atlasbot_fast", "atlasbot_fast"), + prompt + " Provide one clear sentence before the score lines.", + context=context, + use_history=False, + system_override=_open_ended_system(), + model=model, + ) if state: state.update("done", step=_open_ended_total_steps("fast")) return _ensure_scores(reply)