An intelligent Python bug-fixing system that automatically detects, fixes, tests, and validates Python code using Google's ADK (Agent Development Kit) and Gemini AI models.
- Automated Bug Detection: Identifies issues in Python code
- Intelligent Code Fixing: Uses AI to automatically correct code problems
- Test Generation: Automatically creates test cases to verify fixes
- Code Validation: Runs code and tests to ensure correctness
- Iterative Refinement: Continuously improves code until all tests pass
- Multi-Agent Architecture: Specialized agents for different tasks
The system consists of four specialized AI agents working in a loop:
- BugFixer Agent: Analyzes and corrects buggy Python code
- TestGenerator Agent: Creates test assertions to verify code correctness
- ValidatorAgent Agent: Executes code and tests to validate fixes
- RefineOrExit Agent: Decides whether to refine code further or exit the loop
- Python 3.8 or higher
- Google API key for Gemini models
- Git
git clone <your-github-repo-url>
cd <repository-name>python -m venv .venvWindows (PowerShell):
.venv\Scripts\Activate.ps1Windows (Command Prompt):
.venv\Scripts\activate.batmacOS/Linux:
source .venv/bin/activatepip install google-adkCreate a .env file in the project root:
GOOGLE_GENAI_USE_VERTEXAI=FALSE
GOOGLE_API_KEY=your_actual_api_key_hereImportant: Replace your_actual_api_key_here with your actual Google API key.
- Go to Google AI Studio
- Create a new API key
- Copy the key and paste it in your
.envfile
Launch the development web interface:
adk webThis will open a web browser where you can interact with the bug-fixing agent through a user-friendly interface.
adk runadk api_serverfrom bugfix.agent import root_agent
# Your buggy Python code here
buggy_code = """
def add_numbers(a, b):
return a - b # Bug: should be addition, not subtraction
"""
# Run the bug fixing loop
result = root_agent.run(buggy_code)
print(result)The system uses gemini-2.0-flash by default. You can modify this in agent.py:
GEMINI_MODEL = "gemini-2.0-flash" # Change to your preferred modeldef calculate_area(length, width):
return length * length # Bug: should be length * widthdef calculate_area(length, width):
return length * width- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request