Yeachan-Heo/oh-my-codex · error · Error
Invalid worker count "${match[1]}". Expected ${MIN_WORKER_CO
Error message
Invalid worker count "${match[1]}". Expected ${MIN_WORKER_COUNT}-${DEFAULT_MAX_WORKERS}. What it means
Thrown when the first token matches the `<count>[:<agentType>]` pattern but the numeric count is outside MIN_WORKER_COUNT..DEFAULT_MAX_WORKERS (or not finite). The first token doubles as the worker-count specifier, so its count portion is range-validated before use.
Source
Thrown at src/cli/team.ts:859
}
export function parseTeamArgs(args: string[], cwd: string = process.cwd()): ParsedTeamArgs {
const tokens = [...args];
let workerCount = 3;
let agentType = 'executor';
let explicitAgentType = false;
let explicitWorkerCount = false;
if (tokens[0]?.toLowerCase() === 'ralph') {
throw new Error('Deprecated usage: `omx team ralph ...` has been removed. Use `omx team ...` or run `omx ralph ...` separately.');
}
const first = tokens[0] || '';
const match = first.match(/^(\d+)(?::([a-z][a-z0-9-]*))?$/i);
if (match) {
const count = Number.parseInt(match[1], 10);
if (!Number.isFinite(count) || count < MIN_WORKER_COUNT || count > DEFAULT_MAX_WORKERS) {
throw new Error(`Invalid worker count "${match[1]}". Expected ${MIN_WORKER_COUNT}-${DEFAULT_MAX_WORKERS}.`);
}
workerCount = count;
explicitWorkerCount = true;
if (match[2]) {
agentType = match[2];
explicitAgentType = true;
}
tokens.shift();
}
const task = tokens.join(' ').trim();
if (!task) {
throw new Error('Usage: omx team [N:agent-type] "<task description>"');
}
const followupContext = resolveApprovedTeamFollowupContext(cwd, task);
const effectiveTask = followupContext?.task ?? task;
if (followupContext) {View on GitHub (pinned to 3ad79a8a6f)
Solutions
- Use a count within MIN_WORKER_COUNT..DEFAULT_MAX_WORKERS as shown in the message (default is 3).
- If you didn't intend to set workers, remove the leading `N:` token — without it the default count applies.
- Omit the count entirely to accept the default: `omx team "do the thing"`.
Example fix
# before omx team 500:executor "run suite" # after omx team 8:executor "run suite" # within MIN_WORKER_COUNT..DEFAULT_MAX_WORKERS
Defensive patterns
Strategy: validation
Validate before calling
const m = (tokens[0] || '').match(/^(\d+)(?::([a-z][a-z0-9-]*))?$/i);
if (m) {
const n = Number.parseInt(m[1], 10);
if (!(n >= MIN_WORKER_COUNT && n <= DEFAULT_MAX_WORKERS)) {
console.error(`Worker count must be ${MIN_WORKER_COUNT}-${DEFAULT_MAX_WORKERS}`); process.exit(2);
}
} Type guard
function isValidWorkerToken(t: string): boolean {
const m = t.match(/^(\d+)(?::[a-z][a-z0-9-]*)?$/i);
if (!m) return true; // not a worker token
const n = Number.parseInt(m[1], 10);
return n >= MIN_WORKER_COUNT && n <= DEFAULT_MAX_WORKERS;
} Try / catch
try { await teamCommand(tokens); } catch (e) {
if (e instanceof Error && e.message.startsWith('Invalid worker count')) { /* drop leading count token to use default and retry */ }
else throw e;
} Prevention
- Omit the leading N: token unless you truly need a custom worker count.
- Read MIN_WORKER_COUNT/DEFAULT_MAX_WORKERS from the installed version before scripting counts.
When it happens
Trigger: `omx team 0 task`, `omx team 999 task`, or `omx team 99:executor task` when 99 exceeds DEFAULT_MAX_WORKERS.
Common situations: Assuming any worker count is allowed on bigger machines, porting configs from versions with a different max, or a leading number that was meant as part of the task text.
Related errors
- --keep-policy must be one of: score_improvement, pass_only
- Unknown capabilities subcommand: ${parsed.subcommand}
- Unknown capabilities option: ${arg}
- ${flag} requires a value
- Unknown hooks subcommand: ${subcommand}
AI-assisted analysis of Yeachan-Heo/oh-my-codex@3ad79a8a6f (2026-08-27).
Data as JSON: /api/errors/fd59d0bbd695f0e3.
Report an issue: GitHub.