{"record":{"id":"a6cb7cc70c8b4166","repo":"can1357/oh-my-pi","slug":"cache-flags-require-cache","errorCode":null,"errorMessage":"Cache flags require --cache","messagePattern":"Cache flags require --cache","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/cli/bench-cli.ts","lineNumber":859,"sourceCode":"\treturn `${lines.join(\"\\n\")}\\n`;\n}\n\nfunction assertCacheModeSupported(targets: BenchTarget[]): void {\n\tif (targets.some(({ model }) => model.api === \"openai-codex-responses\")) {\n\t\tthrow new Error(\n\t\t\t\"--cache is not supported for openai-codex-responses because Codex WebSocket chaining cannot produce independent prompt-cache pairs\",\n\t\t);\n\t}\n}\n\nexport async function runBenchCommand(command: BenchCommandArgs, deps: BenchDependencies = {}): Promise<BenchSummary> {\n\tconst cacheMode = command.flags.cache === true;\n\tconst cacheFlagsUsed =\n\t\tcommand.flags.cachePrefixFile !== undefined ||\n\t\tcommand.flags.cachePrefixBytes !== undefined ||\n\t\tcommand.flags.cachePairs !== undefined ||\n\t\tcommand.flags.cacheConcurrency !== undefined;\n\tif (!cacheMode && cacheFlagsUsed) throw new Error(\"Cache flags require --cache\");\n\tif (cacheMode && command.flags.runs !== undefined)\n\t\tthrow new Error(\"Use --cache-pairs instead of --runs with --cache\");\n\tif (cacheMode && command.flags.prompt !== undefined) throw new Error(\"--cache builds its own stable-prefix prompts\");\n\tif (cacheMode && command.flags.profile !== undefined) throw new Error(\"--profile cannot be combined with --cache\");\n\tif (cacheMode && (command.flags.par ?? 1) > 1) {\n\t\tthrow new Error(\"--par cannot parallelize cold/warm pairs; use --cache-concurrency instead\");\n\t}\n\tconst profileFlag = command.flags.profile;\n\tif (\n\t\tprofileFlag !== undefined &&\n\t\tprofileFlag !== \"mix\" &&\n\t\tprofileFlag !== \"chat\" &&\n\t\tprofileFlag !== \"prefill\" &&\n\t\tprofileFlag !== \"generation\"\n\t) {\n\t\tthrow new Error(`Unknown --profile \"${profileFlag}\" (expected mix, chat, prefill, or generation)`);\n\t}\n\tconst profile: BenchProfile = profileFlag ?? \"mix\";","sourceCodeStart":841,"sourceCodeEnd":877,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/cli/bench-cli.ts#L841-L877","documentation":"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.","triggerScenarios":"`omp bench --cache-pairs 10` or `--cache-prefix-file x.md` without `--cache`.","commonSituations":"Copying a cache-mode command but dropping --cache; scripted invocations that append cache flags unconditionally.","solutions":["Add --cache to the command when you intend cache benchmarking.","Remove the stray cache-* flags if you want a normal benchmark.","Update the generating script so cache flags are gated on the --cache switch."],"exampleFix":"// before\nomp bench --cache-pairs 10\n// after\nomp bench --cache --cache-pairs 10","handlingStrategy":"validation","validationCode":"const cacheFlags = [\"cachePrefixFile\",\"cachePrefixBytes\",\"cachePairs\",\"cacheConcurrency\"] as const;\nif (!flags.cache && cacheFlags.some(k => flags[k] !== undefined)) {\n  throw new Error(\"cache flags require --cache\");\n}","typeGuard":"function cacheFlagsValid(flags: BenchFlags): boolean {\n  return flags.cache ||\n    (flags.cachePrefixFile === undefined && flags.cachePrefixBytes === undefined &&\n     flags.cachePairs === undefined && flags.cacheConcurrency === undefined);\n}","tryCatchPattern":"try {\n  await runBenchCommand(command);\n} catch (err) {\n  if (String(err) === \"Cache flags require --cache\") {\n    console.error(\"Add --cache or remove the cache-* flags\");\n  }\n  process.exitCode = 1;\n}","preventionTips":["Gate cache-* flags behind the --cache switch in wrapper scripts","Read `omp bench --help` to see flag groupings","Fail early in scripts by dry-parsing flags before spawning omp"],"tags":["cli","validation","arguments"],"backgroundTag":"missing-required-flag-combination","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}