fix(multi-review): filter lock files from PR diff to prevent LLM context overflow#195
Conversation
…ext overflow Lock files (pnpm-lock.yaml, bun.lock, package-lock.json, yarn.lock, etc.) can push diffs past 1MB. The entire diff was sent inline as a single text part to each reviewer, exceeding model request limits and causing all 4 reviewers to fail with 'Unexpected server error'. Add diff-filter.ts that parses unified diff headers and strips sections for files matching known lock file / auto-generated patterns. Apply the filter in index.ts before the diff reaches the LLM. Fixes #194
|
Let me verify the issues against the current code first. 最终决策:可合并 / CAN MERGE 所有 4 位 reviewer 均同意合并,无阻塞项。该 PR 功能清晰、实现轻量、测试覆盖完整,且实际上通过过滤大锁文件改善了整体性能。 阻塞项:无 / Blocking Issues: None 建议项 / Suggestions:
📋 各 Reviewer 详细审查结果quality可合并 / CAN MERGE 总结此 PR 在 multi-review action 中添加了 阻塞项:无建议项
security安全无虞 / SECURE 该 PR 实现了从 PR diff 中过滤锁定文件(lock files)的功能,用于控制 LLM 请求大小。代码逻辑简单清晰,仅对 diff 文本进行字符串分割和正则匹配,不涉及数据库查询、外部命令执行或网络请求。
阻塞项:无 建议项:无 performance性能良好 / GOOD 该 PR 的主要变更(
阻塞项:无 建议项:
architecture架构合理 / SOUND 该 PR 引入 分析要点:
阻塞项:无 建议项:
|
|
无遗漏 分析总结: PR 实现了 Issue #194 中建议的方案一(硬编码排除列表)。具体实现了:
Issue #194 中列出的三个建议为或选方案("1. ... 2. Or ... 3. Or ..."),PR 选择方案一实现完整,所有被提及的锁文件类型均已覆盖,集成路径正确,无遗漏。 |

Repro
PR with
pnpm-lock.yaml(790KB) +bun.lock(411KB) = ~1.2MB total diff. The multi-review action loads the full diff (PR diff loaded from pre-fetched file: 1207658 chars) and concatenates it inline into a single text part sent to all 4 reviewers. Within ~280ms, every reviewer fails withUnexpected server error— the request body exceeds model limits.Cause
orchestrator.ts:76constructs the prompt by appending the rawprDiffstring directly:No filtering occurs between diff load and LLM submission. Lock files routinely exceed 500KB each, pushing total diff well past typical model request body limits.
Fix
multi-review/src/diff-filter.ts— Parses unified diff headers, extracts basenames fromdiff --git a/<path> b/<path>lines, and strips sections for files matching lock/auto-generated patterns (*.lock,*.lockb,pnpm-lock.yaml,yarn.lock,package-lock.json,bun.lock,go.sum,Cargo.lock,Gemfile.lock,uv.lock,poetry.lock,composer.lock,Pipfile.lock,requirements.lock,flake.lock).multi-review/src/index.ts— CallsfilterDiff()after diff load, logs excluded files, passes filtered diff to reviewers.multi-review/src/diff-filter.test.ts— 14 tests covering lock file patterns, nested paths, empty diffs, all-lock-file diffs, and non-lock files with "lock" in the name.multi-review/package.json— Addsdiff-filter.test.tsto test script.multi-review/dist/index.cjs— Regenerated bundle.Verification
Fixes #194