From 182410a9950627c04236343e0eeb01e68d09fa7f Mon Sep 17 00:00:00 2001 From: OG T Date: Mon, 23 Mar 2026 14:28:40 +0800 Subject: [PATCH] docs(skills): Add Chinese action parsing lesson to Skill 03 Record the 2026-03-23 incident where Y button failed because LLM generated Chinese action strings that couldn't be parsed Co-Authored-By: Claude Opus 4.5 --- .../skills/03-openclaw-cognitive-expert.md | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/.agents/skills/03-openclaw-cognitive-expert.md b/.agents/skills/03-openclaw-cognitive-expert.md index 27d2f631..decc2840 100644 --- a/.agents/skills/03-openclaw-cognitive-expert.md +++ b/.agents/skills/03-openclaw-cognitive-expert.md @@ -197,6 +197,44 @@ def validate_namespace(command: str) -> bool: --- +## 🚨 中文 Action 解析 (2026-03-23 教訓) + +> **事故**: Y 按鈕執行後顯示「錯誤」,因為 LLM 生成中文建議,`parse_operation_from_action()` 無法解析 + +### 根因 + +```json +{"event": "background_execution_skip", "reason": "Could not parse operation type from action"} +{"action": "擴展 awoooi-api-deployment 副本數 + 啟用 HPA"} +{"action": "重新啟動 postgres-primary-0 服務"} +``` + +### 支援的中文模式 + +| 中文關鍵字 | 操作類型 | 備註 | +|-----------|---------|------| +| 擴展...副本數 | SCALE_DEPLOYMENT | 自動移除 `-deployment` 後綴 | +| 重新啟動 | RESTART_DEPLOYMENT | 不需要「服務」後綴 | +| StatefulSet Pod (xxx-0) | DELETE_POD | 自動識別 `-N` 格式 | + +### 驗證指令 + +```bash +# 查看目前支援的解析模式 +grep -n "chinese" apps/api/src/api/v1/approvals.py + +# 檢查 Action 解析函數 +grep -A 5 "def parse_operation_from_action" apps/api/src/api/v1/approvals.py +``` + +### 教訓 + +1. **LLM 輸出不可預測**: 生成的建議可能是中文、英文或混合 +2. **後綴可能錯誤**: LLM 常加 `-deployment` 後綴,需自動清理 +3. **資源類型識別**: `xxx-0` 是 StatefulSet Pod,應使用 DELETE_POD 而非 RESTART_DEPLOYMENT + +--- + ## 參考文檔 - `apps/api/src/services/incident_engine.py`: 聚合引擎