From 8a2d4623823ac048c67c9b2127941a05e1931a33 Mon Sep 17 00:00:00 2001 From: ymq Date: Fri, 21 Aug 2026 00:10:38 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20TimeoutError=20=E6=B2=BB=E7=90=86?= =?UTF-8?q?=E2=80=94=E2=80=94=E7=BC=A9=E5=B0=8F=20read=5Ffile=20=E4=B8=8A?= =?UTF-8?q?=E4=B8=8B=E6=96=87=20+=20=E6=94=BE=E5=AE=BD=20LLM=20=E5=A4=96?= =?UTF-8?q?=E5=B1=82=E7=A1=AC=E8=B6=85=E6=97=B6=E7=BB=99=E8=B6=B3=E9=87=8D?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 根因:develop agent 的 LLM 调用(deepseek-v4-pro→qwen3.8-max 经 llmage 网关)在 大上下文多轮累积时偶发挂起/返回 FAILED,llm_bridge 300s×3 重试被外层 420s 硬超时 提前掐断(只够 ~1.4 轮),可自愈的瞬时故障也 TimeoutError 超限暂停任务链。 修复:read_file 30000→12000 缩小上下文;_LLM_HARD_TIMEOUT 420→600 给 llm_bridge 至少 2 轮完整重试机会。 --- pipeline_service/agent_loop.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pipeline_service/agent_loop.py b/pipeline_service/agent_loop.py index 5cf26f0..625ca53 100644 --- a/pipeline_service/agent_loop.py +++ b/pipeline_service/agent_loop.py @@ -890,7 +890,7 @@ async def _exec_agent_tool(tool, params, workspace_dir): if not await _is_safe_workdir_async(full): return 'FAIL: 路径不在允许范围' if not os.path.isfile(full): return f'FAIL: 文件不存在 {path}' with open(full, encoding='utf-8') as f: - return f.read()[:30000] + return f.read()[:12000] elif tool == 'write_file': path = p.get('path', '') content = p.get('content', '') @@ -950,8 +950,9 @@ _FORCE_PRODUCE_TURN = 5 # LLM 调用硬超时(外层 asyncio.wait_for 兜底)。llm_bridge 内部 300s×3 重试最坏 15 分钟, # 期间 role_agent_run 心跳不更新(心跳在调用前 touch),观察上像任务挂起/僵尸。 -# 外层硬上限:① 缩短最坏时长到 7 分钟 ② 防 aiohttp total 超时因 DNS 等场景失效导致的真正无限挂起。 -_LLM_HARD_TIMEOUT = 420 +# 外层硬上限:① 防 aiohttp total 超时因 DNS 等场景失效导致的真正无限挂起 ② 给 llm_bridge 至少 2 轮完整重试机会 +# (420s 只够 ~1.4 轮,网关瞬时挂起时重试被提前掐断,可自愈的瞬时故障也 TimeoutError 超限暂停任务链)。 +_LLM_HARD_TIMEOUT = 600 _FORCE_PRODUCE_HINT = ( "⚠️ 你已经探索了足够多轮(已超过 5 轮)。现在必须立即产出并交付:\n"