Skip to content

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.

  • 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
Terminal window
git clone --depth 1 {repoUrl} /workspace/repo
git checkout -b sentinel/fix-{incidentId}
bun install

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.

Run the existing test suite to establish that it passes before the fix:

Terminal window
bun test

Run the reproduction test in isolation. It must fail to confirm the bug exists:

Terminal window
bun test tests/sentinel-reproduction.test.ts

If the test passes (bug not reproduced), the incident is marked needs_human.

Up to 5 attempts, each with iterative refinement:

  1. Call LLM with: source code, root cause analysis, test output, and previous failure context
  2. Write the generated fix to the file
  3. Run the reproduction test — it should now pass
  4. Run the full regression suite — all tests should still pass
  5. 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.

Terminal window
bunx oxlint --fix .
Terminal window
git add -A
git commit -m "fix: {rootCauseExplanation}"
git push {authenticatedUrl} sentinel/fix-{incidentId}

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)
ArtifactR2 KeyDescription
Patchincidents/{id}/patch.diffGit diff of the fix
PR bodyincidents/{id}/pr-body.mdPR description markdown
ConditionResult
No Sandbox bindingneeds_human
No repository URLneeds_human
Reproduction test passesneeds_human (bug not confirmed)
5 fix attempts exhaustedneeds_human
GitHub API errorneeds_human + error logged
MethodPathDescription
POST/fixAttempt a fix from a queue message
GET/statusActive fixes

src/agents/fix.ts