MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / recommendSubagent

Function recommendSubagent

src/setup/model-detector.ts:309–329  ·  view source on GitHub ↗
(models: DetectedModel[], parent: DetectedModel)

Source from the content-addressed store, hash-verified

307 * - Prefer something a bit smaller than parent (faster spin-up, lighter load)
308 */
309export function recommendSubagent(models: DetectedModel[], parent: DetectedModel): DetectedModel | undefined {
310 const candidates = models.filter(m => m.id !== parent.id);
311 if (candidates.length === 0) return undefined;
312 const parentParams = parent.paramsB ?? 0;
313 const sorted = [...candidates].sort((a, b) => {
314 // Different runtime = real parallel
315 const aDiff = a.source !== parent.source ? 1 : 0;
316 const bDiff = b.source !== parent.source ? 1 : 0;
317 if (aDiff !== bDiff) return bDiff - aDiff;
318 // Tool calling
319 const aTC = a.toolCallsLikely ? 1 : 0;
320 const bTC = b.toolCallsLikely ? 1 : 0;
321 if (aTC !== bTC) return bTC - aTC;
322 // Closer to (parent - 30%) is ideal — "a bit smaller"
323 const target = parentParams * 0.7;
324 const aDist = Math.abs((a.paramsB ?? 0) - target);
325 const bDist = Math.abs((b.paramsB ?? 0) - target);
326 return aDist - bDist;
327 });
328 return sorted[0];
329}
330
331/** Pretty-format a detected model for display in the wizard list. */
332export function formatModel(m: DetectedModel): { label: string; hint: string } {

Callers 1

runSetupFunction · 0.85

Calls 1

absMethod · 0.80

Tested by

no test coverage detected