From 8b2a3df64b1ed18d0f5d3208cf0e78adf6466ccf Mon Sep 17 00:00:00 2001 From: OG T Date: Thu, 16 Apr 2026 18:42:05 +0800 Subject: [PATCH] =?UTF-8?q?fix(telegram):=20=E4=BF=AE=E5=BE=A9=20Telegram?= =?UTF-8?q?=20=E5=8D=A1=E7=89=87=20description=20=E9=A1=AF=E7=A4=BA=20debu?= =?UTF-8?q?g=20garbage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 問題:description = debate_summary[:500],用戶看到的是內部審計文字 修復:從 diagnosis.top_hypothesis + action_plan.top_candidate 組出人類可讀摘要 格式:「根因:[描述](信心 X%);方案:[動作]」 Co-Authored-By: Claude Sonnet 4.6 --- apps/api/src/services/decision_manager.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/apps/api/src/services/decision_manager.py b/apps/api/src/services/decision_manager.py index 20eb19e82..9d2154cc9 100644 --- a/apps/api/src/services/decision_manager.py +++ b/apps/api/src/services/decision_manager.py @@ -983,16 +983,31 @@ def _package_to_proposal_data(package: Any) -> dict[str, Any]: else: risk_level = "high" + # 組出人類可讀的 description(Telegram 卡片顯示用) + # 2026-04-16 ogt + Claude Sonnet 4.6: 修復 description=debate_summary garbage + diag = getattr(package, "diagnosis", None) + plan = getattr(package, "action_plan", None) + desc_parts = [] + if diag and getattr(diag, "top_hypothesis", None): + h = diag.top_hypothesis + desc_parts.append(f"根因:{h.description[:150]}(信心 {h.confidence:.0%})") + if plan and getattr(plan, "top_candidate", None): + c = plan.top_candidate + desc_parts.append(f"方案:{c.action[:100]}") + if package.blocked_reason: + desc_parts.append(f"備注:{package.blocked_reason[:100]}") + description = ";".join(desc_parts) if desc_parts else (action[:200] if action else "待分析") + return { "action": action, "kubectl_command": action if action.startswith("kubectl") else "", - "description": package.debate_summary[:500] if package.debate_summary else "", + "description": description, "reasoning": package.debate_summary[:1000] if package.debate_summary else "", "confidence": confidence, "risk_level": risk_level, "source": "phase2_agent_debate", "requires_human_review": package.requires_human_approval, - # Phase 2 診斷摘要(供 Telegram 卡片顯示) + # Phase 2 診斷摘要(供 Audit Trail / 學習閉環,不直接顯示給用戶) "debate_summary": package.debate_summary or "", "all_agents_degraded": package.all_agents_degraded, "blocked_reason": package.blocked_reason or "",