Repository navigation
Conversation
Oversized diffs made OpenAI-compatible backends reject the request. Compact keeps a file summary and as many file diffs as fit, and drops lock, minified, and binary file bodies.
Settings such as diff.noprefix, diff.external, or color.ui=always changed the output that the diff parser relies on.
The suggestion pipeline compacts every diff to this budget (default 40000) before building the prompt, for both commit and PR flows.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
lazycommit commitandlazycommit prsend the whole diff to the model with no size limit. With a large change set, OpenAI rejects the request (context length or tokens-per-minute limit). Retry and model fallback then resend the same oversized request, and the user just sees an error.What this changes
Diff.Compact(budget)ininternal/domain: a diff that fits the budget is sent unchanged. A larger diff becomes a list of changed files with +/- line counts, followed by every file diff that fits in full. Leftover space goes to the first file that did not fit, cut at a line boundary and marked[truncated].go.sum,package-lock.json,yarn.lock, ...), minified files, source maps, and binary files are listed without their diffs.max_diff_charssetting inprompts.yaml, default 40000 (about 10k tokens). It layers likenum_suggestions, so a repo-locallazycommit.prompts.yamlcan override it. Values below 1000 are raised to 1000 so the file list always fits.--no-color --no-ext-diff --src-prefix=a/ --dst-prefix=b/, so settings such asdiff.noprefix,diff.mnemonicPrefix,diff.external, orcolor.ui=alwayscannot change the format the parser reads.Behavior change: diffs larger than 40000 bytes are now shortened by default. If you use a large-context model, raise
max_diff_chars. There is no "off" value yet. I can add one (for example-1) if you want it.Testing
go test ./internal/...andgolangci-lint runpass.