From f90198a5ee971af481c0a68534158b938d56fc42 Mon Sep 17 00:00:00 2001 From: r266-tech Date: Wed, 25 Nov 2026 12:50:23 +0800 Subject: [PATCH] fix(codex): include Command Code image capabilities in model catalogs --- .../service/openai_codex_models_service.go | 15 ++++++-- .../openai_codex_models_service_test.go | 34 +++++++++++++++++++ 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/backend/internal/service/openai_codex_models_service.go b/backend/internal/service/openai_codex_models_service.go index 59ee8d459b..cee5511d5a 100644 --- a/backend/internal/service/openai_codex_models_service.go +++ b/backend/internal/service/openai_codex_models_service.go @@ -259,6 +259,7 @@ func loadCodexGroupCatalogAccounts(ctx context.Context, repo AccountRepository, PlatformDeepseek, PlatformMiniMax, PlatformOpenCodeGo, + PlatformCommandCode, }, false, ) @@ -1182,7 +1183,9 @@ func groupCodexModelSupportsImageInput( return false } } - if platform != PlatformOpenAI && platform != PlatformGrok && platform != PlatformDeepseek && platform != PlatformOpenCodeGo { + switch platform { + case PlatformOpenAI, PlatformGrok, PlatformDeepseek, PlatformOpenCodeGo, PlatformCommandCode: + default: return false } @@ -1321,7 +1324,7 @@ func accountCodexModelSupportsImageInput(account *Account, upstreamModel string) return false } switch account.Platform { - case PlatformOpenAI, PlatformDeepseek, PlatformOpenCodeGo: + case PlatformOpenAI, PlatformDeepseek, PlatformOpenCodeGo, PlatformCommandCode: if metadata, ok := account.GetUpstreamModelMetadata(upstreamModel); ok { if modalities := normalizeCodexInputModalities(metadata.InputModalities); len(modalities) > 0 { // Official GPT-6 Astra metadata briefly shipped with a stale @@ -1334,6 +1337,14 @@ func accountCodexModelSupportsImageInput(account *Account, upstreamModel string) return stringSliceContains(modalities, "image") } } + if account.IsCommandCode() { + // Only infer capabilities for the provider's own endpoints when a + // synced model has no input modalities. + model := strings.TrimPrefix(strings.TrimSpace(upstreamModel), "deepseek/") + return model == "deepseek-v4.1-flash" && + strings.TrimRight(account.GetOpenAIBaseURL(), "/") == DefaultCommandCodeBaseURL && + strings.TrimRight(account.GetCNProtocolBaseURL(APIProtocolResponses), "/") == DefaultCommandCodeBaseURL + } if strings.EqualFold(strings.TrimSpace(upstreamModel), "deepseek-v4-flash-vision-exp") { return account.Type == AccountTypeAPIKey } diff --git a/backend/internal/service/openai_codex_models_service_test.go b/backend/internal/service/openai_codex_models_service_test.go index b702eadc0f..7f21d64dfe 100644 --- a/backend/internal/service/openai_codex_models_service_test.go +++ b/backend/internal/service/openai_codex_models_service_test.go @@ -816,6 +816,9 @@ func TestBuildCodexModelsManifestForGroupUsesDeepSeekVisionCapabilities(t *testi return account } + customResponses := newAccount(1, PlatformCommandCode, "deepseek-v4.1-flash", nil) + customResponses.Credentials["api_base_urls"] = map[string]any{APIProtocolResponses: "https://example.test/v1"} + tests := []struct { name string platform string @@ -837,6 +840,36 @@ func TestBuildCodexModelsManifestForGroupUsesDeepSeekVisionCapabilities(t *testi accounts: []Account{newAccount(1, PlatformDeepseek, visionModel, nil)}, modalities: []any{"text", "image"}, }, + { + name: "Command Code bare ID", platform: PlatformCommandCode, + accounts: []Account{newAccount(1, PlatformCommandCode, "deepseek-v4.1-flash", nil)}, + modalities: []any{"text", "image"}, + }, + { + name: "Composite Command Code mapping", platform: PlatformComposite, + accounts: []Account{newAccount(1, PlatformCommandCode, "deepseek/deepseek-v4.1-flash", nil)}, + modalities: []any{"text", "image"}, + }, + { + name: "Command Code with a custom Responses endpoint", platform: PlatformCommandCode, + accounts: []Account{customResponses}, + modalities: []any{"text"}, + }, + { + name: "Command Code text-only override", platform: PlatformCommandCode, + accounts: []Account{newAccount(1, PlatformCommandCode, "deepseek/deepseek-v4.1-flash", []string{"text"})}, + modalities: []any{"text"}, + }, + { + name: "Command Code unknown model", platform: PlatformCommandCode, + accounts: []Account{newAccount(1, PlatformCommandCode, "unknown-model", nil)}, + modalities: []any{"text"}, + }, + { + name: "Command Code explicit vision metadata", platform: PlatformCommandCode, + accounts: []Account{newAccount(1, PlatformCommandCode, "other-model", []string{"text", "image"})}, + modalities: []any{"text", "image"}, + }, { name: "text-only DeepSeek Flash", platform: PlatformDeepseek, accounts: []Account{newAccount(1, PlatformDeepseek, "deepseek-v4-flash", nil)}, @@ -1129,6 +1162,7 @@ func TestBuildCodexModelsManifestForGroupLoadsAccountsOnce(t *testing.T) { require.Contains(t, repo.platforms, PlatformDeepseek) require.Contains(t, repo.platforms, PlatformMiniMax) require.Contains(t, repo.platforms, PlatformOpenCodeGo) + require.Contains(t, repo.platforms, PlatformCommandCode) require.NotContains(t, repo.platforms, PlatformComposite) }