From 6aa1c94cd6c1554632ff15e61af1cd191775bb6c Mon Sep 17 00:00:00 2001 From: Danny Avila Date: Thu, 19 Nov 2026 13:36:10 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=8F=AD=20fix:=20Init?= =?UTF-8?q?ialize=20Remote=20SDK=20Hosts=20in=20Cluster=20Workers=20(#1851?= =?UTF-8?q?9)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/server/experimental.js | 4 ++++ api/server/experimental.spec.js | 15 +++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/api/server/experimental.js b/api/server/experimental.js index 5978d8d26f..2f29bad154 100644 --- a/api/server/experimental.js +++ b/api/server/experimental.js @@ -61,6 +61,8 @@ const { startCodeEnvironmentLifecycleReconciler, waitForKeyvRedisClient, createCodeApiUploadRegistry, + createSdkFileHost, + createSdkModelHost, cacheConfig, createClusteredFileSweep, createRequestSanitizer, @@ -545,6 +547,8 @@ if (cluster.isMaster) { }), { priority: 50 }, ); + app.locals.sdkFileHost = createSdkFileHost(appConfig?.endpoints?.agents?.sdkHostFiles); + app.locals.sdkModelHost = createSdkModelHost(appConfig?.endpoints?.agents?.sdkHostModels); initializeFileStorage(appConfig); initializeGitHubSkillSync(appConfig); startSkillDeletionSweep(appConfig.skillDeletion); diff --git a/api/server/experimental.spec.js b/api/server/experimental.spec.js index c15eaee8b5..9908accdc7 100644 --- a/api/server/experimental.spec.js +++ b/api/server/experimental.spec.js @@ -13,6 +13,21 @@ describe('Experimental server configuration', () => { expect(listenIndex).toBeLessThan(timeoutConfigIndex); }); + it.each([ + ['File', 'Files'], + ['Model', 'Models'], + ])('installs the SDK %s host from base config before serving requests', (host, setting) => { + const configIndex = source.indexOf('await getAppConfig({ baseOnly: true });'); + const binding = `app.locals.sdk${host}Host = createSdk${host}Host(appConfig?.endpoints?.agents?.sdkHost${setting});`; + const bindingIndex = source.indexOf(binding); + const listenIndex = source.indexOf('const server = app.listen'); + + expect(configIndex).toBeGreaterThan(-1); + expect(bindingIndex).toBeGreaterThan(configIndex); + expect(listenIndex).toBeGreaterThan(bindingIndex); + expect(source.indexOf(binding, bindingIndex + 1)).toBe(-1); + }); + it('lets each worker drain registered services before cluster shutdown', () => { const listenIndex = source.indexOf('const server = app.listen'); const gracefulShutdownIndex = source.indexOf('setupGracefulShutdown(server);');