fix(drift-narrator): shortener 用 replace — 包容 LLM 加 'Resource/Name:' 前綴幻覺
All checks were successful
CD Pipeline / build-and-deploy (push) Successful in 10m50s
All checks were successful
CD Pipeline / build-and-deploy (push) Successful in 10m50s
2026-04-18 下午(台北時區)— ogt + Claude Opus 4.7 Round 4 LLM 自己在 field 前加資源識別符: 'Deployment/awoooi-web: spec.template.spec.containers' 導致 startswith 模式 shortener 失效(前綴不在開頭)。 防禦式修法: startswith 不中 → 改用 replace 清除任何位置的前綴。 結果: 'Deployment/awoooi-web: containers' ✅ Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -580,13 +580,22 @@ class DriftNarratorService:
|
||||
def _shorten_field_path(self, field: str) -> str:
|
||||
"""
|
||||
砍掉常見冗長前綴,讓 Telegram 排版不換行
|
||||
spec.template.spec.volumes → volumes
|
||||
spec.template.metadata.labels → metadata.labels
|
||||
spec.internalTrafficPolicy → internalTrafficPolicy
|
||||
|
||||
處理 2 種場景:
|
||||
A. 開頭即前綴: 'spec.template.spec.volumes' → 'volumes'
|
||||
B. LLM 雞婆加資源識別符: 'Deployment/awoooi-web: spec.template.spec.containers'
|
||||
→ 'Deployment/awoooi-web: containers'
|
||||
|
||||
用 replace 比 startswith 更有韌性,包容 LLM 前綴幻覺。
|
||||
"""
|
||||
# 先移除 absolute prefix(若開頭)
|
||||
for prefix in ("spec.template.spec.", "spec.template.", "spec."):
|
||||
if field.startswith(prefix):
|
||||
return field[len(prefix):]
|
||||
# 中間出現(LLM 加 'Resource/Name: spec.template.spec.xxx' 場景)
|
||||
for prefix in ("spec.template.spec.", "spec.template."):
|
||||
if prefix in field:
|
||||
return field.replace(prefix, "")
|
||||
return field
|
||||
|
||||
def _render_telegram_body(
|
||||
|
||||
Reference in New Issue
Block a user