From 436c41fb190486db9dceed336254ce387fbaca5d Mon Sep 17 00:00:00 2001 From: doudouOUC Date: Mon, 1 Jun 2026 14:21:44 +0800 Subject: [PATCH] fix(core): add keepAliveTimeout to no-proxy Agent for connection reuse MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Match the proxy path's keepAliveTimeout: 60_000 so TCP connections to local model servers survive between interactive turns (default 4s is too short for 30s–2min prompt intervals). --- packages/core/src/utils/runtimeFetchOptions.test.ts | 1 + packages/core/src/utils/runtimeFetchOptions.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/core/src/utils/runtimeFetchOptions.test.ts b/packages/core/src/utils/runtimeFetchOptions.test.ts index e443fc25c..de3e18ead 100644 --- a/packages/core/src/utils/runtimeFetchOptions.test.ts +++ b/packages/core/src/utils/runtimeFetchOptions.test.ts @@ -86,6 +86,7 @@ describe('buildRuntimeFetchOptions (node runtime)', () => { expect(dispatcher?.options).toMatchObject({ bodyTimeout: 0, headersTimeout: 0, + keepAliveTimeout: 60_000, }); }); diff --git a/packages/core/src/utils/runtimeFetchOptions.ts b/packages/core/src/utils/runtimeFetchOptions.ts index 1409945be..7932e63fb 100644 --- a/packages/core/src/utils/runtimeFetchOptions.ts +++ b/packages/core/src/utils/runtimeFetchOptions.ts @@ -181,6 +181,7 @@ function getOrCreateNoProxyDispatcher(bodyTimeout: number): Dispatcher { const dispatcher = new Agent({ bodyTimeout, headersTimeout: 0, + keepAliveTimeout: 60_000, }); noProxyDispatcherCache.set(bodyTimeout, dispatcher);