From 94310ccc2f56be3ce451d8188bda732e9ec54f3b Mon Sep 17 00:00:00 2001 From: Brad Stein Date: Mon, 30 Mar 2026 03:53:42 -0300 Subject: [PATCH] ai: return mode-specific timeout guidance when atlasbot misses SLA --- backend/atlas_portal/routes/ai.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/backend/atlas_portal/routes/ai.py b/backend/atlas_portal/routes/ai.py index c695d65..b534a61 100644 --- a/backend/atlas_portal/routes/ai.py +++ b/backend/atlas_portal/routes/ai.py @@ -36,9 +36,23 @@ def register(app) -> None: elapsed_ms = int((time.time() - started) * 1000) return jsonify({"reply": reply, "latency_ms": elapsed_ms, "source": source}) elapsed_ms = int((time.time() - started) * 1000) + if mode == "quick": + budget = max(1, int(round(settings.AI_ATLASBOT_TIMEOUT_QUICK_SEC))) + fallback = ( + f"Quick mode hit {budget}s response budget before finishing. " + "Try atlas-smart for a deeper answer." + ) + elif mode == "smart": + budget = max(1, int(round(settings.AI_ATLASBOT_TIMEOUT_SMART_SEC))) + fallback = ( + f"Smart mode hit {budget}s response budget before finishing. " + "Try atlas-genius or ask a narrower follow-up." + ) + else: + fallback = "Atlas genius mode timed out before it could finish. Please retry with a narrower prompt." return jsonify( { - "reply": "Atlasbot is busy. Please try again in a moment.", + "reply": fallback, "latency_ms": elapsed_ms, "source": source, }