Skip to content

Commit 895f185

Browse files
fix: enrich default models with SDK metadata instead of replacing
The SDK's supportedModels() returns a different set than our defaults — missing opus, including a "default" alias that duplicates sonnet. Instead of replacing our curated model list, enrich it with SDK capability metadata (supportsEffort, etc.) while keeping our list and display names as the source of truth. Fixes: Opus 4.6 disappearing and duplicate Sonnet 4.6 entries. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 6a35a56 commit 895f185

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

src/app/api/providers/models/route.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,21 +65,24 @@ export async function GET() {
6565
}),
6666
});
6767

68-
// If SDK has discovered models, use them for the env group
68+
// Enrich default models with SDK capability metadata (supportsEffort, etc.)
69+
// but keep our curated list and display names as the source of truth.
70+
// The SDK may return different aliases ("default"), missing models, or
71+
// different display names — we don't let that override our defaults.
6972
try {
7073
const { getCachedModels } = await import('@/lib/agent-sdk-capabilities');
7174
const sdkModels = getCachedModels('env');
7275
if (sdkModels.length > 0) {
73-
groups[0].models = sdkModels.map(m => {
74-
const cw = getContextWindow(m.value);
76+
const sdkByValue = new Map(sdkModels.map(m => [m.value, m]));
77+
groups[0].models = groups[0].models.map(m => {
78+
const sdk = sdkByValue.get(m.value);
79+
if (!sdk) return m;
7580
return {
76-
value: m.value,
77-
label: CLAUDE_MODELS[m.value as keyof typeof CLAUDE_MODELS]?.displayName ?? m.displayName,
78-
description: m.description,
79-
supportsEffort: m.supportsEffort,
80-
supportedEffortLevels: m.supportedEffortLevels,
81-
supportsAdaptiveThinking: m.supportsAdaptiveThinking,
82-
...(cw != null ? { contextWindow: cw } : {}),
81+
...m,
82+
description: sdk.description,
83+
supportsEffort: sdk.supportsEffort,
84+
supportedEffortLevels: sdk.supportedEffortLevels,
85+
supportsAdaptiveThinking: sdk.supportsAdaptiveThinking,
8386
};
8487
});
8588
}

0 commit comments

Comments
 (0)