From 604d8eea372ca243bbc14e2e2d36c7e898cdc7ac Mon Sep 17 00:00:00 2001 From: OG T Date: Fri, 17 Apr 2026 22:10:18 +0800 Subject: [PATCH] =?UTF-8?q?fix(schema-drift):=20=E8=A3=9C=E9=BD=8A=20promp?= =?UTF-8?q?ts.py=20+=20Claude=20API=20schema=20enum=20=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=20(ADR-090)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 問題: fe77e6d 擴充了 models/ai.py enum 至 8 值,但兩個地方未同步: 1. core/prompts.py L77: 缺 INVESTIGATE、OBSERVE 2. core/prompts.py L176 (NEMOTRON_SYSTEM_PROMPT): 缺 APPLY_HPA、INVESTIGATE、OBSERVE 3. openclaw.py L564 (_call_claude tools schema): 舊 4 值 enum 約束 影響: LLM 不知道可以輸出 INVESTIGATE/OBSERVE,只能選舊 4 值 修復: 三處統一對齊 8 個 suggested_action 值 RESTART_DEPLOYMENT|DELETE_POD|SCALE_DEPLOYMENT|APPLY_HPA|TUNE_RESOURCES|INVESTIGATE|OBSERVE|NO_ACTION Closes: ADR-090 Prompt-Model 三層同步鐵律 2026-04-17 ogt + Claude Sonnet 4.6 Co-Authored-By: Claude Sonnet 4.6 --- apps/api/src/core/prompts.py | 4 ++-- apps/api/src/services/openclaw.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/api/src/core/prompts.py b/apps/api/src/core/prompts.py index aaf8f637..49720213 100644 --- a/apps/api/src/core/prompts.py +++ b/apps/api/src/core/prompts.py @@ -74,7 +74,7 @@ For each optimization suggestion, provide EXECUTABLE kubectl commands: { "action_title": "string - 操作標題 (繁體中文)", "description": "string - 根因分析含 SignOz 數據關聯 (繁體中文)", - "suggested_action": "RESTART_DEPLOYMENT|DELETE_POD|SCALE_DEPLOYMENT|APPLY_HPA|TUNE_RESOURCES|NO_ACTION", + "suggested_action": "RESTART_DEPLOYMENT|DELETE_POD|SCALE_DEPLOYMENT|APPLY_HPA|TUNE_RESOURCES|INVESTIGATE|OBSERVE|NO_ACTION", "kubectl_command": "string - 具體的 kubectl 指令", "target_resource": "string - 目標資源名稱", "namespace": "string - K8s namespace", @@ -173,7 +173,7 @@ Make action_title describe the ACTUAL problem (not generic "自動修復 AWOOOI "risk_level": "low|medium|critical", "action_title": "操作標題,必須反映 alertname 的實際問題 (繁體中文)", "description": "根因分析,說明 alertname 代表的問題及建議調查步驟 (繁體中文)", - "suggested_action": "RESTART_DEPLOYMENT|DELETE_POD|SCALE_DEPLOYMENT|TUNE_RESOURCES|NO_ACTION", + "suggested_action": "RESTART_DEPLOYMENT|DELETE_POD|SCALE_DEPLOYMENT|APPLY_HPA|TUNE_RESOURCES|INVESTIGATE|OBSERVE|NO_ACTION", "kubectl_command": "針對此告警類型的 kubectl 指令", "target_resource": "目標資源", "namespace": "K8s namespace", diff --git a/apps/api/src/services/openclaw.py b/apps/api/src/services/openclaw.py index 46c30859..e8f00cd1 100644 --- a/apps/api/src/services/openclaw.py +++ b/apps/api/src/services/openclaw.py @@ -561,7 +561,7 @@ class OpenClawService: "properties": { "action_title": {"type": "string"}, "description": {"type": "string"}, - "suggested_action": {"type": "string", "enum": ["RESTART_DEPLOYMENT", "DELETE_POD", "SCALE_DEPLOYMENT", "NO_ACTION"]}, + "suggested_action": {"type": "string", "enum": ["RESTART_DEPLOYMENT", "DELETE_POD", "SCALE_DEPLOYMENT", "APPLY_HPA", "TUNE_RESOURCES", "INVESTIGATE", "OBSERVE", "NO_ACTION"]}, "kubectl_command": {"type": "string"}, "target_resource": {"type": "string"}, "namespace": {"type": "string"},