Agentic System PR Reviewer
Built an autonomous LangGraph agentic pipeline that inspects GitHub Pull Requests, analyzes code diffs for security & logic flaws, and posts structured inline comments.
Overview
An automated developer tool powered by LangGraph cyclic agent graphs. It fetches GitHub PR diffs, executes multi-step static analysis, identifies security vulnerabilities, and posts contextual inline feedback on GitHub.
Problem
Manual code reviews consume significant engineering hours, particularly for catching recurring syntax bugs, missing error handles, and security anti-patterns.
Constraints
- Avoid hallucinated code suggestions by validating suggestions against actual AST diffs
- Respect GitHub REST & GraphQL API rate limits
- Stateful execution capable of evaluating multi-file pull requests
Approach
Designed a multi-agent LangGraph workflow in Python where specialized agent nodes handle syntax analysis, security checks, and comment formatting.
Key Decisions
Use LangGraph cyclic state graphs over linear LLM chains
LangGraph allows agents to re-evaluate output, check for false positives, and refine suggestions before executing GitHub API writes.
- Sequential LangChain chains
- Single-prompt GPT-4 calls
Tech Stack
- Python
- LangGraph
- LangChain
- OpenAI API
- GitHub API
- Docker
Result & Impact
- Instant PR AuditsFeedback Speed
- Cyclic State GraphAgent Pattern
- Static + LLM AnalysisVulnerability Catch
Automated routine PR review tasks, delivering instant feedback on pull requests and improving overall code quality.
Learnings
- Cyclic agent graphs drastically improve accuracy over single-pass LLM prompts.
- Formatting inline PR comments accurately requires precise line-offset mapping from git diffs.
Multi-Agent Review Workflow
The system treats PR review as a collaborative multi-agent process:
- Diff Collector Node: Fetches pull request files and parses unified git diff patches.
- Security Inspector Node: Scans changes for secret leaks, injection risks, and unhandled promises.
- Refiner Node: Evaluates proposed review comments for false positives and formats markdown suggestions.
- GitHub Publisher Node: Uses GitHub Webhooks and APIs to post comments directly to the pull request thread.