Merge pull request #1851 from pikasTech/fix/agentrun-transport-retry-1811-20260621
修复 AgentRun transport failure 重试投影
This commit is contained in:
@@ -563,10 +563,25 @@ function agentRunDispatchRetryDelayMs(policy, retryAttempt) {
|
|||||||
return Math.min(cap, Math.trunc(base * Math.pow(2, Math.max(0, Number(retryAttempt ?? 1) - 1))));
|
return Math.min(cap, Math.trunc(base * Math.pow(2, Math.max(0, Number(retryAttempt ?? 1) - 1))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const RETRYABLE_AGENTRUN_TRANSPORT_FAILURE_KINDS = new Set([
|
||||||
|
"agentrun-connect-failed",
|
||||||
|
"agentrun-proxy-exec-failed",
|
||||||
|
"agentrun-manager-fetch-failed",
|
||||||
|
"agentrun-timeout",
|
||||||
|
"timeout",
|
||||||
|
"fetch-failed",
|
||||||
|
"network-error"
|
||||||
|
]);
|
||||||
|
|
||||||
|
function isRetryableAgentRunTransportFailureKind(failureKind) {
|
||||||
|
return RETRYABLE_AGENTRUN_TRANSPORT_FAILURE_KINDS.has(normalizedFailureKind(failureKind));
|
||||||
|
}
|
||||||
|
|
||||||
function agentRunDispatchRetryable(error, failureKind) {
|
function agentRunDispatchRetryable(error, failureKind) {
|
||||||
const status = Number(error?.statusCode ?? error?.status ?? error?.agentRunError?.statusCode ?? 0);
|
const status = Number(error?.statusCode ?? error?.status ?? error?.agentRunError?.statusCode ?? 0);
|
||||||
if ([429, 502, 503, 504].includes(status)) return true;
|
if ([429, 502, 503, 504].includes(status)) return true;
|
||||||
if (["provider-unavailable", "provider-stream-disconnected", "agentrun-timeout", "agentrun-timeout", "timeout", "fetch-failed", "network-error"].includes(failureKind)) return true;
|
if (["provider-unavailable", "provider-stream-disconnected"].includes(failureKind)) return true;
|
||||||
|
if (isRetryableAgentRunTransportFailureKind(failureKind)) return true;
|
||||||
return /ECONNRESET|ETIMEDOUT|EAI_AGAIN|ENOTFOUND|socket hang up|fetch failed|network|timeout/iu.test(String(error?.message ?? ""));
|
return /ECONNRESET|ETIMEDOUT|EAI_AGAIN|ENOTFOUND|socket hang up|fetch failed|network|timeout/iu.test(String(error?.message ?? ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2559,11 +2574,14 @@ function isRetryableProviderInterruptionPayload(payload = {}, options = {}) {
|
|||||||
const kind = normalizedFailureKind(payload?.failureKind ?? payload?.errorCode ?? payload?.code);
|
const kind = normalizedFailureKind(payload?.failureKind ?? payload?.errorCode ?? payload?.code);
|
||||||
if (kind === "provider-stream-disconnected") return payload?.willRetry === true;
|
if (kind === "provider-stream-disconnected") return payload?.willRetry === true;
|
||||||
if (kind === "provider-unavailable") return payload?.willRetry === true || (options.activeError === true && payload?.terminal !== true && payload?.final !== true);
|
if (kind === "provider-unavailable") return payload?.willRetry === true || (options.activeError === true && payload?.terminal !== true && payload?.final !== true);
|
||||||
|
if (isRetryableAgentRunTransportFailureKind(kind)) return payload?.willRetry === true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function normalizedFailureKind(value) {
|
function normalizedFailureKind(value) {
|
||||||
return String(value ?? "").trim().toLowerCase().replace(/_/gu, "-") || null;
|
const normalized = String(value ?? "").trim().toLowerCase().replace(/_/gu, "-") || null;
|
||||||
|
if (normalized === "agentrun-unreachable") return "agentrun-connect-failed";
|
||||||
|
return normalized;
|
||||||
}
|
}
|
||||||
|
|
||||||
function numberOrNull(value) {
|
function numberOrNull(value) {
|
||||||
|
|||||||
@@ -284,11 +284,22 @@ function retryableProviderInterruptionEvidence(...values) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const RETRYABLE_AGENTRUN_TRANSPORT_FAILURE_KINDS = new Set([
|
||||||
|
"agentrun-connect-failed",
|
||||||
|
"agentrun-proxy-exec-failed",
|
||||||
|
"agentrun-manager-fetch-failed",
|
||||||
|
"agentrun-timeout"
|
||||||
|
]);
|
||||||
|
|
||||||
|
function isRetryableAgentRunTransportFailureKind(kind) {
|
||||||
|
return RETRYABLE_AGENTRUN_TRANSPORT_FAILURE_KINDS.has(kind);
|
||||||
|
}
|
||||||
|
|
||||||
function retryableProviderInterruptionRecord(value) {
|
function retryableProviderInterruptionRecord(value) {
|
||||||
const record = objectValue(value);
|
const record = objectValue(value);
|
||||||
if (!record) return null;
|
if (!record) return null;
|
||||||
const kind = normalizeWorkbenchStatus(record.failureKind ?? record.errorCode ?? record.code ?? record.name);
|
const kind = normalizeWorkbenchStatus(record.failureKind ?? record.errorCode ?? record.code ?? record.name);
|
||||||
if ((kind === "provider-stream-disconnected" || kind === "provider-unavailable") && record.willRetry === true) {
|
if ((kind === "provider-stream-disconnected" || kind === "provider-unavailable" || isRetryableAgentRunTransportFailureKind(kind)) && record.willRetry === true) {
|
||||||
return {
|
return {
|
||||||
failureKind: kind,
|
failureKind: kind,
|
||||||
willRetry: true,
|
willRetry: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user