Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/app/api/providers/[id]/models/discovery/codex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,17 @@ function recordSupportsVision(record: JsonRecord): boolean {
return Array.isArray(record.input_modalities) && record.input_modalities.some(isImageModality);
}

function reasoningEffortValue(entry: unknown): string | null {
if (typeof entry === "string") return toNonEmptyString(entry);
const effort = asRecord(entry).effort;
return typeof effort === "string" ? toNonEmptyString(effort) : null;
}

function supportedThinkingEfforts(record: JsonRecord): string[] | undefined {
if (!Array.isArray(record.supported_reasoning_levels)) return undefined;
const efforts = record.supported_reasoning_levels.filter(
(effort): effort is string => typeof effort === "string" && effort.trim().length > 0
);
const efforts = record.supported_reasoning_levels
.map(reasoningEffortValue)
.filter((effort): effort is string => effort !== null);
return efforts.length > 0 ? efforts : undefined;
}

Expand Down
49 changes: 49 additions & 0 deletions tests/unit/provider-models-discovery-split.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,55 @@ test("codex.normalizeCodexGithubCatalogResponse parses current client catalog me
assert.equal(parsed[0]?.supportsVision, true);
});

test("codex catalog keeps reasoning tiers when upstream sends objects", () => {
const parsed = normalizeCodexModelsResponse({
models: [
{
slug: "gpt-6-sol",
display_name: "GPT 6 Sol",
visibility: "list",
supported_in_api: true,
supported_reasoning_levels: [
{ effort: "low" },
{ effort: "medium" },
{ effort: "high" },
{ effort: "xhigh" },
{ effort: "max" },
{ effort: "ultra" },
{ effort: "" },
{ value: "high" },
],
},
],
});

assert.equal(parsed[0]?.supportsThinking, true);
assert.deepEqual(parsed[0]?.supportedThinkingEfforts, [
"low",
"medium",
"high",
"xhigh",
"max",
"ultra",
]);
});

test("codex catalog ignores non-object reasoning entries", () => {
const parsed = normalizeCodexModelsResponse({
models: [
{
slug: "gpt-6-sol",
display_name: "GPT 6 Sol",
visibility: "list",
supported_in_api: true,
supported_reasoning_levels: [1, null, { effort: "high" }],
},
],
});

assert.deepEqual(parsed[0]?.supportedThinkingEfforts, ["high"]);
});

test("codex.enrichCodexModelsFromGithubCatalog keeps live entitlement list authoritative", () => {
const enriched = enrichCodexModelsFromGithubCatalog(
[
Expand Down
Loading