Handle buffer overflows gracefully and truncate diffs fairly (#5083)
- Gracefully fall back to file-name summaries when staged diffs exceed node/ssh execution maxBuffer limits, preventing generation failures. - Split oversized diffs by file and allocate budget via water-filling, ensuring single huge files do not starve smaller human changes. - Clip truncated diff sections on line boundaries to avoid half-lines.
This commit is contained in:
@@ -35,7 +35,11 @@ export function buildCommitMessagePrompt(
|
||||
context: CommitMessageDraftContext,
|
||||
customPrompt: string
|
||||
): string {
|
||||
const patch = truncateDiffForPrompt(context.stagedPatch)
|
||||
// Why: the staged patch is dropped when it's too large to read, so fall back to
|
||||
// the file summary and tell the agent why the diff is missing.
|
||||
const patch = context.stagedPatch.trim()
|
||||
? truncateDiffForPrompt(context.stagedPatch)
|
||||
: '(diff omitted — too large to read; infer the change from the staged file list above)'
|
||||
const base = [
|
||||
'You are generating a single git commit message.',
|
||||
'Return only the commit message text. Do not include a preamble, quotes, or code fences.',
|
||||
|
||||
Reference in New Issue
Block a user