From 16f9e83657f893a8b1f22701fba06c5ee2957624 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Mon, 4 May 2026 18:09:47 -0700 Subject: [PATCH] test(live): scale gateway profile timeout --- .../gateway-models.profiles.live.test.ts | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/gateway/gateway-models.profiles.live.test.ts b/src/gateway/gateway-models.profiles.live.test.ts index 253ce4b2271..3b0c1b5953b 100644 --- a/src/gateway/gateway-models.profiles.live.test.ts +++ b/src/gateway/gateway-models.profiles.live.test.ts @@ -158,8 +158,11 @@ function resolveGatewayLiveSuiteTimeoutMs(maxModels: number): number { if (maxModels <= 0) { return GATEWAY_LIVE_UNBOUNDED_TIMEOUT_MS; } - // Gateway live runs multiple probes per model; scale timeout by model cap. - const estimated = 5 * 60 * 1000 + maxModels * 90 * 1000; + // Gateway live runs multiple probes per model and may retry with another + // profile key before moving on, so the suite budget has to scale with the + // model timeout rather than only the first prompt. + const perModelBudgetMs = Math.max(3 * 60 * 1000, GATEWAY_LIVE_MODEL_TIMEOUT_MS * 3); + const estimated = 10 * 60 * 1000 + maxModels * perModelBudgetMs; return Math.max( GATEWAY_LIVE_DEFAULT_TIMEOUT_MS, Math.min(GATEWAY_LIVE_MAX_TIMEOUT_MS, estimated), @@ -533,6 +536,20 @@ describe("resolveGatewayLiveModelTimeoutMs", () => { }); }); +describe("resolveGatewayLiveSuiteTimeoutMs", () => { + it("leaves uncapped explicit sweeps bounded by the unbounded live timeout", () => { + expect(resolveGatewayLiveSuiteTimeoutMs(0)).toBe(GATEWAY_LIVE_UNBOUNDED_TIMEOUT_MS); + }); + + it("scales model-capped sweeps for multi-probe retries", () => { + expect(resolveGatewayLiveSuiteTimeoutMs(2)).toBeGreaterThan(GATEWAY_LIVE_DEFAULT_TIMEOUT_MS); + }); + + it("caps very large model sweeps", () => { + expect(resolveGatewayLiveSuiteTimeoutMs(999)).toBe(GATEWAY_LIVE_MAX_TIMEOUT_MS); + }); +}); + describe("resolveGatewayLiveMaxModels", () => { const originalGatewayModels = process.env.OPENCLAW_LIVE_GATEWAY_MODELS; const originalGatewayMax = process.env.OPENCLAW_LIVE_GATEWAY_MAX_MODELS;