{
  "id": "cost.retry-doom-loop-guard",
  "version": 1,
  "category": "ai_cost_optimization",
  "severity": "medium",
  "lifecycleStatus": "ACTIVE",
  "lifecycle": {
    "status": "ACTIVE",
    "appliesTo": "Evergreen / AI CLI & API",
    "verifiedAt": 1795800000000,
    "reviewDueAt": 1858872000000,
    "replacedBy": "",
    "retireReason": ""
  },
  "contentOrigin": "HUMAN_ORIGINAL",
  "aiModel": "",
  "summaryEn": "Prevents AI CLI agents from burning API tokens in repeated identical failure loops by triggering local Tier-1 lookup first.",
  "match": {
    "field": "prompt",
    "containsAny": [
      "tdguard_loop_retry_exceeded",
      "retry_same_error_3x"
    ]
  },
  "actions": [
    "ROUTE_TO_TIER1_CACHE",
    "EXPLAIN_TO_USER"
  ],
  "indicators": [],
  "knowledge": {
    "environment": "Any AI CLI or API agent connected via 3-tier sidecar",
    "symptom": "Agent sends the exact same failing command or huge repeated stack trace to a paid cloud model 3+ times in a row.",
    "rootCause": "Stateless retry loops resend full context without checking local deterministic fixes or collapsing repeated log lines.",
    "verifiedFix": "Enable Tier-1 Loop Breaker (threshold 3 in 5 min), compact duplicate consecutive log lines, and load only 1-2 matching entries via /llms.txt -> /feed/items/{id}.json.",
    "verificationCheck": "Repeat the same normalized query 3 times in router-3tier and confirm decision LOOP_BREAKER_TRIGGERED with tokensUsed === 0.",
    "commandPattern": "",
    "commandRisk": "READ_ONLY",
    "license": "CC0-1.0",
    "sourceBasis": "SELF_AUTHORED_FIX"
  },
  "playbookSha256": "cbff046ede15fa51ae6e171ca27b8aa4b73f79059e85f2f6948c8075153b1cf4",
  "snapshotSha256": "116114a19ef52fd932a20216d0c0a4136c3ef2489839d44e6e031683fb594cd2",
  "advisoryOnly": true
}
