[NoQA][AI Reviewer] Fix file content exceeds maximum allowed tokens#72950
Conversation
Fix Summary: AI Reviewer Token Limit ErrorsProblemThe AI reviewer agents were failing with token limit errors when trying to review PRs that modified large files: From the error report:
Solution1. Updated Code Inline Reviewer AgentFile: Changes:
Key Instructions Added: 2. **For analyzing changed files:**
- **For large files (>5000 lines):** Use the Grep tool instead of reading entire file
- **For smaller files:** You may read the full file using the Read tool
- **If a Read fails with token limit error:** Immediately switch to Grep
3. **Search strategy for large files:**
- PERF-1: Search for `renderItem` and `...` patterns
- PERF-2: Search for `.every(`, `.some(`, `.find(`, `.filter(`
- PERF-3: Search for `useOnyx` within renderItem components
- PERF-4: Search for `useMemo`, `useCallback` patterns
- PERF-5: Search for `React.memo` and `deepEqual`
- PERF-6: Search for hook dependency arrays2. Updated HelpDot Inline Reviewer AgentFile: Changes:
How It Works NowBefore (Failed)After (Fixed)Expected ImpactImmediate Benefits
Error Rate ReductionFrom your error report:
Affected Files That Will Now WorkThese large files will no longer cause failures:
Testing Recommendations1. Test with a Known Large File PRCreate or find a PR that modifies
2. Monitor Next 10 PR ReviewsWatch for:
3. Check Agent Execution TimeLarge file PRs should now be:
|
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppNA Android: mWeb ChromeNA iOS: HybridAppNA iOS: mWeb SafariNA MacOS: Chrome / SafariNA MacOS: DesktopNA |
|
@mountiny, PR is ready to be merged and further tested 🚀 |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/mountiny in version: 9.2.41-0 🚀
|
|
🚀 Deployed to production by https://github.com/puneetlath in version: 9.2.41-6 🚀
|
Explanation of Change
Fixes handling of too large files for AI reviewer. For more see summary in comment below.
Fixed Issues
$ #72802
PROPOSAL: #72802 (comment)
Tests
Create or find a PR that modifies src/CONST/index.ts and verify:
Offline tests
QA Steps
// TODO: These must be filled out, or the issue title must include "[No QA]."
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop