{"record":{"id":"32ec3bc97beb637b","repo":"Yeachan-Heo/oh-my-codex","slug":"agenttypes-length-must-be-1-or-workercount-rec","errorCode":null,"errorMessage":"agentTypes length must be 1 or ${workerCount}; received ${providers.length}.","messagePattern":"agentTypes length must be 1 or (.+?); received (.+?)\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/team/runtime-cli.ts","lineNumber":221,"sourceCode":"  const status = phase === 'complete' ? 'completed' : 'failed';\n  return {\n    output: buildCliOutput(stateRoot, teamName, status, workerCount, startTimeMs),\n    exitCode: status === 'completed' ? 0 : 1,\n    notice:\n      `[runtime-cli] phase=${phase} reached terminal state; preserving team state for inspection. `\n      + `Inspect with \"omx team status ${teamName} --json\" or \"omx team api read-stall-state --input '{\\\"team_name\\\":\\\"${teamName}\\\"}' --json\". `\n      + `Run \"omx team shutdown ${teamName}\" (or --force after state capture) when explicit cleanup is desired.\\n`,\n  };\n}\n\nexport function normalizeAgentTypes(raw: string[], workerCount: number): TeamWorkerProvider[] {\n  const providers = raw.map((entry) => String(entry || '').trim().toLowerCase());\n  const invalid = providers.filter((entry) => entry !== 'codex' && entry !== 'claude' && entry !== 'gemini');\n  if (invalid.length > 0) {\n    throw new Error(`Invalid agentTypes entries: ${invalid.join(', ')}. Expected codex|claude|gemini.`);\n  }\n  if (providers.length !== 1 && providers.length !== workerCount) {\n    throw new Error(`agentTypes length must be 1 or ${workerCount}; received ${providers.length}.`);\n  }\n  return providers as TeamWorkerProvider[];\n}\n\nexport function resolveRuntimeCliProviderMap(\n  raw: string[] | undefined,\n  workerCount: number,\n): string | null {\n  if (!Array.isArray(raw) || raw.length === 0) {\n    return null;\n  }\n  return normalizeAgentTypes(raw, workerCount).join(',');\n}\n\nexport function resolveRuntimeCliAgentType(raw: string | undefined): string {\n  const normalized = typeof raw === 'string' ? raw.trim() : '';\n  return normalized || 'executor';\n}","sourceCodeStart":203,"sourceCodeEnd":239,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/team/runtime-cli.ts#L203-L239","documentation":"normalizeAgentTypes requires the provider array length to be exactly 1 (broadcast to all workers) or exactly workerCount (per-worker assignment). Any other length — 0, 2 when there are 3 workers, or more than workerCount — throws this error. It fires only after all entries pass the codex|claude|gemini check.","triggerScenarios":"Passing 2 entries with workerCount 3, or an empty array (length 0 is neither 1 nor workerCount unless workerCount is 0).","commonSituations":"CLI flag lists fewer providers than --workers; partial config merge dropping entries; default worker count changed between versions making a previously valid array invalid.","solutions":["Pass a single entry to use the same provider for all workers, or exactly one entry per worker","Verify workerCount matches the number of --workers actually configured","Default to replicating a single entry across all workers before calling"],"exampleFix":"// before\nconst providers = normalizeAgentTypes(['codex','claude'], 3);\n// after\nconst raw = ['codex','claude'];\nconst providers = normalizeAgentTypes(raw.length === 1 ? raw : Array.from({length: 3}, (_, i) => raw[i % raw.length]), 3);","handlingStrategy":"validation","validationCode":"if (raw.length !== 1 && raw.length !== workerCount) {\n  raw = raw.length > 0 ? Array.from({length: workerCount}, (_, i) => raw[i % raw.length]) : ['codex'];\n}","typeGuard":null,"tryCatchPattern":"try { normalizeAgentTypes(raw, workerCount); } catch (e) { if (e instanceof Error && e.message.startsWith('agentTypes length')) { /* fill or trim to workerCount */ } throw e; }","preventionTips":["Derive provider list length from the same source as workerCount","Default to a single provider entry when unspecified"],"tags":["cli-validation","array-length","agent-providers"],"backgroundTag":"argument-count-mismatch","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}