MCPcopy Create free account
hub / github.com/cursor/cookbook / dedupeModelChoices

Function dedupeModelChoices

sdk/coding-agent-cli/src/agent.ts:316–335  ·  view source on GitHub ↗
(choices: ModelChoice[])

Source from the content-addressed store, hash-verified

314}
315
316function dedupeModelChoices(choices: ModelChoice[]) {
317 const bySelection = new Map<string, ModelChoice>()
318
319 for (const choice of choices) {
320 const key = modelSelectionKey(choice.value)
321 const existing = bySelection.get(key)
322
323 if (!existing) {
324 bySelection.set(key, choice)
325 continue
326 }
327
328 bySelection.set(key, {
329 ...existing,
330 description: existing.description ?? choice.description,
331 })
332 }
333
334 return Array.from(bySelection.values())
335}
336
337function disambiguateGlobalDuplicateLabels(choices: ModelChoice[]) {
338 const labelCounts = choices.reduce((counts, choice) => {

Callers 2

listModelsMethod · 0.85
modelToChoicesFunction · 0.85

Calls 1

modelSelectionKeyFunction · 0.85

Tested by

no test coverage detected