FixAgent
The FixAgent is the most complex agent in the pipeline. It implements a full TDD (Test-Driven Development) cycle inside an isolated Sandbox container.
Responsibilities
Section titled “Responsibilities”- Clone the repository and create a fix branch
- Place the reproduction test and confirm the bug
- Generate a fix via LLM (up to 5 attempts with iterative refinement)
- Verify the fix passes the reproduction test
- Run a full regression check
- Lint, commit, push, and create a GitHub Pull Request
TDD Cycle
Section titled “TDD Cycle”Step 1: Clone and Branch
Section titled “Step 1: Clone and Branch”git clone --depth 1 {repoUrl} /workspace/repogit checkout -b sentinel/fix-{incidentId}bun installStep 2: Place Reproduction Test
Section titled “Step 2: Place Reproduction Test”The reproduction test is fetched from R2 (test-case.ts) and written to the repo. If the R2 artifact is unavailable, a fallback template is used.
Step 3: Baseline Check
Section titled “Step 3: Baseline Check”Run the existing test suite to establish that it passes before the fix:
bun testStep 4: Confirm Reproduction
Section titled “Step 4: Confirm Reproduction”Run the reproduction test in isolation. It must fail to confirm the bug exists:
bun test tests/sentinel-reproduction.test.tsIf the test passes (bug not reproduced), the incident is marked needs_human.
Step 5: Generate and Apply Fix (Loop)
Section titled “Step 5: Generate and Apply Fix (Loop)”Up to 5 attempts, each with iterative refinement:
- Call LLM with: source code, root cause analysis, test output, and previous failure context
- Write the generated fix to the file
- Run the reproduction test — it should now pass
- Run the full regression suite — all tests should still pass
- If regression fails: revert the file (
git checkout -- {file}) and try a different approach
Each subsequent attempt includes the error from the previous attempt, prompting the LLM to try a different strategy.
Step 6: Lint
Section titled “Step 6: Lint”bunx oxlint --fix .Step 7: Commit and Push
Section titled “Step 7: Commit and Push”git add -Agit commit -m "fix: {rootCauseExplanation}"git push {authenticatedUrl} sentinel/fix-{incidentId}Step 8: Create Pull Request
Section titled “Step 8: Create Pull Request”A GitHub PR is created via the REST API with a structured body:
- Incident ID and service name
- Root cause file, lines, and explanation
- Fix strategy and confidence level
- Affected files list
- Verification checklist (reproduction, regression, lint)
Artifacts
Section titled “Artifacts”| Artifact | R2 Key | Description |
|---|---|---|
| Patch | incidents/{id}/patch.diff | Git diff of the fix |
| PR body | incidents/{id}/pr-body.md | PR description markdown |
Failure Handling
Section titled “Failure Handling”| Condition | Result |
|---|---|
| No Sandbox binding | needs_human |
| No repository URL | needs_human |
| Reproduction test passes | needs_human (bug not confirmed) |
| 5 fix attempts exhausted | needs_human |
| GitHub API error | needs_human + error logged |
HTTP Endpoints
Section titled “HTTP Endpoints”| Method | Path | Description |
|---|---|---|
POST | /fix | Attempt a fix from a queue message |
GET | /status | Active fixes |