fix: cap aggregate untracked content in review context (#405)#461
Open
ayobamiseun wants to merge 1 commit into
Open
fix: cap aggregate untracked content in review context (#405)#461ayobamiseun wants to merge 1 commit into
ayobamiseun wants to merge 1 commit into
Conversation
collectWorkingTreeContext inlined every untracked file (24KB per-file cap, no total cap) into the Untracked Files section - in both the inline-diff and lightweight paths. With enough untracked files the assembled prompt exceeded Codex's 1,048,576-character input limit and adversarial-review died with an opaque "Input exceeds the maximum length" error. Track a running byte budget (default 256KB, matching the inline diff cap) across the untracked section. Once the next entry would exceed it, stop inlining and append a visible notice with the omitted count, pointing at the Git Status section (which still names every file) and suggesting how to narrow the review. Fixes openai#405
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.
Fixes #405
Problem
collectReviewContextbounds the inline diff (256KB) and each untracked file (24KB), but never bounds the total Untracked Files section. The section is also inlined even in the lightweightincludeDiff: falsepath, so themaxInlineDiffBytesheuristic never protects it. With enough untracked files the two independently-bounded sections compose into an unbounded prompt andadversarial-reviewdies with the opaque model-layer error:Repro
Repo with 300 untracked text files just under the 24KB per-file cap (mirrors the issue's real case of 309 files):
Fix
New
formatUntrackedSectiontracks a running byte budget across the untracked entries — default 256KB (DEFAULT_UNTRACKED_TOTAL_MAX_BYTES, matching the existing inline-diff cap), overridable viacollectReviewContext(..., { maxUntrackedTotalBytes }). Once the next entry would exceed the budget, it stops inlining and appends a visible notice instead of failing downstream:Nothing becomes silently invisible: the Git Status section (
--untracked-files=all) still names every untracked file, and skip markers (directory/binary/oversized) count toward the budget too. This is option 1 of the fixes suggested in the issue.Tests
collectReviewContext caps aggregate untracked content instead of growing unbounded— cap kicks in, omission notice present, Git Status still lists omitted files.collectReviewContext keeps all untracked content when under the aggregate cap— no behavior change for small trees.resolveStateDir uses a temp-backed per-workspace directory) fails identically onmainwhen run inside a live Claude Code session (pre-existing Test suite is not hermetic inside a live Claude Code session: 4 failures at HEAD + fixture state leaks into the user's real plugin data dir #455, unrelated).