fix: extend Agnes video submit timeout

This commit is contained in:
FengLee
2026-06-06 20:04:47 +08:00
parent 567d264673
commit 6609a7dec2
2 changed files with 22 additions and 5 deletions

View File

@@ -156,7 +156,9 @@ await runTest('Agnes video manifest splits per-request timeout from total pollin
assert.match(executor, /function getManifestRequestTimeoutMs/);
assert.match(executor, /USER_API_MANIFEST_SUBMIT_TIMEOUT_MS/);
assert.match(executor, /USER_API_MANIFEST_POLL_REQUEST_TIMEOUT_MS/);
assert.match(executor, /getManifestRequestTimeoutMs\(input\.timeoutMs,\s*method\)/);
assert.match(executor, /AGNES_VIDEO_MANIFEST_SUBMIT_TIMEOUT_MS/);
assert.match(executor, /function isAgnesVideoManifestRequest/);
assert.match(executor, /getManifestRequestTimeoutMs\(input\.timeoutMs,\s*method,\s*input\)/);
assert.match(executor, /while \(Date\.now\(\) < deadline\)/);
assert.match(executor, /isTransientPollError/);
});

View File

@@ -368,12 +368,27 @@ function parsePositiveInt(value: string | undefined, fallback: number): number {
return Number.isFinite(parsed) && parsed > 0 ? Math.floor(parsed) : fallback;
}
function getManifestRequestTimeoutMs(totalTimeoutMs: number, method: string): number {
const AGNES_VIDEO_MANIFEST_SUBMIT_TIMEOUT_MS = 10 * 60_000;
function isAgnesVideoManifestRequest(input: UserApiManifestExecutionInput): boolean {
const modelName = (input.modelName || '').toLowerCase();
const apiUrl = (input.apiUrl || '').toLowerCase();
return modelName.startsWith('agnes-video-')
|| (modelName.includes('agnes-video') && apiUrl.includes('agnes-ai'));
}
function getManifestRequestTimeoutMs(totalTimeoutMs: number, method: string, input: UserApiManifestExecutionInput): number {
const isPoll = method === 'GET';
const fallback = isPoll ? 60_000 : 180_000;
const fallback = isPoll
? 60_000
: isAgnesVideoManifestRequest(input)
? AGNES_VIDEO_MANIFEST_SUBMIT_TIMEOUT_MS
: 180_000;
const envValue = isPoll
? process.env.USER_API_MANIFEST_POLL_REQUEST_TIMEOUT_MS
: process.env.USER_API_MANIFEST_SUBMIT_TIMEOUT_MS;
: isAgnesVideoManifestRequest(input)
? process.env.AGNES_VIDEO_MANIFEST_SUBMIT_TIMEOUT_MS || process.env.USER_API_MANIFEST_SUBMIT_TIMEOUT_MS
: process.env.USER_API_MANIFEST_SUBMIT_TIMEOUT_MS;
return Math.max(1_000, Math.min(totalTimeoutMs, parsePositiveInt(envValue, fallback)));
}
@@ -404,7 +419,7 @@ async function requestManifestEndpoint(
response = await fetchWithRetry(
url,
{ method, headers, body: method === 'GET' ? undefined : body },
getManifestRequestTimeoutMs(input.timeoutMs, method),
getManifestRequestTimeoutMs(input.timeoutMs, method, input),
1,
);
} catch (error) {