This document explains how the OpenFix Agent works, breaking down its structure and the step-by-step flow of how it autonomously solves GitHub issues.
OpenFix is an autonomous agent that:
- Ingests a GitHub repository.
- Reads an issue description.
- Finds relevant code.
- Generates a patch using Gemini.
- Validates the patch (optional).
It is built in Python and uses a modular architecture.
Here are the key components you need to know:
openfix/
├── agents/ # The "Brain" of the system
│ ├── solver/ # Core logic for solving issues
│ │ └── solver_agent.py # Main orchestrator
│ └── base_agent.py # Shared agent functionality
│
├── infrastructure/ # The "Tools" used by the agent
│ ├── llm_pool/ # LLM Client (Gemini API)
│ ├── code_graph/ # Code ingestion & chunking
│ ├── git/ # GitHub API interaction
│ └── validation/ # Scripts to test patches
│
├── data/ # The "Memory"
│ ├── db/ # SQLite database (openfix.db)
│ └── patches/ # Generated patch files
│
├── config/ # Configuration
│ └── config.yml # Settings (models, limits, paths)
│
└── scripts/ # Entry Points
└── run_e2e.py # Main script to run the agent
When you run python scripts/run_e2e.py, here is exactly what happens:
- Script:
scripts/run_e2e.py - Action: Loads
config.yml, connects to the SQLite database (data/database.py), and initializes theSolverAgent.
- Component:
infrastructure/code_graph/ingestion.py - Action:
- Clones the target GitHub repository to a temporary folder.
- Walks through all files, filtering out binaries and junk (like
node_modules). - Creates a single text representation of the codebase.
- Component:
infrastructure/code_graph/chunk_selector.py - Action:
- Splits the huge codebase text into smaller "chunks" (e.g., functions or classes).
- Compares these chunks to the Issue Title/Body.
- Selects the Top K (default 10) most relevant chunks to send to the AI.
- Component:
infrastructure/llm_pool/client.py - Action:
- Constructs a prompt containing:
- The Issue Description.
- The Selected Code Chunks.
- Instructions to generate a Git Patch.
- Sends this to Gemini Pro.
- Receives a JSON response containing the patch and an explanation.
- Constructs a prompt containing:
- Component:
agents/solver/solver_agent.py - Action:
- Extracts the diff from the LLM response.
- Saves it to
data/patches/issue-X/fix.patch. - Updates the database with the run results.
- Component:
infrastructure/validation/validate_patch.sh - Action:
- Tries to apply the patch.
- Runs tests (if configured).
- If validation fails, the agent can optionally feed the error back to Gemini to "repair" the patch (Self-Healing).
- Language: Python 3.11+
- Database: SQLite (Simple, file-based)
- AI Model: Google Gemini Pro (via
google-generativeaiSDK) - VCS: Git (via
GitPython)
- Modular: You can swap out the LLM or the Database without rewriting the agent.
- Traceable: Every run, token usage, and error is logged to the SQLite DB.
- Safe: Patches are generated in a separate folder, not directly applied to your main repo until you approve.