{"record":{"id":"53f860f0ed63eddb","repo":"can1357/oh-my-pi","slug":"cache-builds-its-own-stable-prefix-prompts","errorCode":null,"errorMessage":"--cache builds its own stable-prefix prompts","messagePattern":"--cache builds its own stable-prefix prompts","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/cli/bench-cli.ts","lineNumber":862,"sourceCode":"function 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\";\n\tif (!cacheMode && command.flags.prompt !== undefined && profile !== \"chat\" && profile !== \"generation\") {\n\t\tthrow new Error(\"--prompt requires --profile chat or generation\");\n\t}","sourceCodeStart":844,"sourceCodeEnd":880,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/cli/bench-cli.ts#L844-L880","documentation":"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.","triggerScenarios":"Running a bench command with both --cache and --prompt (e.g. `omp bench sonnet --cache --prompt \"hello\"`).","commonSituations":"Users who previously benchmarked a custom prompt with --runs --prompt now adding --cache; assuming --prompt customizes the cache-mode prefix content.","solutions":["Drop --prompt when using --cache","Use --cache-prefix-bytes or --cache-prefix-file to control the stable-prefix content in cache mode","Run a separate non-cache benchmark with --prompt --profile chat (or generation) if a custom prompt is needed"],"exampleFix":"// before\nomp bench sonnet --cache --prompt \"Explain quines\"\n// after\nomp bench sonnet --cache --cache-prefix-bytes 20000","handlingStrategy":"validation","validationCode":"if (useCacheMode && (args.prompt !== undefined)) throw new Error(\"--prompt is ignored in --cache mode; use --cache-prefix-bytes/--cache-prefix-file\");","typeGuard":null,"tryCatchPattern":"try {\n  await runBench(argv);\n} catch (err) {\n  if (err instanceof Error && err.message.includes(\"stable-prefix prompts\")) {\n    console.error(\"Cache mode builds its own prompts; drop --prompt or use cache-prefix flags.\");\n    process.exitCode = 2;\n  } else throw err;\n}","preventionTips":["Never combine --prompt with --cache; route custom content through --cache-prefix-* flags","Assert flag exclusivity in CI scripts that generate bench commands"],"tags":["cli","flag-validation","mutually-exclusive-options"],"backgroundTag":"conflicting-cli-flags","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}