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

runIfBenchCommand resolves optional numeric flags (turns, length, max-tokens, nya-max, par) through positiveInteger(), which throws if a flag was supplied but is not a positive integer. Absent flags fall back to defaults without error.

Source

Thrown at packages/coding-agent/src/if-bench/index.ts:56

	};
}

export interface IfBenchDependencies {
	createRuntime?: () => Promise<BenchRuntime>;
	streamSimple?: StreamSimpleFn;
	now?: () => number;
	randomSessionId?: () => string;
	sleep?: (ms: number) => Promise<void>;
	writeStdout?: (text: string) => void;
	writeStderr?: (text: string) => void;
	setExitCode?: (code: number) => void;
	stdoutIsTTY?: boolean;
}

function positiveInteger(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;
}

/** Resolve selectors, run every thread, and render the live board plus scoreboard. */
export async function runIfBenchCommand(
	command: IfBenchCommandArgs,
	deps: IfBenchDependencies = {},
): Promise<IfBenchSummary> {
	if (command.models.length === 0) {
		throw new Error("Pass at least one model selector, e.g. `omp if-bench opus gpt-5.2`");
	}
	const maxTurns = positiveInteger("turns", command.flags.turns, DEFAULT_TURNS);
	const arrayLength = positiveInteger("length", command.flags.length, DEFAULT_ARRAY_LENGTH);
	const maxTokens = positiveInteger("max-tokens", command.flags.maxTokens, DEFAULT_MAX_TOKENS);
	const nyaMax = positiveInteger("nya-max", command.flags.nyaMax, DEFAULT_NYA_MAX);
	const par = positiveInteger("par", command.flags.par, DEFAULT_PAR);
	const json = command.flags.json === true;

View on GitHub (pinned to 9690622007)

Solutions

  1. Supply positive integers for each flag (>= 1)
  2. Omit the flag to use its default instead of passing 0
  3. Pre-parse/validate values in wrapper scripts before invoking omp

Example fix

// before
omp if-bench opus --turns 0
// after
omp if-bench opus --turns 10
Defensive patterns

Strategy: validation

Validate before calling

function assertPositiveInt(name: string, v: number | undefined): void {
  if (v !== undefined && (!Number.isInteger(v) || v <= 0)) {
    throw new Error(`--${name} must be a positive integer`);
  }
}
["turns","length","maxTokens","nyaMax","par"].forEach(k => assertPositiveInt(k, flags[k]));

Type guard

function isPositiveInt(v: unknown): v is number {
  return typeof v === "number" && Number.isInteger(v) && v > 0;
}

Try / catch

try {
  await runIfBenchCommand(args);
} catch (err) {
  if (err instanceof Error && err.message.startsWith("Expected --")) {
    console.error(err.message);
    process.exitCode = 2;
  } else throw err;
}

Prevention

When it happens

Trigger: Passing `--turns 0`, `--par -3`, `--max-tokens 2.5`, or any non-positive/non-integer value for turns/length/max-tokens/nya-max/par on the `omp if-bench` command.

Common situations: Shell variables interpolating empty or malformed values; typos like `--turns 1.5`; testing degenerate configs such as zero turns.

Understand the failure class

Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.

Related errors


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