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

Function disambiguateDuplicateLabels

sdk/coding-agent-cli/src/agent.ts:295–314  ·  view source on GitHub ↗
(
  choices: ModelChoice[],
  model: SDKModel
)

Source from the content-addressed store, hash-verified

293}
294
295function disambiguateDuplicateLabels(
296 choices: ModelChoice[],
297 model: SDKModel
298): ModelChoice[] {
299 const labelCounts = choices.reduce((counts, choice) => {
300 counts.set(choice.label, (counts.get(choice.label) ?? 0) + 1)
301 return counts
302 }, new Map<string, number>())
303
304 return choices.map((choice) => {
305 if ((labelCounts.get(choice.label) ?? 0) <= 1) {
306 return choice
307 }
308
309 const paramsLabel = formatParamsLabel(choice.value.params ?? [], model)
310 return paramsLabel
311 ? { ...choice, label: `${choice.label} - ${paramsLabel}` }
312 : choice
313 })
314}
315
316function dedupeModelChoices(choices: ModelChoice[]) {
317 const bySelection = new Map<string, ModelChoice>()

Callers 1

modelToChoicesFunction · 0.85

Calls 1

formatParamsLabelFunction · 0.85

Tested by

no test coverage detected