can1357/oh-my-pi · error
Expected --${name} to be a positive integer, got ${value}
Error message
Expected --${name} to be a positive integer, got ${value} What it means
normalizePositiveInteger validates bench CLI numeric flags (--runs, --max-tokens, --par, --cache-pairs, --cache-bytes, --cache-concurrency). It throws when a provided value is not a positive integer (non-integer or <= 0). Fallbacks apply only when the flag is omitted.
Source
Thrown at packages/coding-agent/src/cli/bench-cli.ts:271
writeStderr?: (text: string) => void;
setExitCode?: (code: number) => void;
streamSimple?: StreamSimpleFn;
now?: () => number;
/** Uniform [0,1) source for challenge randomization; default `Math.random`. */
random?: () => number;
readTextFile?: (path: string, maxBytes: number) => Promise<string>;
stdoutIsTTY?: boolean;
}
function getErrorMessage(error: unknown): string {
if (error instanceof Error && error.message) return error.message;
return String(error);
}
function normalizePositiveInteger(name: string, value: number | undefined, fallback: number): number {
if (value === undefined) return fallback;
if (!Number.isInteger(value) || value <= 0) {
throw new Error(`Expected --${name} to be a positive integer, got ${value}`);
}
return value;
}
function closeProviderSessionStates(providerSessionState: Map<string, ProviderSessionState>): void {
for (const state of providerSessionState.values()) {
state.close();
}
providerSessionState.clear();
}
function isFirstTokenEvent(event: AssistantMessageEvent): boolean {
switch (event.type) {
case "text_delta":
case "thinking_delta":
case "toolcall_delta":
return event.delta.length > 0;
case "text_end":View on GitHub (pinned to 9690622007)
Solutions
- Pass a positive whole number for the flag (>= 1).
- Remove the flag to use the built-in default fallback.
- Fix the generating script so it computes a valid integer.
Example fix
// before omp bench --runs 0 // after omp bench --runs 5
Defensive patterns
Strategy: validation
Validate before calling
function parsePositiveInt(raw: string): number {
const n = Number(raw);
if (!Number.isInteger(n) || n <= 0) throw new Error(`--flag must be a positive integer, got ${raw}`);
return n;
} Type guard
function isPositiveInt(v: unknown): v is number {
return typeof v === "number" && Number.isInteger(v) && v > 0;
} Try / catch
try {
await runBenchCommand(command);
} catch (err) {
if (String(err).startsWith("Expected --")) {
console.error("All numeric bench flags must be integers >= 1");
}
process.exitCode = 1;
} Prevention
- Validate numeric args in wrapper scripts before invoking omp bench
- Avoid computing flags with expressions that can yield 0/NaN
- Check `omp bench --help` for flag defaults
When it happens
Trigger: Passing e.g. `--par 0`, `--runs -1`, `--cache-concurrency 2.5`, or a non-numeric string coerced to NaN to `omp bench`.
Common situations: Typing `--par 0` expecting unlimited; copy-pasting fractional values; scripts computing values that become 0 or NaN.
Related errors
- Cache flags require --cache
- --alias requires --profile <name> or OMP_PROFILE
- Expected --${name} to be a positive integer, got ${value}
- Pass at least one model selector, e.g. `omp if-bench opus gp
- at least one --model is required
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/116965fd407bedee.
Report an issue: GitHub.