From fd878c53960fa4aefa1b3273b927884032f96cb7 Mon Sep 17 00:00:00 2001 From: thzxx Date: Sat, 20 Jun 2026 13:32:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AD=90=E4=BB=A3=E7=90=86=E8=B6=85?= =?UTF-8?q?=E6=97=B6=E8=AE=BE=E4=B8=BA0=E6=97=B6=E7=AB=8B=E5=8D=B3?= =?UTF-8?q?=E8=A7=A6=E5=8F=91=EF=BC=8C=E6=94=B9=E4=B8=BAInfinity=E6=AD=A3?= =?UTF-8?q?=E7=A1=AE=E7=A6=81=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/services/sub-agent.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/renderer/services/sub-agent.ts b/src/renderer/services/sub-agent.ts index 8d0d4c0..2d53756 100644 --- a/src/renderer/services/sub-agent.ts +++ b/src/renderer/services/sub-agent.ts @@ -50,6 +50,7 @@ export async function executeSubAgent( const model = options.model || state.get('_defaultModel', ''); const maxLoops = options.maxLoops ?? state.get('subAgentMaxLoops', SUB_AGENT_MAX_LOOPS); const timeout = options.timeout ?? state.get('subAgentTimeout', SUB_AGENT_TIMEOUT); + const effectiveTimeout = timeout > 0 ? timeout : Infinity; // 0=禁用超时 if (!api || !model) { return { success: false, error: '未选择模型,无法执行子任务' }; @@ -73,7 +74,7 @@ ${context ? `\n附加上下文:\n${context}` : ''}`; while (loopCount < maxLoops) { loopCount++; - if (Date.now() - startTime > timeout) { + if (Date.now() - startTime > effectiveTimeout) { logWarn('子 Agent 超时', `${loopCount} 轮`); return { success: true, content: '子任务执行超时', loops: loopCount, duration: Date.now() - startTime, partial: true }; }