fix: align DeepSeek Harness model selection

DeepSeek Harness previously required a separate Runtime model selection when no administrator-provided connection was available, even if the user had already selected a compatible GoodBuddy model. It now prefers the administrator connection, then follows the compatible default model or first compatible connection across conversations, projects, and messaging channels.

Release note: 修复 DeepSeek Harness 未自动使用已选兼容模型的问题;没有管理员预置连接时,现在会跟随当前默认或首个兼容模型,无需再到 Harness 页面重复指定。
This commit is contained in:
mesalogo
2026-09-02 16:45:42 +08:00
parent 42cbfa43f1
commit 5fac1d3c41
6 changed files with 123 additions and 14 deletions
+72
View File
@@ -408,6 +408,78 @@ describe('RuntimeSettingsStore', () => {
})
})
it('uses a compatible GoodBuddy model for Harness when no platform model is configured', async () => {
const profileId = '00000000-0000-4000-8000-000000000044'
const { store } = await createStore()
await store.update(
settings({
modelProfiles: [
{
id: profileId,
name: 'OpenAI-compatible gateway',
baseUrl: 'https://gateway.example/openai/v1',
modelName: 'qwen-plus',
protocol: 'openai-chat-completions',
authentication: 'api-key',
imageGenerationQuality: 'auto',
apiKey: { action: 'replace', value: 'deepseek-secret' }
}
],
defaultModelProfileId: profileId
})
)
await expect(store.getPublicSettings()).resolves.toMatchObject({
deepseekHarnessModelSource: { kind: 'profile', profileId },
configured: {
deepseekHarnessModelSource: { kind: 'platform' }
}
})
await expect(store.getResolvedSettings()).resolves.toMatchObject({
deepseekHarnessModelProfile: {
id: profileId,
apiKey: 'deepseek-secret'
}
})
})
it('uses the first compatible Harness model when the default model is incompatible', async () => {
const defaultId = '00000000-0000-4000-8000-000000000043'
const harnessId = '00000000-0000-4000-8000-000000000044'
const { store } = await createStore()
await store.update(
settings({
modelProfiles: [
{
id: defaultId,
name: 'Anthropic model',
baseUrl: 'https://anthropic.example',
modelName: 'claude',
protocol: 'anthropic-messages',
authentication: 'api-key',
imageGenerationQuality: 'auto',
apiKey: { action: 'replace', value: 'anthropic-secret' }
},
{
id: harnessId,
name: 'OpenAI-compatible gateway',
baseUrl: 'https://gateway.example/openai/v1',
modelName: 'qwen-plus',
protocol: 'openai-chat-completions',
authentication: 'api-key',
imageGenerationQuality: 'auto',
apiKey: { action: 'replace', value: 'deepseek-secret' }
}
],
defaultModelProfileId: defaultId
})
)
await expect(store.getResolvedSettings()).resolves.toMatchObject({
deepseekHarnessModelProfile: { id: harnessId }
})
})
it('migrates DeepSeek Harness to controlled platform mode and stores a compatible profile', async () => {
const { filePath, store } = await createStore()
await store.update(settings())
+40 -7
View File
@@ -1423,6 +1423,30 @@ export class RuntimeSettingsStore {
}
}
private resolveDeepSeekHarnessModelProfile(
settings: StoredSettings,
modelProfiles: readonly ResolvedModelProfile[]
): ResolvedModelProfile | undefined {
const source = settings.deepseekHarnessModelSource
if (source.kind === 'profile') {
return modelProfiles.find(
(profile) => profile.id === source.profileId
)
}
const platformProfile = this.resolvePlatformHarnessProfile()
if (platformProfile) {
return platformProfile
}
return (
modelProfiles.find(
(profile) =>
profile.id === settings.defaultModelProfileId &&
isDeepSeekHarnessModelProfile(profile)
) ??
modelProfiles.find(isDeepSeekHarnessModelProfile)
)
}
private resolveModelCredentials(
settings: StoredSettings
): Map<string, ResolvedModelCredential> {
@@ -1692,6 +1716,20 @@ export class RuntimeSettingsStore {
credentialSource: credential.source
}
})
const deepseekHarnessModelProfile =
this.resolveDeepSeekHarnessModelProfile(
settings,
resolvedModelProfiles
)
const deepseekHarnessModelSource =
settings.deepseekHarnessModelSource.kind === 'platform' &&
deepseekHarnessModelProfile &&
resolvedProfilesById.has(deepseekHarnessModelProfile.id)
? {
kind: 'profile' as const,
profileId: deepseekHarnessModelProfile.id
}
: settings.deepseekHarnessModelSource
const embeddingEnvironmentApiKey =
this.environment.GOODBUDDY_EMBEDDING_API_KEY?.trim()
const embeddingStoredApiKey = embeddingEnvironmentApiKey
@@ -1797,8 +1835,7 @@ export class RuntimeSettingsStore {
? { kind: 'platform' }
: settings.opencodeModelSource,
continueModelSource: settings.continueModelSource,
deepseekHarnessModelSource:
settings.deepseekHarnessModelSource,
deepseekHarnessModelSource,
secureStorageAvailable: this.cipher.isAvailable(),
toolApproval: settings.toolApproval,
configured: {
@@ -1892,11 +1929,7 @@ export class RuntimeSettingsStore {
? profilesById.get(settings.continueModelSource.profileId)
: undefined
const deepseekHarnessModelProfile =
settings.deepseekHarnessModelSource.kind === 'profile'
? profilesById.get(
settings.deepseekHarnessModelSource.profileId
)
: this.resolvePlatformHarnessProfile()
this.resolveDeepSeekHarnessModelProfile(settings, modelProfiles)
const embeddingConnections =
this.resolveEmbeddingConnections(settings)
const activeEmbeddingConnection =