can1357/oh-my-pi · error · CliUsageError
--agents must be a positive integer
Error message
--agents must be a positive integer
What it means
Same validation as the cleanse command: omp compress runs its work across --agents concurrent agents, and only positive integers are valid concurrency. The check happens in run() before any files are processed.
Source
Thrown at packages/coding-agent/src/commands/compress.ts:33
rounds: Flags.integer({ char: "r", description: "Maximum drafts per file before giving up", default: 3 }),
agents: Flags.integer({ char: "n", description: "Files compressed concurrently", default: 4 }),
model: Flags.string({ char: "m", description: "Model selector" }),
};
static examples = [
"omp compress prompts/tools/read.md",
"omp compress notes.md -o notes.compressed.md",
"omp compress 'src/prompts/**/*.md' -i",
"omp compress a.md b.md c.md -i -n 8",
"omp compress spec.md -r 5 -m opus",
];
async run(): Promise<void> {
const { args, flags } = await this.parse(Compress);
const files = args.files ?? [];
if (files.length === 0) throw new CliUsageError("compress requires at least one file or glob pattern");
if (flags.rounds <= 0) throw new CliUsageError("--rounds must be a positive integer");
if (flags.agents <= 0) throw new CliUsageError("--agents must be a positive integer");
if (flags.inPlace && flags.out) throw new CliUsageError("--in-place and --out are mutually exclusive");
const result = await runCompressCommand({
files,
model: flags.model,
maxRounds: flags.rounds,
concurrency: flags.agents,
output: flags.out,
inPlace: flags.inPlace,
});
await postmortem.quit(result.exitCode);
}
}
View on GitHub (pinned to 9690622007)
Solutions
- Pass a positive integer, e.g. --agents 12
- Omit --agents to use the default concurrency
- Guard the computed value: Math.max(1, computedAgents)
Example fix
// before
const agents = Number(process.env.AGENTS ?? 0); // 0 when unset
omp compress spec.md --agents ${agents}
// after
const agents = Math.max(1, Number(process.env.AGENTS ?? 4)); Defensive patterns
Strategy: validation
Validate before calling
const agents = Math.max(1, Number(process.env.AGENTS ?? 4));
if (!Number.isInteger(agents)) throw new Error('agents must be an integer'); Type guard
function isPositiveInt(n) { return typeof n === 'number' && Number.isInteger(n) && n > 0; } Try / catch
try {
await Compress.run(['--agents', String(agents)]);
} catch (err) {
if (err instanceof CliUsageError && err.message.includes('--agents')) {
console.error(`Invalid --agents: ${agents}`);
process.exitCode = 1;
} else throw err;
} Prevention
- Default unset env-driven counts to a positive value
- Never encode 'disabled' as 0 for concurrency flags
- Sanity-check CI matrix values feeding the flag
When it happens
Trigger: 'omp compress spec.md --agents 0' or '--agents -1'; --agents sourced from an unset environment variable or a CI matrix value of 0.
Common situations: Dynamic concurrency computed as 0 when no workers are configured; typos; template placeholders left unfilled in CI pipelines.
Related errors
- No snippet provided. Pass inline text, --file <path>, or pip
- --agents must be a positive integer
- --rounds must be a positive integer
- --repaint must be a positive integer
- invalid {} argument: {}
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/0229fa8bc0527f09.
Report an issue: GitHub.