From fbfcd385cf3a51f4411b111d8dec70ea5d9d0ab6 Mon Sep 17 00:00:00 2001 From: Evan Jacobson Date: Wed, 1 Apr 2026 18:55:55 -0600 Subject: [PATCH] fix(kiloclaw): set baseUrl when creating kilocode provider entry for org instances OpenClaw's ModelProviderSchema requires baseUrl to be a non-empty string. The org header block creates a models.providers.kilocode entry to inject X-KiloCode-OrganizationId but never set baseUrl, causing config validation to fail on every org instance boot with: models.providers.kilocode.baseUrl: Invalid input: expected string, received undefined Fix: set baseUrl to the production URL (falling back from any existing dev override set earlier in the function by KILOCODE_API_BASE_URL). --- kiloclaw/controller/src/config-writer.test.ts | 3 +++ kiloclaw/controller/src/config-writer.ts | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/kiloclaw/controller/src/config-writer.test.ts b/kiloclaw/controller/src/config-writer.test.ts index a91ca6000..d7d33b18a 100644 --- a/kiloclaw/controller/src/config-writer.test.ts +++ b/kiloclaw/controller/src/config-writer.test.ts @@ -251,6 +251,9 @@ describe('generateBaseConfig', () => { expect(config.models.providers.kilocode.headers['X-KiloCode-OrganizationId']).toBe( 'org_abc123' ); + // baseUrl must be a string (OpenClaw schema requires it); fall back to + // the production URL when no KILOCODE_API_BASE_URL override is active. + expect(config.models.providers.kilocode.baseUrl).toBe('https://api.kilo.ai/api/gateway/'); expect(config.models.providers.kilocode.models).toEqual([]); }); diff --git a/kiloclaw/controller/src/config-writer.ts b/kiloclaw/controller/src/config-writer.ts index 5b23bd560..f73041ebe 100644 --- a/kiloclaw/controller/src/config-writer.ts +++ b/kiloclaw/controller/src/config-writer.ts @@ -187,6 +187,10 @@ export function generateBaseConfig( config.models = config.models ?? {}; config.models.providers = config.models.providers ?? {}; config.models.providers.kilocode = config.models.providers.kilocode ?? {}; + // OpenClaw's provider schema requires baseUrl to be a string. Preserve an + // existing dev override (KILOCODE_API_BASE_URL), otherwise use the production URL. + config.models.providers.kilocode.baseUrl = + config.models.providers.kilocode.baseUrl ?? 'https://api.kilo.ai/api/gateway/'; config.models.providers.kilocode.headers = config.models.providers.kilocode.headers ?? {}; config.models.providers.kilocode.headers['X-KiloCode-OrganizationId'] = env.KILOCODE_ORGANIZATION_ID;