Repository Configuration Overrides
Relevant source files
The following files were used as context for generating this wiki page:
Repository Configuration Overrides allow individual repositories to customize the behavior of the PR-Agent tool. While global settings are inherited from the central JWEB0689/pr-agent-settings repository, specific repositories define local .pr_agent.toml files to supersede these defaults.
The system uses a layered configuration approach where PR-Agent first loads global settings and then applies repository-specific overrides during Pull Request analysis. This mechanism ensures consistent standards across the fleet while providing the flexibility needed for different project requirements, such as unique test runners or specific review guidelines.
Sources: README.md:1-12
Configuration Hierarchy
The PR-Agent infrastructure follows a strict inheritance model. Global settings reside in the central configuration file, which PR-Agent automatically discovers for all repositories owned by the organization. Local overrides occur when a repository includes its own configuration file.
Inheritance Flow
- Global Settings: PR-Agent fetches
.pr_agent.tomlfrom theJWEB0689/pr-agent-settingsrepository. - Local Overrides: If the target repository contains a
.pr_agent.tomlfile, those values replace corresponding global settings. - Runtime Context: Scripts like
autofix.pyutilize the final resolved configuration to interact with the GitHub API and Generative AI models.
The following diagram illustrates how global settings and local overrides merge to form the active configuration.
Sources: README.md:5-15, scripts/autofix.py:38-45
Automated Fixer Integration
The autofix.py script acts as an autonomous consumer of the configuration, applying repairs based on PR-Agent findings or CI failures. It detects the local repository environment to determine the appropriate validation commands.
Environment-Based Detection
The script identifies the repository layout to select the correct test runner. This allows overrides in behavior based on the presence of specific project files.
| File Detected | Test/Check Command | Directory |
|---|---|---|
v2/Cargo.toml | cargo check --workspace --no-default-features | v2 |
ui/mobile/package.json | npm test --if-present | ui/mobile |
Cargo.toml | cargo check --workspace | . |
package.json | npm test or npm run build | . |
pyproject.toml | pytest -q | . |
go.mod | go test ./... | . |
Sources: scripts/autofix.py:73-95
Workflow Logic
The autofix.py script operates in two primary modes: review-fix and ci-fix. It uses the configuration to communicate with the Gemini API and GitHub REST API.
Configuration Components
Specific files within the repository define the boundaries and parameters for overrides.
Core Configuration Files
- .pr_agent.toml: The primary file for defining tool behavior, such as
/review,/describe, and/improvecommands. - scripts/autofix.py: Implements logic for applying fixes, respecting path safety, and file size limits (e.g.,
MAX_FILE_BYTES = 80_000). - .github/workflows/pr_agent.yml: The reusable workflow that triggers the PR-Agent processes across repositories.
Technical Constraints
The autofix.py script enforces specific constraints to ensure stability during configuration application:
- Context Limits: Maximum of 12 context files are read per session.
- Path Safety: Normalizes paths and rejects any that escape the repository root.
- Verification: Always re-runs the detected test command before committing changes.
Sources: scripts/autofix.py:39-40, scripts/autofix.py:100-110, scripts/autofix.py:228-235
Summary
Repository Configuration Overrides provide a robust method for tailoring AI-driven code reviews and autonomous fixes to specific project needs. By combining centralized global defaults with repository-level .pr_agent.toml files, the system maintains a balance between organizational standards and technical diversity. The autofix.py utility further enhances this by dynamically detecting environment settings to validate and apply code repairs.