Skip to main content

Documentation Index

Fetch the complete documentation index at: https://openclaw.zhcndoc.com/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 处理正常的短重试。
  • 对于基于 Stainless 的 SDK,例如 Anthropic 和 OpenAI,可重试的响应 (4084094295xx)可以包含 retry-after-msretry-after。当该等待时间超过 60 秒时,OpenClaw 会注入 x-should-retry: false,使 SDK 立即上报错误,并且模型 故障转移可以轮换到另一个认证配置或回退模型。
  • 可通过 OPENCLAW_SDK_RETRY_MAX_WAIT_SECONDS=<seconds> 覆盖上限。 将其设置为 0falseoffnonedisabled,可让 SDK 在内部遵守较长的 Retry-After 睡眠时间。

Discord

  • 针对速率限制错误(HTTP 429)、请求超时、HTTP 5xx 响应, 以及瞬时传输故障(例如 DNS 解析失败、连接重置、 套接字关闭和 fetch 失败)进行重试。
  • 可用时使用 Discord 的 retry_after,否则使用指数退避。

Telegram

  • 对瞬时错误重试(429、timeout、connect/reset/closed、temporarily unavailable)。
  • 可用时使用 retry_after,否则使用指数退避。
  • Markdown 解析错误不会重试;它们会回退为纯文本。

配置

~/.openclaw/openclaw.json 中按提供方设置重试策略:
{
  channels: {
    telegram: {
      retry: {
        attempts: 3,
        minDelayMs: 400,
        maxDelayMs: 30000,
        jitter: 0.1,
      },
    },
    discord: {
      retry: {
        attempts: 3,
        minDelayMs: 500,
        maxDelayMs: 30000,
        jitter: 0.1,
      },
    },
  },
}

说明

  • 重试按请求生效(消息发送、媒体上传、反应、投票、贴纸)。
  • 复合流程不会重试已完成的步骤。

相关内容