fix(aiops-p2): P2.1 LLM品質三修 — Evidence-First + consensus confidence + raw_evidence注入
Some checks failed
CD Pipeline / build-and-deploy (push) Has been cancelled
Some checks failed
CD Pipeline / build-and-deploy (push) Has been cancelled
根因: - consensus_engine 四 ExpertAgent confidence=0.0 → 加權投票 total=0 → 永遠返回 NO_ACTION - prompts.py 無 Evidence-First 指令 → LLM 靠記憶推理,無真實環境約束 - openclaw.py analyze_alert 建 prompt 未注入 MCP evidence (diagnosis_context) 修復: - consensus_engine: SRE/Security/Cost/Performance 依訊號強度設 0.45~0.80 confidence - consensus_engine: _normalize_action 加「重新啟動」別名 → RESTART - consensus_engine: SecurityAgent 移除未使用的 _target 變數 - prompts.py: 加 Evidence-First Protocol + Skepticism Rules 區塊 - openclaw.py: analyze_alert 提取 diagnosis_context → <raw_evidence> 注入 full_prompt 驗證: consensus score 從 0.0 → 0.744(CrashLoop 測試案例) P2.1 fix 2026-04-24 ogt + Claude Sonnet 4.6 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1360,19 +1360,26 @@ Trace URL: {signoz_trace_url}
|
||||
else "\n\n## ⚠️ 無法取得叢集清單,target_resource 請依 alertname 推斷,勿編造。\n"
|
||||
)
|
||||
|
||||
# P2.1 fix 2026-04-24 ogt + Claude Sonnet 4.6: 提取 MCP evidence_summary 注入 prompt
|
||||
# diagnosis_context 由 decision_manager 在呼叫前填入(pre_decision_investigator 產出)
|
||||
_raw_evidence = alert_context.get("diagnosis_context", "") or ""
|
||||
if _raw_evidence and not _raw_evidence.startswith("<raw_evidence>"):
|
||||
_raw_evidence = f"<raw_evidence>\n{_raw_evidence}\n</raw_evidence>"
|
||||
evidence_section = f"\n\n## 🔬 MCP 實時環境證據\n{_raw_evidence}\n" if _raw_evidence else ""
|
||||
|
||||
# 格式化告警為 Prompt (2026-03-31 ogt: 強力截斷以符合 NVIDIA 4K 限制)
|
||||
# 優先保留 System Prompt,截斷 Alert Data
|
||||
available_len = 3500 - len(OPENCLAW_SYSTEM_PROMPT) - len(signoz_context) - len(k8s_section)
|
||||
available_len = 3500 - len(OPENCLAW_SYSTEM_PROMPT) - len(signoz_context) - len(k8s_section) - len(evidence_section)
|
||||
if available_len < 500:
|
||||
# 如果 SignOz 太長,也截斷它
|
||||
signoz_context = signoz_context[:500] + "... (truncated)"
|
||||
available_len = 3500 - len(OPENCLAW_SYSTEM_PROMPT) - len(signoz_context) - len(k8s_section)
|
||||
available_len = 3500 - len(OPENCLAW_SYSTEM_PROMPT) - len(signoz_context) - len(k8s_section) - len(evidence_section)
|
||||
|
||||
alert_json = json.dumps(alert_context, ensure_ascii=False, indent=2)
|
||||
if len(alert_json) > available_len:
|
||||
alert_json = alert_json[:available_len] + "... (truncated)"
|
||||
|
||||
full_prompt = OPENCLAW_SYSTEM_PROMPT + signoz_context + k8s_section + "\n\n## Alert Data:\n" + alert_json
|
||||
full_prompt = OPENCLAW_SYSTEM_PROMPT + signoz_context + k8s_section + evidence_section + "\n\n## Alert Data:\n" + alert_json
|
||||
|
||||
logger.info(
|
||||
"openclaw_alert_analysis_start",
|
||||
|
||||
Reference in New Issue
Block a user