Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(desktop): 自动续跑 API operation timeout (#1361)

Dashee39bacc0a9a
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/interruptedTurnAutoResume.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/interruptedTurnAutoResume.test.ts
index 7eea4919e2..a427f1a44f 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/interruptedTurnAutoResume.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/interruptedTurnAutoResume.test.ts
@@ -115,6 +115,7 @@ describe('isInterruptedTurnError', () => {
'connect ECONNREFUSED 127.0.0.1:9',
'socket hang up',
'Request timed out',
+ 'API Error: The operation timed out.',
'Connection error',
'upstream unreachable',
'502 Bad Gateway',
diff --git a/apps/desktop/src/renderer/__tests__/networkError.test.ts b/apps/desktop/src/renderer/__tests__/networkError.test.ts
index 02677da966..61ebb8a18c 100644
--- a/apps/desktop/src/renderer/__tests__/networkError.test.ts
+++ b/apps/desktop/src/renderer/__tests__/networkError.test.ts
@@ -15,6 +15,7 @@ describe('isNetworkishErrorMessage', () => {
it.each([
// Anthropic SDK 重试耗尽后透传的终止型错误原文
'Request timed out.',
+ 'API Error: The operation timed out.',
'Connection error.',
// 网关 / errno / fetch 存量场景抽查
'unexpected status 502 Bad Gateway: upstream unreachable: AggregateError',
@@ -31,6 +32,8 @@ describe('isNetworkishErrorMessage', () => {
'Invalid API key',
'thread not found',
'context window exceeded',
+ 'Local tool operation timed out.',
+ 'Wrapped error: API Error: The operation timed out.',
// 长数字不因包含 502 片段误伤(\b 词边界)
'order id 15024 rejected',
])('does not match non-network message: %s', (msg) => {
diff --git a/apps/desktop/src/renderer/utils/networkError.ts b/apps/desktop/src/renderer/utils/networkError.ts
index 5650d2f7b3..4cb7f852c5 100644
--- a/apps/desktop/src/renderer/utils/networkError.ts
+++ b/apps/desktop/src/renderer/utils/networkError.ts
@@ -11,7 +11,7 @@
*
* `Reconnecting... N/M` 是 Codex streaming response 的有限重连状态;解析后的
* attempt/maxAttempts 会显示在 recoverable banner。`Request timed out` /
- * `Connection error` 是 Anthropic SDK 的
+ * `API Error: The operation timed out` / `Connection error` 是 Anthropic SDK 的
* APIConnectionTimeoutError / APIConnectionError 原文(SDK 重试耗尽后透传成
* 终止型 turn error),同属重试可自愈的网络类(2026-07-13 超时横幅裸英文实锤)。
*/
@@ -39,7 +39,7 @@ export function parseReconnectAttemptMessage(message: string): ReconnectAttempt
export function isNetworkishErrorMessage(message: string): boolean {
return (
parseReconnectAttemptMessage(message) !== null ||
- /\b50[234]\b|Bad Gateway|Service Unavailable|Gateway Time-?out|upstream unreachable|ECONNREFUSED|ECONNRESET|ETIMEDOUT|ENOTFOUND|ENETUNREACH|EHOSTUNREACH|EPIPE|EAI_AGAIN|fetch failed|network error|socket hang up|AggregateError|Request timed out|Connection error/i.test(
+ /\b50[234]\b|Bad Gateway|Service Unavailable|Gateway Time-?out|upstream unreachable|ECONNREFUSED|ECONNRESET|ETIMEDOUT|ENOTFOUND|ENETUNREACH|EHOSTUNREACH|EPIPE|EAI_AGAIN|fetch failed|network error|socket hang up|AggregateError|Request timed out|^API Error:\s*The operation timed out|Connection error/i.test(
message,
)
);
diff --git a/packages/maker-core/src/agents/shared/network-error.test.ts b/packages/maker-core/src/agents/shared/network-error.test.ts
index 68e7169bf1..f8e93a92fd 100644
--- a/packages/maker-core/src/agents/shared/network-error.test.ts
+++ b/packages/maker-core/src/agents/shared/network-error.test.ts
@@ -18,6 +18,7 @@ describe('isNetworkishErrorMessage', () => {
it.each([
// Anthropic SDK 重试耗尽后透传的终止型错误原文
'Request timed out.',
+ 'API Error: The operation timed out.',
'Connection error.',
// 网关 / errno / fetch 存量场景抽查
'unexpected status 502 Bad Gateway: upstream unreachable: AggregateError',
@@ -34,6 +35,8 @@ describe('isNetworkishErrorMessage', () => {
'Invalid API key',
'thread not found',
'context window exceeded',
+ 'Local tool operation timed out.',
+ 'Wrapped error: API Error: The operation timed out.',
// 长数字不因包含 502 片段误伤(\b 词边界)
'order id 15024 rejected',
])('does not match non-network message: %s', (msg) => {
diff --git a/packages/maker-core/src/agents/shared/network-error.ts b/packages/maker-core/src/agents/shared/network-error.ts
index 89ffcf8b3b..58cc57173e 100644
--- a/packages/maker-core/src/agents/shared/network-error.ts
+++ b/packages/maker-core/src/agents/shared/network-error.ts
@@ -16,7 +16,8 @@
* 网关标准短语、Node 网络 errno(ECONNREFUSED 等)、undici/fetch 失败短语、
* AggregateError(Node 并发连接尝试全失败的聚合错误,几乎只出现在网络场景)、
* Anthropic SDK 的 APIConnectionTimeoutError / APIConnectionError 原文
- * ("Request timed out" / "Connection error",SDK 重试耗尽后透传成终止型 turn error)。
+ * ("Request timed out" / "API Error: The operation timed out" / "Connection error",
+ * SDK 重试耗尽后透传成终止型 turn error)。
*/
export interface ReconnectAttempt {
attempt: number;
@@ -47,7 +48,7 @@ export function parseReconnectAttemptMessage(message: string): ReconnectAttempt
export function isNetworkishErrorMessage(message: string): boolean {
return (
parseReconnectAttemptMessage(message) !== null ||
- /\b50[234]\b|Bad Gateway|Service Unavailable|Gateway Time-?out|upstream unreachable|ECONNREFUSED|ECONNRESET|ETIMEDOUT|ENOTFOUND|ENETUNREACH|EHOSTUNREACH|EPIPE|EAI_AGAIN|fetch failed|network error|socket hang up|AggregateError|Request timed out|Connection error/i.test(
+ /\b50[234]\b|Bad Gateway|Service Unavailable|Gateway Time-?out|upstream unreachable|ECONNREFUSED|ECONNRESET|ETIMEDOUT|ENOTFOUND|ENETUNREACH|EHOSTUNREACH|EPIPE|EAI_AGAIN|fetch failed|network error|socket hang up|AggregateError|Request timed out|^API Error:\s*The operation timed out|Connection error/i.test(
message,
)
);