can1357/oh-my-pi · error · CliUsageError

--agents must be a positive integer

Error message

--agents must be a positive integer

What it means

The omp cleanse command parallelizes its work across N agents, controlled by the --agents flag. A value of zero, negative, or non-numeric-parsed-zero cannot be used as concurrency, so the command rejects it up front with a CliUsageError before doing any work.

Source

Thrown at packages/coding-agent/src/commands/cleanse.ts:50

			char: "a",
			description: "Run every discovered checker without the interactive picker",
			default: false,
		}),
	};

	static examples = [
		"omp cleanse",
		"omp cleanse --all",
		'omp cleanse "ts errors"',
		"omp cleanse -n 8",
		"omp cleanse -m opus",
		"omp cleanse -t",
		"omp cleanse --agents 12 --model anthropic/claude-opus-4-6",
	];

	async run(): Promise<void> {
		const { args, flags } = await this.parse(Cleanse);
		if (flags.agents <= 0) throw new CliUsageError("--agents must be a positive integer");
		const result = await runCleanseCommand({
			maxAgents: flags.agents,
			model: flags.model,
			includeTests: flags.tests,
			request: args.request,
			all: flags.all,
		});
		await postmortem.quit(result.exitCode);
	}
}

View on GitHub (pinned to 9690622007)

Solutions

  1. Pass a positive integer, e.g. --agents 4
  2. If unset is desired, omit --agents entirely to use the command default
  3. Fix the shell/CI variable feeding the flag so it is >= 1

Example fix

// before
omp cleanse --agents 0 -t
// after
omp cleanse --agents 4 -t
Defensive patterns

Strategy: validation

Validate before calling

const agents = Number(rawAgents);
if (!Number.isInteger(agents) || agents <= 0) {
  throw new Error(`--agents must be a positive integer, got: ${rawAgents}`);
}

Type guard

function isPositiveInt(n) { return typeof n === 'number' && Number.isInteger(n) && n > 0; }

Try / catch

try {
  await Cleanse.run(['--agents', String(agents)]);
} catch (err) {
  if (err instanceof CliUsageError && err.message.includes('--agents')) {
    console.error(`Bad --agents value: ${agents}. Use an integer >= 1.`);
    process.exitCode = 1;
  } else throw err;
}

Prevention

When it happens

Trigger: Running 'omp cleanse --agents 0 ...' or 'omp cleanse --agents -3 ...'; also a shell variable expansion that resolves to an empty/zero value, e.g. --agents $AGENTS where AGENTS is unset or '0'.

Common situations: Scripting the command with a computed concurrency value that defaults to 0; typos like --agents=-1; forgetting the flag has no default meaning of 'unlimited'.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/c70d828ea0d066e6. Report an issue: GitHub.