can1357/oh-my-pi · error

--budget must be a non-negative number

Error message

--budget must be a non-negative number

What it means

parseArgs validates a Terminal-Bench run configuration before any work starts. When --budget is provided it must be a finite, non-negative number; null means 'no budget'. This guard exists to fail fast at config-parse time instead of mid-run when costs are being tracked.

Source

Thrown at packages/metaharness/src/tb/cli.ts:214

				throw new Error(`unknown option: ${arg}`);
		}
	}

	if (config.help) return config;
	if (config.models.length === 0) throw new Error("at least one --model is required");
	for (const model of config.models) {
		const slash = model.indexOf("/");
		if (slash <= 0 || slash === model.length - 1) throw new Error(`invalid model ${model}; expected provider/model`);
	}
	for (const [flag, value] of [
		["--attempts", config.attempts],
		["--concurrency", config.concurrency],
		["--epochs", config.epochs],
	] as const) {
		if (!Number.isInteger(value) || value < 1) throw new Error(`${flag} must be a positive integer`);
	}
	if (config.budget !== null && (!Number.isFinite(config.budget) || config.budget < 0)) {
		throw new Error("--budget must be a non-negative number");
	}
	return config;
}

class Semaphore {
	#available: number;
	#queue: Array<() => void> = [];

	constructor(available: number) {
		this.#available = available;
	}

	async acquire(): Promise<void> {
		if (this.#available > 0) {
			this.#available--;
			return;
		}
		const { promise, resolve } = Promise.withResolvers<void>();

View on GitHub (pinned to 9690622007)

Solutions

  1. Pass a non-negative finite number for --budget, e.g. --budget=10
  2. Omit --budget (or pass null) entirely to run without a cost budget
  3. Check the shell/env variable feeding --budget for typos or empty values

Example fix

// before
parseArgs(["--budget", "-5"])
// after
parseArgs(["--budget", "5"])
Defensive patterns

Strategy: validation

Validate before calling

if (config.budget !== null && (!Number.isFinite(config.budget) || config.budget < 0)) throw new Error("--budget must be a non-negative number");

Type guard

function isValidBudget(b: unknown): b is number | null {
  return b === null || (typeof b === "number" && Number.isFinite(b) && b >= 0);
}

Prevention

When it happens

Trigger: Calling parseArgs (or the tb CLI) with --budget set to a negative number (e.g. --budget=-5), a non-finite value (NaN, Infinity), or a string that fails numeric parsing while budget !== null.

Common situations: Typo in a script passing '--budget=-1' to signal unlimited; shell variable interpolation producing an empty/garbage value; copy-pasted config with a negative cost cap.

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/9c107ae7cf263ecb. Report an issue: GitHub.