Skip to content

Commit 12771d8

Browse files
nadavisclaude
andcommitted
fix: surface truncation warning in PR comment, align word limit with max_tokens
- Track wasTruncated and append a visible blockquote warning to the posted comment so reviewers know the diff was cut off - Raise prompt word limit from 400 → 800 to be consistent with the 2048 max_tokens budget Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 52766cf commit 12771d8

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

scripts/ai-review.mjs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ async function runReview() {
2929
return;
3030
}
3131

32-
const truncatedDiff = prDiff.length > MAX_DIFF_CHARS
32+
const wasTruncated = prDiff.length > MAX_DIFF_CHARS;
33+
const truncatedDiff = wasTruncated
3334
? prDiff.slice(0, MAX_DIFF_CHARS) + "\n\n... [diff truncated]"
3435
: prDiff;
3536

@@ -45,7 +46,7 @@ Review the following git diff and provide concise, actionable feedback. Focus on
4546
4647
If the changes look good with no issues, say so briefly.
4748
Do NOT rewrite the code. Just review it.
48-
Keep your review under 400 words.
49+
Keep your review under 800 words.
4950
5051
## Git Diff:
5152
${truncatedDiff}`;
@@ -65,7 +66,7 @@ ${truncatedDiff}`;
6566
owner: repoOwner,
6667
repo: repoName,
6768
issue_number: prNumber,
68-
body: `## 🤖 Claude Code Review\n\n${review}\n\n---\n*Automated review by Claude Sonnet*`,
69+
body: `## 🤖 Claude Code Review\n\n${review}${wasTruncated ? "\n\n> ⚠️ **Note:** This diff exceeded 20,000 characters and was truncated. The review above covers only the first portion of the changes." : ""}\n\n---\n*Automated review by Claude Sonnet*`,
6970
});
7071

7172
console.log("Review posted successfully.");

0 commit comments

Comments
 (0)