{"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":"validation","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/8321021c54d670126ce3b2969d5deb880b4b0c2a/skills/council-multi-model/scripts/review-with-codex.js#L166-L202","documentation":"runReview() enforces a hard payload cap of MAX_PROMPT_BYTES (64 KiB) on the UTF-8 byte length of the review packet. Packets larger than 64 * 1024 bytes throw this error, protecting against oversized prompts to the Codex CLI. The stdin wrapper (runStdinReview) enforces the same limit incrementally.","triggerScenarios":"runReview(prompt, options) where Buffer.byteLength(prompt, 'utf8') > 65536 — e.g. piping a large git diff, long logs, or many files into the script.","commonSituations":"Reviewing a big PR diff without truncation; piping concatenated files; non-ASCII content (multi-byte UTF-8) pushing a modest-looking packet over the byte cap.","solutions":["Trim the packet to under 64 KiB before calling runReview (truncate the diff, review files in batches)","Use byte-aware truncation (Buffer.byteLength) rather than character length to account for multi-byte characters","Split the review into multiple smaller packets and run runReview per chunk","Summarize or filter the diff (e.g. `git diff --stat` plus key hunks) to reduce size"],"exampleFix":"// before\nconst review = runReview(hugeDiff, options); // throws >64KiB\n// after\nlet packet = hugeDiff;\nwhile (Buffer.byteLength(packet, 'utf8') > 64 * 1024) {\n  packet = packet.slice(0, Math.floor(packet.length * 0.9));\n}\nconst review = runReview(packet, options);","handlingStrategy":"validation","validationCode":"const { MAX_PROMPT_BYTES } = require('./review-with-codex');\nfunction packetFits(prompt) {\n  return Buffer.byteLength(prompt, 'utf8') <= MAX_PROMPT_BYTES;\n}\nif (!packetFits(packet)) packet = truncateToBytes(packet, MAX_PROMPT_BYTES);","typeGuard":null,"tryCatchPattern":"try {\n  return runReview(prompt, options);\n} catch (err) {\n  if (err.message.includes('review packet exceeds')) {\n    console.error('Packet too large; split or truncate to <= 65536 bytes');\n    return null;\n  }\n  throw err;\n}","preventionTips":["Measure size with Buffer.byteLength (UTF-8 bytes), not string length","Truncate diffs to relevant hunks before review","Batch large reviews into multiple packets","Reuse the exported MAX_PROMPT_BYTES constant in caller-side checks"],"tags":["validation","payload-size","limits","codex"],"backgroundTag":"payload-too-large","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}