> ## Documentation Index
> Fetch the complete documentation index at: https://docs2.openclaw.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# 重試政策

## 目標

* 針對每個 HTTP 請求重試，而非針對多步驟流程重試。
* 僅重試目前步驟，以保留順序。
* 避免重複執行非冪等操作。

## 預設值

| 設定            | 預設值       |
| ------------- | --------- |
| 嘗試次數          | 3         |
| 最大延遲上限        | 30000 ms  |
| 抖動            | 0.1 (10%) |
| Telegram 最短延遲 | 400 ms    |
| Discord 最短延遲  | 500 ms    |

## 行為

### 模型供應商

* OpenClaw 讓供應商 SDK 處理一般的短暫重試。
* 對於 Anthropic 和 OpenAI 等以 Stainless 為基礎的 SDK，可重試的回應（`408`、`409`、`429` 和 `5xx`）可能包含 `retry-after-ms` 或 `retry-after`。當該等待時間超過 60 秒時，OpenClaw 會注入 `x-should-retry: false`，讓 SDK 立即回報錯誤，使模型容錯移轉能切換至其他驗證設定檔或備援模型。
* 使用 `OPENCLAW_SDK_RETRY_MAX_WAIT_SECONDS=<seconds>` 覆寫上限。將其設為 `0`、`false`、`off`、`none` 或 `disabled`，即可讓 SDK 在內部遵循長時間的 `Retry-After` 休眠。

### Discord

* 遇到速率限制錯誤（HTTP 429）、請求逾時、HTTP 5xx 回應，以及 DNS 查詢失敗、連線重設、通訊端關閉和擷取失敗等暫時性傳輸失敗時會重試。
* 可用時使用 Discord `retry_after`，否則採用指數退避。

### Telegram

* 遇到暫時性錯誤（429、逾時、連線失敗／重設／關閉、暫時無法使用）時會重試。
* 可用時使用 `retry_after`，否則採用指數退避。
* HTML／Markdown 剖析錯誤不會重試；第一次嘗試時即改用純文字。

## 設定

在 `~/.openclaw/openclaw.json` 中為各供應商設定重試政策：

```json5 theme={"theme":{"light":"min-light","dark":"min-dark"}}
{
  channels: {
    telegram: {
      retry: {
        attempts: 3,
        minDelayMs: 400,
        maxDelayMs: 30000,
        jitter: 0.1,
      },
    },
    discord: {
      retry: {
        attempts: 3,
        minDelayMs: 500,
        maxDelayMs: 30000,
        jitter: 0.1,
      },
    },
  },
}
```

## 注意事項

* 重試會套用至每個請求（傳送訊息、上傳媒體、新增回應、投票、貼圖）。
* 複合流程不會重試已完成的步驟。

## 相關內容

* [模型容錯移轉](/zh-TW/concepts/model-failover)
* [命令佇列](/zh-TW/concepts/queue)
