feat(web): multi-phase review agent with per-file parallel LLM calls#1164
feat(web): multi-phase review agent with per-file parallel LLM calls#1164fatmcgav wants to merge 3 commits intosourcebot-dev:mainfrom
Conversation
Replace the per-chunk (N LLM calls) architecture with a two-phase approach: 1. A single MR summary pass over all changed files to detect cross-file semantic changes (renames, signature changes, removed exports, etc.) that individual file reviewers should be aware of. 2. Per-file LLM reviews that batch all hunks for a file into a single call, parallelised across files via a concurrency-capped pool (MAX_CONCURRENT_FILE_REVIEWS = 5). This reduces LLM calls from one-per-hunk to one-per-file (plus one summary call), while giving each file review the full picture via the MR summary context. Additional changes: - Export `validateLogPath` from `invokeDiffReviewLlm` for reuse in the summary node - Add "How it works" section to the review agent docs Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
WalkthroughIntroduces a two-phase review pipeline: a single MR-summary LLM pass over the entire PR, then per-file LLM review calls (parallelized, max 5 concurrent) that consume each file’s diffs, PR metadata, configured context, and the MR summary; documentation and prompts updated accordingly. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant ReviewAgent as Review Agent\n(generatePrReview)
participant MRLLM as LLM\n(MR Summary)
participant FileLLM as LLM\n(Per-file Reviews)
Client->>ReviewAgent: pr_payload
ReviewAgent->>MRLLM: generateMrSummary(pr_payload)\n(entire PR diff)
MRLLM-->>ReviewAgent: pr_summary context
ReviewAgent->>ReviewAgent: iterate files (parallel, max 5)
ReviewAgent->>FileLLM: per-file prompt + pr_summary + file diffs
FileLLM-->>ReviewAgent: file_diff_review (inline comments)
ReviewAgent-->>Client: aggregated file_diff_review[]
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsTimed out fetching pipeline failures after 30000ms Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
docs/docs/features/agents/review-agent.mdx (1)
6-23: ⚡ Quick winRewrite this new section in second person.
The new intro and How it works steps switch to third person (
the agent runs,the agent posts,it returns). Please recast this asyou/yourto match the docs voice.As per coding guidelines,
docs/**/*.mdxshould “write in second person present tense”.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@docs/docs/features/agents/review-agent.mdx` around lines 6 - 23, Rewrite the introduction and "How it works" steps to use second-person present-tense phrasing (you/your) instead of third-person; change sentences like "This agent provides", "When a review is triggered, the agent runs", "the agent posts", and "it returns nothing" to address the reader directly and use present tense, and update step headings and descriptions ("MR summary pass", "Per-file reviews", "Inline comments") so they read like instructions to the user (e.g., "You run a MR summary pass", "You run per-file reviews", "You post inline comments" or similar) while preserving the original meaning and sequence.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/web/src/features/agents/review-agent/nodes/generateMrSummary.ts`:
- Around line 31-32: The code incorrectly uses the undefined variable modelName
in the models.find call inside the REVIEW_AGENT_MODEL branch; update the
predicate to compare m.displayName === env.REVIEW_AGENT_MODEL so it matches the
condition and the later usage (replace the modelName reference with
env.REVIEW_AGENT_MODEL in the models.find call that resolves the model).
---
Nitpick comments:
In `@docs/docs/features/agents/review-agent.mdx`:
- Around line 6-23: Rewrite the introduction and "How it works" steps to use
second-person present-tense phrasing (you/your) instead of third-person; change
sentences like "This agent provides", "When a review is triggered, the agent
runs", "the agent posts", and "it returns nothing" to address the reader
directly and use present tense, and update step headings and descriptions ("MR
summary pass", "Per-file reviews", "Inline comments") so they read like
instructions to the user (e.g., "You run a MR summary pass", "You run per-file
reviews", "You post inline comments" or similar) while preserving the original
meaning and sequence.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ab12e7a3-a174-49f2-b51f-16607592ad85
📒 Files selected for processing (6)
docs/docs/features/agents/review-agent.mdxpackages/web/src/features/agents/review-agent/nodes/generateDiffReviewPrompt.tspackages/web/src/features/agents/review-agent/nodes/generateMrSummary.tspackages/web/src/features/agents/review-agent/nodes/generatePrReview.tspackages/web/src/features/agents/review-agent/nodes/gitlabMrParser.tspackages/web/src/features/agents/review-agent/nodes/invokeDiffReviewLlm.ts
Replace the per-chunk (N LLM calls) architecture with a two-phase approach:
semantic changes (renames, signature changes, removed exports, etc.)
that individual file reviewers should be aware of.
parallelised across files via a concurrency-capped pool
(MAX_CONCURRENT_FILE_REVIEWS = 5).
This reduces LLM calls from one-per-hunk to one-per-file (plus one summary
call), while giving each file review the full picture via the MR summary
context.
Additional changes:
validateLogPathfrominvokeDiffReviewLlmfor reuse in thesummary node
Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com
Summary by CodeRabbit
New Features
Improvements
Documentation