Skip to content

Commit cb8782e

Browse files
committed
fix(timeout): 重试递增的上限从 900s 提到 3600s
900s 上限对 CLI / ollama 长任务偏紧: - CLI 默认 600s 起跳,第一次递增就封顶 (900s) - 用户 --timeout 20min (1200s) 起步已超上限,完全不延长 提到 3600s (60 min) 后: - API 默认 120s × retry 5 → 最长 15min,对 API 场景足够 - CLI 默认 600s × retry 5 → 最长 60min 封顶,覆盖长任务 - 用户 --timeout 10m 还能继续递增到 60min - 仍留失控保险,防止 retry 10 次 + 长 timeout 放飞到几十小时 - 真要超过 1 小时单步的用 timeout: 0 不限时
1 parent f322189 commit cb8782e

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

src/core/executor.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,12 +316,14 @@ async function executeStep(
316316
// timeout 策略:
317317
// - 用户显式设置(含 timeout: 0 表示不限时)→ 第一次按此值
318318
// - 未设置 → provider 默认(API 120s / CLI/ollama 600s)
319-
// - 因超时触发 retry 时,下一轮 timeout x1.5(上限 900s
319+
// - 因超时触发 retry 时,下一轮 timeout x1.5(上限 3600s / 60min
320320
// 非超时类错误(429/500/ECONNRESET 等)保持原 timeout,避免无谓放大
321+
// - 上限是防误配置放飞的保险丝(retry 10 次可能放大到几十小时),
322+
// 真要超过 1 小时单步请用 timeout: 0 / --timeout 0 完全不限时
321323
const defaultTimeout = effectiveIsCLI ? 600_000 : effectiveIsLocal ? 600_000 : 120_000;
322324
const baseTimeout = effectiveConfig.timeout !== undefined ? effectiveConfig.timeout : defaultTimeout;
323325
const effectiveMaxRetry = effectiveConfig.retry ?? opts.maxRetry;
324-
const TIMEOUT_CAP = 900_000;
326+
const TIMEOUT_CAP = 3_600_000;
325327

326328
// 带重试的 LLM 调用(timeout 在网络超时类错误重试时自动延长)
327329
let lastError: Error | null = null;

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export interface LLMConfig {
1717
model?: string; // CLI providers 可省略(使用 CLI 默认模型)
1818
agent?: string; // openclaw-cli 专用:agent ID(默认 "main")
1919
max_tokens?: number; // 默认 4096
20-
timeout?: number; // 单步超时 ms。默认 API 120000 / CLI 600000 / ollama 600000。因超时触发重试时,下一次 timeout 自动 x1.5(上限 900000)。设为 0 表示不限时
20+
timeout?: number; // 单步超时 ms。默认 API 120000 / CLI 600000 / ollama 600000。因超时触发重试时,下一次 timeout 自动 x1.5(上限 3600000 / 60min)。设为 0 表示不限时
2121
retry?: number; // 失败重试次数,默认 3
2222
}
2323

0 commit comments

Comments
 (0)