Skip to content

About

Automated bug fixing with Google ADK

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bug Fix Agent

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.

🚀 Features

  • 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

🏗️ Architecture

The system consists of four specialized AI agents working in a loop:

  1. BugFixer Agent: Analyzes and corrects buggy Python code
  2. TestGenerator Agent: Creates test assertions to verify code correctness
  3. ValidatorAgent Agent: Executes code and tests to validate fixes
  4. RefineOrExit Agent: Decides whether to refine code further or exit the loop

📋 Prerequisites

  • Python 3.8 or higher
  • Google API key for Gemini models
  • Git

🛠️ Installation & Setup

1. Clone the Repository

git clone <your-github-repo-url>
cd <repository-name>

2. Create Virtual Environment (Recommended)

python -m venv .venv

3. Activate Virtual Environment

Windows (PowerShell):

.venv\Scripts\Activate.ps1

Windows (Command Prompt):

.venv\Scripts\activate.bat

macOS/Linux:

source .venv/bin/activate

4. Install Dependencies

pip install google-adk

5. Environment Configuration

Create a .env file in the project root:

GOOGLE_GENAI_USE_VERTEXAI=FALSE
GOOGLE_API_KEY=your_actual_api_key_here

Important: Replace your_actual_api_key_here with your actual Google API key.

6. Get Google API Key

  1. Go to Google AI Studio
  2. Create a new API key
  3. Copy the key and paste it in your .env file

🚀 Usage

Option 1: Web UI (Recommended for Beginners)

Launch the development web interface:

adk web

This will open a web browser where you can interact with the bug-fixing agent through a user-friendly interface.

Option 2: Command Line Interface

adk run

Option 3: API Server

adk api_server

Option 4: Programmatic Usage

from 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)

🔧 Configuration

Model Configuration

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 model

📝 Example Usage

Input: Buggy Code

def calculate_area(length, width):
    return length * length  # Bug: should be length * width

Output: Fixed Code

def calculate_area(length, width):
    return length * width

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

About

Automated bug fixing with Google ADK

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages