{"record":{"id":"6273c831f52a6605","repo":"affaan-m/ECC","slug":"review-packet-exceeds-max-prompt-bytes-bytes","errorCode":null,"errorMessage":"review packet exceeds ${MAX_PROMPT_BYTES} bytes","messagePattern":"review packet exceeds (.+?) bytes","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"skills/council-multi-model/scripts/review-with-codex.js","lineNumber":184,"sourceCode":"    );\n  }\n  return versionMatch[1];\n}\n\nfunction buildEnvironment(sourceEnv = process.env) {\n  const allowed = [\n    'PATH', 'HOME', 'USERPROFILE', 'CODEX_HOME',\n    'TMPDIR', 'TMP', 'TEMP', 'SystemRoot', 'ComSpec', 'PATHEXT',\n  ];\n  return Object.fromEntries(\n    allowed.filter((name) => sourceEnv[name]).map((name) => [name, sourceEnv[name]])\n  );\n}\n\nfunction runReview(prompt, options, dependencies = {}) {\n  if (!prompt.trim()) throw new Error('review packet is empty');\n  if (Buffer.byteLength(prompt, 'utf8') > MAX_PROMPT_BYTES) {\n    throw new Error(`review packet exceeds ${MAX_PROMPT_BYTES} bytes`);\n  }\n  if (!options.consent) throw new Error('OpenAI transfer consent is required');\n  if (options.timeoutMs < 10_000 || options.timeoutMs > MAX_TIMEOUT_MS) {\n    throw new Error('timeout is outside the 10-120 second safety range');\n  }\n\n  const spawn = dependencies.spawnSync || spawnSync;\n  const environment = buildEnvironment(dependencies.env || process.env);\n  const verifySupport = dependencies.verifyToollessSupport || verifyToollessSupport;\n  verifySupport({ spawnSync: spawn, env: environment });\n  const makeTemp = dependencies.mkdtempSync || fs.mkdtempSync;\n  const readFile = dependencies.readFileSync || fs.readFileSync;\n  const remove = dependencies.rmSync || fs.rmSync;\n  const tempDir = makeTemp(path.join(os.tmpdir(), 'ecc-council-review-'));\n  const outputFile = path.join(tempDir, 'last-message.txt');\n\n  try {\n    const result = spawn('codex', buildCodexArgs(tempDir, outputFile), {","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/skills/council-multi-model/scripts/review-with-codex.js#L166-L202","documentation":"runReview refuses to forward a review packet larger than MAX_PROMPT_BYTES (65536 bytes, i.e. 64 KiB) to the external Codex CLI. The size is measured with Buffer.byteLength(prompt,'utf8') so multibyte content counts correctly. This is a hard safety cap that bounds what is shipped to OpenAI and keeps the subprocess input sane; it fires before any codex process is spawned.","triggerScenarios":"Calling runReview(prompt, options) (or runStdinReview, which delegates to it) where Buffer.byteLength(prompt,'utf8') strictly exceeds 65536. Note runStdinReview also short-circuits at the stdin-accumulation layer with a different message, but any direct programmatic call with an oversized joined string hits this throw at line 184.","commonSituations":"Piping a large git diff, build log, or concatenated source tree into the review packet; base64-encoding a binary artifact into the prompt; joining many review contexts without measuring; tests that construct a huge fixture string.","solutions":["Measure the packet first: if (Buffer.byteLength(packet,'utf8') > 65536) trim it before calling runReview.","Strip boilerplate, file headers, and unrelated context from the packet until it fits under 64 KiB.","Split one oversized review into several smaller packets and call runReview per chunk.","Drop base64/binary payloads and summarize them as text instead."],"exampleFix":"// before\nconst review = runReview(hugeDiff + hugeLog, opts);\n\n// after\nconst MAX = 64 * 1024;\nlet packet = hugeDiff + hugeLog;\nif (Buffer.byteLength(packet, 'utf8') > MAX) {\n  packet = packet.slice(0, MAX); // or split into multiple runReview calls\n}\nconst review = runReview(packet, opts);","handlingStrategy":"validation","validationCode":"const MAX_PROMPT_BYTES = 64 * 1024;\nfunction fitsReviewBudget(packet) {\n  return Buffer.isBuffer(packet)\n    ? packet.length <= MAX_PROMPT_BYTES\n    : Buffer.byteLength(packet, 'utf8') <= MAX_PROMPT_BYTES;\n}\n// before calling runReview:\nif (!fitsReviewBudget(packet)) {\n  throw new Error(`packet is ${Buffer.byteLength(packet,'utf8')} bytes; trim to <= ${MAX_PROMPT_BYTES}`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always measure with Buffer.byteLength(..., 'utf8') — string .length undercounts multibyte content.","Cap the stdin accumulator the way runStdinReview does, so oversized input never reaches runReview.","Log the byte count when building the packet so regressions in packet size show up early."],"tags":["validation","input-size","codex","limits"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}