fix: merge base snapshot models during enrichment to prevent catalog shrinkage

When enrichCursorSnapshot runs background capability discovery via
list_available_models, it may return fewer models than the initial
snapshot (which could have been built from session config fallback).
Previously, enrichment replaced all models with only the discovered set,
dropping models that were in the original snapshot but not in the
list_available_models response.

Now we merge: discovered models take precedence (with richer capability
info), but models from the base snapshot that aren't in the discovered
set are preserved.
This commit is contained in:
Cursor Agent committed 2026-06-03 16:17:36 +00:00
1 parent 97c5d15fab
commit 9bd61ebce7
1 file changed
+6 -1
@@ -1216,11 +1216,16 @@ export const enrichCursorSnapshot = (input: {
if (discoveredModels.length === 0) {
return Effect.void;
}
const discoveredSlugs = new Set(discoveredModels.map((m) => m.slug));
const mergedModels = [
...discoveredModels,
...baseSnapshot.models.filter((m) => !discoveredSlugs.has(m.slug)),
];
return publishSnapshot(
stampIdentity({
...baseSnapshot,
models: providerModelsFromSettings(
discoveredModels,
mergedModels,
PROVIDER,
settings.customModels,
EMPTY_CAPABILITIES,