fix(agents): cap exec reviewer timeout · openclaw/openclaw@c536bd6
steipete
·
2026-05-30
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | import { describe, expect, it, vi } from "vitest"; |
2 | | -import { createModelExecAutoReviewer, parseExecAutoReviewResponse } from "./exec-auto-reviewer.js"; |
| 2 | +import { MAX_TIMER_TIMEOUT_MS } from "../shared/number-coercion.js"; |
| 3 | +import { |
| 4 | +createModelExecAutoReviewer, |
| 5 | +parseExecAutoReviewResponse, |
| 6 | +resolveExecReviewerTimeoutMs, |
| 7 | +} from "./exec-auto-reviewer.js"; |
3 | 8 | |
4 | 9 | const input = { |
5 | 10 | command: "git status", |
@@ -304,6 +309,12 @@ describe("createModelExecAutoReviewer", () => {
|
304 | 309 | } |
305 | 310 | }); |
306 | 311 | |
| 312 | +it("caps oversized reviewer timeouts before scheduling timers", () => { |
| 313 | +expect(resolveExecReviewerTimeoutMs({ timeoutMs: Number.MAX_SAFE_INTEGER })).toBe( |
| 314 | +MAX_TIMER_TIMEOUT_MS, |
| 315 | +); |
| 316 | +}); |
| 317 | + |
307 | 318 | it("gives reviewer completion a fresh timeout after slow model preparation", async () => { |
308 | 319 | vi.useFakeTimers(); |
309 | 320 | try { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -8,6 +8,7 @@ import {
|
8 | 8 | type ExecAutoReviewInput, |
9 | 9 | type ExecAutoReviewer, |
10 | 10 | } from "../infra/exec-auto-review.js"; |
| 11 | +import { resolveTimerTimeoutMs } from "../shared/number-coercion.js"; |
11 | 12 | import { normalizeOptionalString } from "../shared/string-coerce.js"; |
12 | 13 | import { DEFAULT_EXEC_REVIEWER_SYSTEM_PROMPT } from "./exec-auto-reviewer.prompt.js"; |
13 | 14 | import { |
@@ -186,10 +187,8 @@ function resolveReviewerModelRef(config?: ExecReviewerConfig): string | undefine
|
186 | 187 | return coerceToolModelConfig(config?.model).primary; |
187 | 188 | } |
188 | 189 | |
189 | | -function resolveReviewerTimeoutMs(config?: ExecReviewerConfig): number { |
190 | | -return typeof config?.timeoutMs === "number" && Number.isFinite(config.timeoutMs) |
191 | | - ? Math.max(1_000, Math.floor(config.timeoutMs)) |
192 | | - : DEFAULT_EXEC_REVIEWER_TIMEOUT_MS; |
| 190 | +export function resolveExecReviewerTimeoutMs(config?: ExecReviewerConfig): number { |
| 191 | +return resolveTimerTimeoutMs(config?.timeoutMs, DEFAULT_EXEC_REVIEWER_TIMEOUT_MS, 1_000); |
193 | 192 | } |
194 | 193 | |
195 | 194 | function buildReviewerTimeoutDecision(timeoutMs: number): ExecAutoReviewDecision { |
@@ -240,7 +239,7 @@ export function createModelExecAutoReviewer(params: {
|
240 | 239 | params.deps?.completeWithPreparedSimpleCompletionModel ?? |
241 | 240 | completeWithPreparedSimpleCompletionModel; |
242 | 241 | const modelRef = resolveReviewerModelRef(params.reviewer); |
243 | | -const timeoutMs = resolveReviewerTimeoutMs(params.reviewer); |
| 242 | +const timeoutMs = resolveExecReviewerTimeoutMs(params.reviewer); |
244 | 243 | return async (input) => { |
245 | 244 | let completionController: AbortController | undefined; |
246 | 245 | try { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。