專業化資源壓力告警語意
Some checks failed
CD Pipeline / deploy (push) Has been cancelled

This commit is contained in:
OoO
2026-05-19 22:40:19 +08:00
parent 0fc96837f4
commit 2e5ff091fa
3 changed files with 52 additions and 8 deletions

View File

@@ -87,7 +87,7 @@ _TRIGGER_ZH = {
"price_drop_alert": "價格下滑警報",
"market_opportunity": "市場機會偵測",
"threat_escalation": "威脅升級通報",
"resource_optimization": "資源調配優化",
"resource_optimization": "資源壓力治理",
"code_exception": "程式碼異常偵測",
"weekly_insight": "全景電商洞察分析",
}
@@ -1087,21 +1087,21 @@ class ElephantAlphaAutonomousEngine:
if metrics.get("load_pressure")
else "主機 CPU 未達高負載門檻,這不是主機資源耗盡,而是工作隊列/人工審核積壓。"
)
executed = [
handling_notes = [
f"已寫入 ai_insights(resource_pressure) #{insight_id}"
if insight_id
else "ai_insights(resource_pressure) 寫入未取得 id請查看 scheduler log。"
]
if new_limit != previous_limit:
executed.append(f"已將 ElephantAlpha 自主決策上限由 {previous_limit} 調整為 {new_limit} 次/小時。")
handling_notes.append(f"已將 ElephantAlpha 自主決策上限由 {previous_limit} 調整為 {new_limit} 次/小時。")
if hygiene_count > 0:
by_source = hygiene.get("by_source") or {}
source_text = "".join(f"{key} {value}" for key, value in by_source.items()) or f"{hygiene_count}"
executed.insert(
handling_notes.insert(
1,
f"已自動關閉過期 action_plans {hygiene_count} 筆({source_text});只改 status/metadata不刪除資料。",
)
executed.append("未執行外部修復、未啟動 Hermes/NemoTron 價格分析、未宣稱效益預測。")
handling_notes.append("邊界:未執行外部修復、未啟動 Hermes/NemoTron 價格分析、未宣稱效益預測。")
lines = [
"<b>Elephant Alpha · 資源壓力告警</b>",
@@ -1130,8 +1130,8 @@ class ElephantAlphaAutonomousEngine:
f"{escape(load_judgement)}",
"• 這則告警只採用 action_plans 與 CPU 實測值,不採用 LLM 生成的 48 小時效益預測。",
"",
"<b>已執行</b>",
*[f"{escape(item)}" for item in executed],
"<b>系統處置紀錄</b>",
*[f"{escape(item)}" for item in handling_notes],
"",
"<b>建議下一步</b>",
*[f"{escape(item)}" for item in ElephantAlphaAutonomousEngine._build_resource_pressure_actions(metrics)],
@@ -1456,6 +1456,12 @@ class ElephantAlphaAutonomousEngine:
decision: StrategicDecision,
trigger: AutonomousTrigger,
) -> None:
if trigger.trigger_type == "resource_optimization":
self._log.warning(
"Suppressed legacy autonomous execution Telegram template for resource_optimization; "
"resource pressure alerts must use the measurement-based template."
)
return
try:
from services.telegram_templates import _send_telegram_raw