Skip to content

Commit 226ed99

Browse files
Assign default capabilities to Codex custom models (#1793)
1 parent c6f57a1 commit 226ed99

3 files changed

Lines changed: 40 additions & 17 deletions

File tree

apps/server/src/provider/Layers/ClaudeProvider.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ import { ClaudeProvider } from "../Services/ClaudeProvider";
2727
import { ServerSettingsService } from "../../serverSettings";
2828
import { ServerSettingsError } from "@t3tools/contracts";
2929

30+
const DEFAULT_CLAUDE_MODEL_CAPABILITIES: ModelCapabilities = {
31+
reasoningEffortLevels: [],
32+
supportsFastMode: false,
33+
supportsThinkingToggle: false,
34+
contextWindowOptions: [],
35+
promptInjectedEffortLevels: [],
36+
};
37+
3038
const PROVIDER = "claudeAgent" as const;
3139
const BUILT_IN_MODELS: ReadonlyArray<ServerProviderModel> = [
3240
{
@@ -87,13 +95,8 @@ const BUILT_IN_MODELS: ReadonlyArray<ServerProviderModel> = [
8795
export function getClaudeModelCapabilities(model: string | null | undefined): ModelCapabilities {
8896
const slug = model?.trim();
8997
return (
90-
BUILT_IN_MODELS.find((candidate) => candidate.slug === slug)?.capabilities ?? {
91-
reasoningEffortLevels: [],
92-
supportsFastMode: false,
93-
supportsThinkingToggle: false,
94-
contextWindowOptions: [],
95-
promptInjectedEffortLevels: [],
96-
}
98+
BUILT_IN_MODELS.find((candidate) => candidate.slug === slug)?.capabilities ??
99+
DEFAULT_CLAUDE_MODEL_CAPABILITIES
97100
);
98101
}
99102

@@ -450,7 +453,12 @@ export const checkClaudeProviderStatus = Effect.fn("checkClaudeProviderStatus")(
450453
Effect.map((settings) => settings.providers.claudeAgent),
451454
);
452455
const checkedAt = new Date().toISOString();
453-
const models = providerModelsFromSettings(BUILT_IN_MODELS, PROVIDER, claudeSettings.customModels);
456+
const models = providerModelsFromSettings(
457+
BUILT_IN_MODELS,
458+
PROVIDER,
459+
claudeSettings.customModels,
460+
DEFAULT_CLAUDE_MODEL_CAPABILITIES,
461+
);
454462

455463
if (!claudeSettings.enabled) {
456464
return buildServerProvider({

apps/server/src/provider/Layers/CodexProvider.ts

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,19 @@ import { CodexProvider } from "../Services/CodexProvider";
4949
import { ServerSettingsService } from "../../serverSettings";
5050
import { ServerSettingsError } from "@t3tools/contracts";
5151

52+
const DEFAULT_CODEX_MODEL_CAPABILITIES: ModelCapabilities = {
53+
reasoningEffortLevels: [
54+
{ value: "xhigh", label: "Extra High" },
55+
{ value: "high", label: "High", isDefault: true },
56+
{ value: "medium", label: "Medium" },
57+
{ value: "low", label: "Low" },
58+
],
59+
supportsFastMode: true,
60+
supportsThinkingToggle: false,
61+
contextWindowOptions: [],
62+
promptInjectedEffortLevels: [],
63+
};
64+
5265
const PROVIDER = "codex" as const;
5366
const OPENAI_AUTH_PROVIDERS = new Set(["openai"]);
5467
const BUILT_IN_MODELS: ReadonlyArray<ServerProviderModel> = [
@@ -159,13 +172,8 @@ const BUILT_IN_MODELS: ReadonlyArray<ServerProviderModel> = [
159172
export function getCodexModelCapabilities(model: string | null | undefined): ModelCapabilities {
160173
const slug = model?.trim();
161174
return (
162-
BUILT_IN_MODELS.find((candidate) => candidate.slug === slug)?.capabilities ?? {
163-
reasoningEffortLevels: [],
164-
supportsFastMode: false,
165-
supportsThinkingToggle: false,
166-
contextWindowOptions: [],
167-
promptInjectedEffortLevels: [],
168-
}
175+
BUILT_IN_MODELS.find((candidate) => candidate.slug === slug)?.capabilities ??
176+
DEFAULT_CODEX_MODEL_CAPABILITIES
169177
);
170178
}
171179

@@ -339,7 +347,12 @@ export const checkCodexProviderStatus = Effect.fn("checkCodexProviderStatus")(fu
339347
Effect.map((settings) => settings.providers.codex),
340348
);
341349
const checkedAt = new Date().toISOString();
342-
const models = providerModelsFromSettings(BUILT_IN_MODELS, PROVIDER, codexSettings.customModels);
350+
const models = providerModelsFromSettings(
351+
BUILT_IN_MODELS,
352+
PROVIDER,
353+
codexSettings.customModels,
354+
DEFAULT_CODEX_MODEL_CAPABILITIES,
355+
);
343356

344357
if (!codexSettings.enabled) {
345358
return buildServerProvider({

apps/server/src/provider/providerSnapshot.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type {
2+
ModelCapabilities,
23
ServerProvider,
34
ServerProviderAuth,
45
ServerProviderModel,
@@ -102,6 +103,7 @@ export function providerModelsFromSettings(
102103
builtInModels: ReadonlyArray<ServerProviderModel>,
103104
provider: ServerProvider["provider"],
104105
customModels: ReadonlyArray<string>,
106+
customModelCapabilities: ModelCapabilities,
105107
): ReadonlyArray<ServerProviderModel> {
106108
const resolvedBuiltInModels = [...builtInModels];
107109
const seen = new Set(resolvedBuiltInModels.map((model) => model.slug));
@@ -117,7 +119,7 @@ export function providerModelsFromSettings(
117119
slug: normalized,
118120
name: normalized,
119121
isCustom: true,
120-
capabilities: null,
122+
capabilities: customModelCapabilities,
121123
});
122124
}
123125

0 commit comments

Comments
 (0)