can1357/oh-my-pi · error

--cache builds its own stable-prefix prompts

Error message

--cache builds its own stable-prefix prompts

What it means

In --cache mode the bench harness constructs its own deterministic stable-prefix prompts sized for cache measurement (via --cache-prefix-bytes/-file), so a user-supplied --prompt would break the prefix protocol. The CLI rejects the combination at argument-validation time.

Source

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

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";
	if (!cacheMode && command.flags.prompt !== undefined && profile !== "chat" && profile !== "generation") {
		throw new Error("--prompt requires --profile chat or generation");
	}

View on GitHub (pinned to 9690622007)

Solutions

  1. Drop --prompt when using --cache
  2. Use --cache-prefix-bytes or --cache-prefix-file to control the stable-prefix content in cache mode
  3. Run a separate non-cache benchmark with --prompt --profile chat (or generation) if a custom prompt is needed

Example fix

// before
omp bench sonnet --cache --prompt "Explain quines"
// after
omp bench sonnet --cache --cache-prefix-bytes 20000
Defensive patterns

Strategy: validation

Validate before calling

if (useCacheMode && (args.prompt !== undefined)) throw new Error("--prompt is ignored in --cache mode; use --cache-prefix-bytes/--cache-prefix-file");

Try / catch

try {
  await runBench(argv);
} catch (err) {
  if (err instanceof Error && err.message.includes("stable-prefix prompts")) {
    console.error("Cache mode builds its own prompts; drop --prompt or use cache-prefix flags.");
    process.exitCode = 2;
  } else throw err;
}

Prevention

When it happens

Trigger: Running a bench command with both --cache and --prompt (e.g. `omp bench sonnet --cache --prompt "hello"`).

Common situations: Users who previously benchmarked a custom prompt with --runs --prompt now adding --cache; assuming --prompt customizes the cache-mode prefix content.

Related errors


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