feat: improve context management for large PRs #10
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.
Summary
This PR fixes issues where the model would incorrectly flag files as 'missing' when they were either in the PR (but on page 2 of results) or pre-existing in the repository.
Changes
1. Fix GitHub API Pagination (root cause)
The PR files endpoint defaults to 30 files per page, but we weren't paginating. PRs with 31+ files were missing files from the analysis.
File:
review_roadmap/github/client.py_fetch_file_diffs()to request 100 files per page and paginate through all results2. Include Diff Content in LLM Context
The LLM was only seeing file names, not the actual code changes. This made it hard to understand imports and cross-file relationships.
File:
review_roadmap/agent/nodes.py_build_diffs_context()to include truncated diffs in the draft_roadmap prompt3. Better Context Expansion Prompt
Updated the prompt to explicitly tell the LLM it can fetch any file from the repo to verify imports exist.
Files:
review_roadmap/agent/prompts.py,review_roadmap/agent/tools.pyCONTEXT_EXPANSION_SYSTEM_PROMPTwith examples and clearer guidanceread_filetool docstring to clarify scopeTesting
Tested against jwm4/temperature_alert#1 which has 39 files:
tools/temperature.pyandtools/memory.pyAll 70 tests pass with 84% coverage.