Multi-Agent LangGraph system for automated code error research with self-correction capabilities.
- Research Agent - Searches web using DuckDuckGo (free, no API key!)
- Synthesis Agent - Analyzes results and creates solutions
- Quality Agent - Validates quality, triggers re-research if needed (self-correction loop)
- LangGraph - Multi-agent orchestration
- Groq API - Fast LLM inference (llama-3.1-70b)
- DuckDuckGo - Free web search (no API key required)
- FastAPI - REST API microservice
- Docker - Containerized deployment
- Python 3.11+
- Docker (optional)
- Groq API Key (Get free key)
mkdir code-research-assistant
cd code-research-assistantCopy all the generated files:
requirements.txt.envagents.pyapi.pyDockerfiledocker-compose.yml
Edit .env and add your Groq API key:
GROQ_API_KEY=gsk_your_actual_groq_api_key_herepip install -r requirements.txt# Test the agents directly
python agents.py
# Run the API
python api.py# Build and run
docker-compose up --build
# Run in background
docker-compose up -d
# View logs
docker-compose logs -f
# Stop
docker-compose downVisit: http://localhost:8000/docs
curl -X POST "http://localhost:8000/research" \
-H "Content-Type: application/json" \
-d '{
"code_snippet": "def divide(a, b):\n return a / b\n\nresult = divide(10, 0)",
"error_message": "ZeroDivisionError: division by zero"
}'{
"solution": "Root Cause: Division by zero...\nSolution: Add error handling...",
"quality_score": 9,
"iterations": 1,
"search_queries": ["python zerodivisionerror fix", "handle division by zero python"]
}User Input (Code + Error)
β
Research Agent (Web Search)
β
Synthesis Agent (Create Solution)
β
Quality Agent (Score Solution)
β
[Score < 7?] β YES β Loop back to Research (Self-Correction!)
β
[Score β₯ 7 OR 2 iterations?] β END
"Built a 3-agent system where each agent has a specific role: Research, Synthesis, and Quality validation."
"Implemented self-correction through conditional edges in LangGraph. The Quality agent can send work back to Research if the solution quality is below threshold."
"Automates the entire debugging workflow: searching Stack Overflow, reading documentation, synthesizing solutions - tasks that would take developers 20-30 minutes."
"Containerized with Docker for easy deployment. Can scale horizontally and integrate into existing DevOps pipelines."
- Rate limiting prevention (max 2 iterations)
- Error handling at each agent
- REST API with automatic documentation
- Environment-based configuration
- Lines of Code: ~250
- Agents: 3 (Research, Synthesis, Quality)
- Search Cost: $0 (DuckDuckGo is free!)
- Avg Response Time: 10-20 seconds
- Self-Correction: Up to 2 iterations
Edit agents.py:
llm = ChatGroq(
model="mixtral-8x7b-32768", # or other Groq models
temperature=0.3
)Edit should_continue() function in agents.py:
if score >= 8 or iteration >= 3: # More strictMake sure .env file exists and contains your key
Run: pip install -r requirements.txt
DuckDuckGo is free but rate-limited. For faster searches, consider Tavily API (paid).
- LangGraph Docs
- Groq API
- FastAPI Docs# Code-Research-assistant