Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(maker-core): 把 upstream stream error 纳入自动续跑白名单 (#3514)
Dash50079b1b763b
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/interruptedTurnAutoResume.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/interruptedTurnAutoResume.test.tsindex bb4776c30e..883e6e1d53 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/interruptedTurnAutoResume.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/interruptedTurnAutoResume.test.ts@@ -146,6 +146,8 @@ describe('isInterruptedTurnError', () => {'upstream unreachable','502 Bad Gateway','Service Unavailable',+ 'API Error: upstream stream error: terminated',+ 'upstream stream error: socket reset',]) {expect(isInterruptedTurnError({ message }), `${message} 应自动重连`).toBe(true);}@@ -176,6 +178,7 @@ describe('isInterruptedTurnError', () => {['codex thread', { message: 'thread not found' }],['加密内容失效', { message: 'invalid encrypted content' }],['Pi auto-retry 耗尽后交给用户点重试', { reason: 'pi-gateway-drop', message: 'The operation timed out.' }],+ ['Codex 鉴权会话结束', { message: 'app_session_terminated' }],] as Array<[string, Parameters<typeof isInterruptedTurnError>[0]]>) {expect(isInterruptedTurnError(signals), `${label} 不该自动重连`).toBe(false);}diff --git a/apps/desktop/src/renderer/__tests__/networkError.test.ts b/apps/desktop/src/renderer/__tests__/networkError.test.tsindex 66216c2f38..e61c5878cb 100644--- a/apps/desktop/src/renderer/__tests__/networkError.test.ts+++ b/apps/desktop/src/renderer/__tests__/networkError.test.ts@@ -26,6 +26,10 @@ describe('isNetworkishErrorMessage', () => {'Reconnecting… 3/5 (stream disconnected before completion)','The operation timed out.','OpenAI Responses stream ended before a terminal response event',+ // Cindy Responses bridge / compat-proxy 中途断流;Claude Code 再包 API Error:+ 'API Error: upstream stream error: terminated',+ 'upstream stream error: socket reset',+ 'upstream stream error: Error: terminated',])('matches networkish message: %s', (msg) => {expect(isNetworkishErrorMessage(msg)).toBe(true);});@@ -38,6 +42,9 @@ describe('isNetworkishErrorMessage', () => {'Wrapped error: API Error: The operation timed out.',// 长数字不因包含 502 片段误伤(\b 词边界)'order id 15024 rejected',+ // 裸 terminated 是鉴权终态,不能当传输抖动+ 'app_session_terminated',+ 'Your session has ended. Please log in again. (app_session_terminated)',])('does not match non-network message: %s', (msg) => {expect(isNetworkishErrorMessage(msg)).toBe(false);});diff --git a/apps/desktop/src/renderer/utils/networkError.ts b/apps/desktop/src/renderer/utils/networkError.tsindex de9c4cfb19..fc542a64fc 100644--- a/apps/desktop/src/renderer/utils/networkError.ts+++ b/apps/desktop/src/renderer/utils/networkError.ts@@ -14,6 +14,9 @@* `API Error: The operation timed out` / `Connection error` 是 Anthropic SDK 的* APIConnectionTimeoutError / APIConnectionError 原文(SDK 重试耗尽后透传成* 终止型 turn error),同属重试可自愈的网络类(2026-07-13 超时横幅裸英文实锤)。+ * Cindy Responses bridge / compat-proxy 中途断流写成 `upstream stream error: …`+ * (undici 的 `terminated`、socket reset 等),Claude Code 再包 `API Error:`;+ * 只认这句短语,不裸匹配 `terminated`,避免误伤 `app_session_terminated`。*/export interface ReconnectAttempt {attempt: number;@@ -39,7 +42,7 @@ export function parseReconnectAttemptMessage(message: string): ReconnectAttemptexport 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|^API Error:\s*The operation timed out|^The operation timed out|stream ended before a terminal|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|^The operation timed out|stream ended before a terminal|Connection error|upstream stream 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.tsindex 1604c5b069..c944dc6b74 100644--- a/packages/maker-core/src/agents/shared/network-error.test.ts+++ b/packages/maker-core/src/agents/shared/network-error.test.ts@@ -29,6 +29,10 @@ describe('isNetworkishErrorMessage', () => {'Reconnecting… 3/5 (stream disconnected before completion)','The operation timed out.','OpenAI Responses stream ended before a terminal response event',+ // Cindy Responses bridge / compat-proxy 中途断流;Claude Code 再包 API Error:+ 'API Error: upstream stream error: terminated',+ 'upstream stream error: socket reset',+ 'upstream stream error: Error: terminated',])('matches networkish message: %s', (msg) => {expect(isNetworkishErrorMessage(msg)).toBe(true);});@@ -41,6 +45,9 @@ describe('isNetworkishErrorMessage', () => {'Wrapped error: API Error: The operation timed out.',// 长数字不因包含 502 片段误伤(\b 词边界)'order id 15024 rejected',+ // 裸 terminated 是鉴权终态,不能当传输抖动+ 'app_session_terminated',+ 'Your session has ended. Please log in again. (app_session_terminated)',])('does not match non-network message: %s', (msg) => {expect(isNetworkishErrorMessage(msg)).toBe(false);});diff --git a/packages/maker-core/src/agents/shared/network-error.ts b/packages/maker-core/src/agents/shared/network-error.tsindex d0da601284..e47e20fe06 100644--- a/packages/maker-core/src/agents/shared/network-error.ts+++ b/packages/maker-core/src/agents/shared/network-error.ts@@ -20,6 +20,9 @@* SDK 重试耗尽后透传成终止型 turn error)。Pi / OpenAI Responses 还会写出不带* `API Error:` 前缀的 `The operation timed out.`,以及* `OpenAI Responses stream ended before a terminal response event`。+ * Cindy Responses bridge / compat-proxy 中途断流写成 `upstream stream error: …`+ * (undici 的 `terminated`、socket reset 等),Claude Code 再包 `API Error:`;+ * 只认这句短语,不裸匹配 `terminated`,避免误伤 `app_session_terminated`。*//** 仅在 Pi `auto_retry_end` 失败后使用:把「点一下重试」留给用户,Host 不再续跑。首次 aborted 不得打这个 reason。 */export const PI_GATEWAY_DROP_REASON = 'pi-gateway-drop';@@ -53,7 +56,7 @@ export function parseReconnectAttemptMessage(message: string): ReconnectAttemptexport 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|^API Error:\s*The operation timed out|^The operation timed out|stream ended before a terminal|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|^The operation timed out|stream ended before a terminal|Connection error|upstream stream error/i.test(message,));