ec67a0636196258ea767458c89828037b8cbca07
LangGraph Code Review Agent
This repository implements a LangGraph agent that performs a code review on a Python function. The graph consists of three nodes:
- draft_review – generates an initial review.
- reflect – a critic that scores the review on four criteria (PEP8, type hints, edge cases, naming) and decides whether a rewrite is required.
- rewrite – rewrites the weakest part of the review.
The graph runs for a maximum of max_rounds (default 2). The demo can be executed with python -m main.
Requirements
langgraph>=0.2.0
langchain-openai>=0.2.0
python-dotenv>=1.0.0
Usage
# Install dependencies
pip install -r requirements.txt
# Run the demo
python -m main
The demo uses a simple sort_numbers function. The output shows the final review, the scores for each criterion, the verdict, and the number of rounds performed.
Environment Variables
The agent uses OpenAI. Set the OPENAI_API_KEY environment variable before running.
Description
Languages
Python
100%