OG T
fb88512fcb
CD Pipeline / build-and-deploy (push) Has been cancelled
fix(drift-narrator): B 方案 LLM 驅動智能摘要 — 徹底消滅 str()[:30] 暴力截斷
2026-04-18 下午(台北時區)—— ogt + Claude Opus 4.7 (1M)
根因:
_format_drift_summary() 對 dict/list 型別的 git_value/actual_value
直接呼叫 str()[:30] 暴力截斷,產生像 "[{'name': 'repair-ssh-key', 's"
這種亂碼掉半個 dict key 的亂七八糟輸出,徹底違背「AI 自主化」原則。
B 方案架構決策:
「捨棄 Python 寫死的字串解析邏輯。將原始 Config Diff 結構直接作為
Context,餵給 Hermes/NemoTron,利用 prompt 規定輸出格式,讓 LLM 自己
消化並輸出包含紅黃燈標示的 Top 5 人類易讀摘要。」
實作:
1. _NARRATIVE_PROMPT 重寫 — 要求 LLM 回傳 {narrative, items[]} JSON
- drift items 以 JSON serialize 餵進 prompt(保留 200 字 context)
- items 限 5 筆,HIGH 優先
- summary 30 字繁中口語(非技術 repr)
2. _generate_narrative_and_items() 新方法 — 解析 LLM JSON 並驗證結構
3. _format_drift_for_llm() 新方法 — 結構化 JSON 給 LLM(取代舊 str 版)
4. _render_telegram_body() 新方法 — 組裝乾淨的 Telegram 卡片
範例輸出:
🤖 AI 研判
<LLM 4-5 行敘述>
📊 漂移明細 (HIGH: 1 | MEDIUM: 29)
🔴 spec.template.spec.volumes: 新增 2 項 repair-ssh-key 掛載
🟡 spec.template.spec.serviceAccount: (未設) → awoooi-executor
... 還有 27 項 (按 🔍 查看 Diff)
5. Fallback 強化 — _smart_shorten() + _fallback_items()
LLM 失敗時用型別感知的 Python 摘要(dict/list 顯示大小,不暴力 repr)
移除:
- _format_drift_summary() — 舊的暴力截斷實作
- _generate_narrative() — 只回 string 的舊介面
保留:
- _fallback_narrative() / _format_intent_summary() — 仍有用
- Redis 快取 / trigger 條件 / DB update — 邏輯不變
MVP 階段:
本 commit 只改視覺呈現,沒動 automation_operation_log / ai_collaboration_trace
稽核寫入。等 Telegram 視覺驗證 OK 後再做 Phase 2 加入 DB 稽核。
相關:
- feedback_ai_autonomous_direction.md 北極星原則
- 1ff3405 今早的 JSON 裸奔 hotfix(只修了 narrative,沒修 items)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-18 15:54:16 +08:00
..
2026-03-25 16:08:49 +08:00
2026-04-09 15:05:16 +08:00
2026-03-25 09:26:58 +08:00
2026-03-28 18:51:52 +08:00
2026-04-16 02:54:34 +08:00
2026-03-26 16:06:20 +08:00
2026-04-03 13:22:36 +08:00
2026-04-03 13:22:36 +08:00
2026-04-16 00:03:04 +08:00
2026-04-15 18:56:26 +08:00
2026-04-12 22:50:20 +08:00
2026-04-14 14:39:14 +08:00
2026-04-16 22:57:50 +08:00
2026-04-15 19:21:21 +08:00
2026-04-16 20:07:15 +08:00
2026-04-17 23:08:23 +08:00
2026-03-31 16:25:00 +08:00
2026-04-17 15:23:35 +08:00
2026-04-09 12:26:18 +08:00
2026-04-15 16:06:54 +08:00
2026-04-14 20:34:14 +08:00
2026-04-14 20:43:40 +08:00
2026-04-10 22:35:37 +08:00
2026-03-29 16:00:46 +08:00
2026-03-26 15:32:52 +08:00
2026-03-29 15:57:04 +08:00
2026-03-23 23:51:37 +08:00
2026-04-17 23:08:23 +08:00
2026-04-15 16:06:54 +08:00
2026-03-26 21:55:50 +08:00
2026-04-05 00:39:29 +08:00
2026-04-04 12:35:05 +08:00
2026-04-16 20:50:06 +08:00
2026-04-17 10:27:39 +08:00
2026-04-18 15:54:16 +08:00
2026-04-05 00:22:38 +08:00
2026-03-22 18:57:44 +08:00
2026-04-15 15:34:33 +08:00
2026-04-11 20:45:53 +08:00
2026-03-29 16:00:46 +08:00
2026-04-16 16:26:07 +08:00
2026-04-09 19:10:27 +08:00
2026-04-16 20:50:06 +08:00
2026-04-15 20:57:43 +08:00
2026-04-16 01:42:14 +08:00
2026-04-15 20:05:49 +08:00
2026-03-31 16:06:35 +08:00
2026-04-15 16:06:54 +08:00
2026-04-01 11:11:50 +08:00
2026-03-24 12:57:36 +08:00
2026-03-31 16:06:35 +08:00
2026-04-15 19:51:01 +08:00
2026-04-09 23:36:36 +08:00
2026-04-07 11:17:40 +08:00
2026-04-11 20:45:53 +08:00
2026-03-26 19:25:52 +08:00
2026-03-31 22:47:54 +08:00
2026-03-31 22:47:54 +08:00
2026-04-15 22:28:48 +08:00
2026-03-29 22:17:27 +08:00
2026-03-31 11:23:38 +08:00
2026-03-26 21:55:50 +08:00
2026-04-12 17:52:57 +08:00
2026-04-16 08:54:11 +08:00
2026-04-10 10:43:53 +08:00
2026-04-11 20:45:53 +08:00
2026-04-02 09:02:41 +08:00
2026-04-17 16:14:44 +08:00
2026-04-11 20:45:53 +08:00
2026-04-15 15:34:33 +08:00
2026-04-11 20:45:53 +08:00
2026-04-15 13:08:38 +08:00
2026-03-26 10:01:57 +08:00
2026-04-09 10:52:40 +08:00
2026-04-15 22:29:09 +08:00
2026-03-26 12:49:30 +08:00
2026-04-09 14:55:04 +08:00
2026-03-31 16:06:35 +08:00
2026-04-18 00:53:27 +08:00
2026-04-06 11:46:05 +08:00
2026-04-10 11:35:10 +08:00
2026-04-15 21:09:01 +08:00
2026-04-04 12:02:03 +08:00
2026-04-15 23:49:56 +08:00
2026-04-14 15:19:54 +08:00
2026-04-15 13:08:38 +08:00
2026-04-16 20:50:06 +08:00
2026-04-08 16:36:18 +08:00
2026-04-15 15:47:05 +08:00
2026-04-09 18:34:50 +08:00
2026-03-26 16:03:16 +08:00
2026-04-14 18:46:25 +08:00
2026-03-29 16:00:46 +08:00
2026-04-15 16:06:54 +08:00
2026-04-16 02:46:17 +08:00
2026-04-15 13:08:38 +08:00
2026-04-05 13:40:52 +08:00
2026-03-29 15:27:49 +08:00
2026-04-01 16:20:57 +08:00
2026-04-08 21:47:38 +08:00
2026-04-16 15:35:19 +08:00
2026-03-26 15:32:52 +08:00
2026-03-29 15:27:49 +08:00
2026-04-17 14:42:29 +08:00
2026-03-30 01:52:59 +08:00
2026-03-24 09:20:56 +08:00
2026-03-26 16:06:20 +08:00
2026-04-15 15:47:05 +08:00
2026-04-15 18:56:26 +08:00
2026-04-17 16:14:44 +08:00
2026-04-08 16:36:18 +08:00
2026-04-07 13:02:20 +08:00