diff --git a/electron/services/providers/provider-runtime-sync.ts b/electron/services/providers/provider-runtime-sync.ts index a0af1d359..23253107b 100644 --- a/electron/services/providers/provider-runtime-sync.ts +++ b/electron/services/providers/provider-runtime-sync.ts @@ -65,6 +65,15 @@ function shouldUseExplicitDefaultOverride(config: ProviderConfig, runtimeProvide export function getOpenClawProviderKey(type: string, providerId: string): string { if (type === 'custom' || type === 'ollama') { + // If the providerId is already a runtime key (e.g. re-seeded from openclaw.json + // as "custom-XXXXXXXX"), return it directly to avoid double-hashing. + const prefix = `${type}-`; + if (providerId.startsWith(prefix)) { + const tail = providerId.slice(prefix.length); + if (tail.length === 8 && !tail.includes('-')) { + return providerId; + } + } const suffix = providerId.replace(/-/g, '').slice(0, 8); return `${type}-${suffix}`; } diff --git a/electron/utils/provider-keys.ts b/electron/utils/provider-keys.ts index 583a1ad3b..b1da9d57a 100644 --- a/electron/utils/provider-keys.ts +++ b/electron/utils/provider-keys.ts @@ -18,6 +18,15 @@ const PROVIDER_KEY_ALIASES: Record = { export function getOpenClawProviderKeyForType(type: string, providerId: string): string { if (MULTI_INSTANCE_PROVIDER_TYPES.has(type)) { + // If the providerId is already a runtime key (e.g. re-seeded from openclaw.json + // as "custom-XXXXXXXX"), return it directly to avoid double-hashing. + const prefix = `${type}-`; + if (providerId.startsWith(prefix)) { + const tail = providerId.slice(prefix.length); + if (tail.length === 8 && !tail.includes('-')) { + return providerId; + } + } const suffix = providerId.replace(/-/g, '').slice(0, 8); return `${type}-${suffix}`; }