fix: review skipped silently when task diff exceeds 1MB maxBuffer

getCommitRangeDiff and getLatestCommitDiff had maxBuffer set to 1MB.
When a task produced a larger diff (common for 10+ minute tasks),
execSync threw, the catch block returned null, and the review loop
broke immediately with no message — reviews were silently skipped for
larger tasks while smaller tasks reviewed fine.

- Increase maxBuffer to 10MB in both functions (the review prompt
  builder already truncates to MAX_DIFF_BYTES = 50KB before sending
  to the model, so the full diff in memory is fine)
- Add a diagnostic sendChatMessage when the review loop is skipped
  (baseRef undefined or no diff), so silent skips are visible
This commit is contained in:
2026-07-22 21:53:29 -04:00
parent 74c9ead7af
commit 6dcbd064a6
2 changed files with 17 additions and 4 deletions

View File

@@ -877,7 +877,15 @@ async function executeTask(
const reviewInfo = baseRef
? getCommitRangeDiff(worktreeDir, baseRef)
: null;
if (!reviewInfo || !reviewInfo.diff) break; // nothing to review
if (!reviewInfo || !reviewInfo.diff) {
const reason = !baseRef
? "could not capture base ref before execution"
: "no changes found between base and HEAD";
sendChatMessage?.(
`~ review for ${task.id} · ${task.title} — skipping review (${reason})`,
);
break;
}
const reviewPrompt = buildReviewPrompt(
task,

View File

@@ -795,11 +795,12 @@ export function getLatestCommitDiff(
encoding: "utf-8",
}).trim();
// Full diff of the latest commit: stat overview + patch
// Full diff of the latest commit: stat overview + patch.
// maxBuffer set high — the prompt builder truncates to MAX_DIFF_BYTES.
const diff = execSync("git show HEAD --stat --patch", {
cwd: projectDir,
encoding: "utf-8",
maxBuffer: 1024 * 1024,
maxBuffer: 10 * 1024 * 1024,
}).trim();
return { hash, subject, diff };
@@ -868,10 +869,14 @@ export function getCommitRangeDiff(
// Diff from baseRef to HEAD — shows all committed changes made since
// the snapshot. Includes stat overview + full patch.
//
// maxBuffer is set high (10 MB) so larger tasks don't cause execSync to
// throw. The review prompt builder truncates to MAX_DIFF_BYTES (50 KB)
// before sending to the model, so the full diff in memory is fine.
const diff = execSync(`git diff ${baseRef} HEAD --stat --patch`, {
cwd: projectDir,
encoding: "utf-8",
maxBuffer: 1024 * 1024,
maxBuffer: 10 * 1024 * 1024,
}).trim();
if (!diff) return null; // no changes since baseRef