can1357/oh-my-pi · error

Cache flags require --cache

Error message

Cache flags require --cache

What it means

Bench cache-pair flags (--cache-prefix-file, --cache-prefix-bytes, --cache-pairs, --cache-concurrency) are only meaningful in --cache mode. runBenchCommand throws if any of them is provided without --cache, preventing flags that would be silently ignored.

Source

Thrown at packages/coding-agent/src/cli/bench-cli.ts:859

	return `${lines.join("\n")}\n`;
}

function assertCacheModeSupported(targets: BenchTarget[]): void {
	if (targets.some(({ model }) => model.api === "openai-codex-responses")) {
		throw new Error(
			"--cache is not supported for openai-codex-responses because Codex WebSocket chaining cannot produce independent prompt-cache pairs",
		);
	}
}

export async function runBenchCommand(command: BenchCommandArgs, deps: BenchDependencies = {}): Promise<BenchSummary> {
	const cacheMode = command.flags.cache === true;
	const cacheFlagsUsed =
		command.flags.cachePrefixFile !== undefined ||
		command.flags.cachePrefixBytes !== undefined ||
		command.flags.cachePairs !== undefined ||
		command.flags.cacheConcurrency !== undefined;
	if (!cacheMode && cacheFlagsUsed) throw new Error("Cache flags require --cache");
	if (cacheMode && command.flags.runs !== undefined)
		throw new Error("Use --cache-pairs instead of --runs with --cache");
	if (cacheMode && command.flags.prompt !== undefined) throw new Error("--cache builds its own stable-prefix prompts");
	if (cacheMode && command.flags.profile !== undefined) throw new Error("--profile cannot be combined with --cache");
	if (cacheMode && (command.flags.par ?? 1) > 1) {
		throw new Error("--par cannot parallelize cold/warm pairs; use --cache-concurrency instead");
	}
	const profileFlag = command.flags.profile;
	if (
		profileFlag !== undefined &&
		profileFlag !== "mix" &&
		profileFlag !== "chat" &&
		profileFlag !== "prefill" &&
		profileFlag !== "generation"
	) {
		throw new Error(`Unknown --profile "${profileFlag}" (expected mix, chat, prefill, or generation)`);
	}
	const profile: BenchProfile = profileFlag ?? "mix";

View on GitHub (pinned to 9690622007)

Solutions

  1. Add --cache to the command when you intend cache benchmarking.
  2. Remove the stray cache-* flags if you want a normal benchmark.
  3. Update the generating script so cache flags are gated on the --cache switch.

Example fix

// before
omp bench --cache-pairs 10
// after
omp bench --cache --cache-pairs 10
Defensive patterns

Strategy: validation

Validate before calling

const cacheFlags = ["cachePrefixFile","cachePrefixBytes","cachePairs","cacheConcurrency"] as const;
if (!flags.cache && cacheFlags.some(k => flags[k] !== undefined)) {
  throw new Error("cache flags require --cache");
}

Type guard

function cacheFlagsValid(flags: BenchFlags): boolean {
  return flags.cache ||
    (flags.cachePrefixFile === undefined && flags.cachePrefixBytes === undefined &&
     flags.cachePairs === undefined && flags.cacheConcurrency === undefined);
}

Try / catch

try {
  await runBenchCommand(command);
} catch (err) {
  if (String(err) === "Cache flags require --cache") {
    console.error("Add --cache or remove the cache-* flags");
  }
  process.exitCode = 1;
}

Prevention

When it happens

Trigger: `omp bench --cache-pairs 10` or `--cache-prefix-file x.md` without `--cache`.

Common situations: Copying a cache-mode command but dropping --cache; scripted invocations that append cache flags unconditionally.

Related errors


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