Can an AI Agent Fix a Failing CI Pipeline? I Tested Antigravity + Harness
DEV Community

Can an AI Agent Fix a Failing CI Pipeline? I Tested Antigravity + Harness

AI coding agents can write features, update tests, and help prepare pull requests. But what happens when that PR reaches CI and a test fails?

I wanted to see whether an agent could do more than explain the failure. Could it actually correct the code, push the fix, and let CI verify the result?

So I built a controlled experiment using Google Antigravity, Harness MCP, and the Harness CI Failure Autofix Worker Agent. Here's what happened.

The setup

I used a small Node.js and TypeScript checkout application with Vitest tests covering cart operations, discounts, shipping calculations, and order creation.

The application was connected to a Harness CI pipeline that ran on pull-request updates. The pipeline installed dependencies, ran ESLint, built the application, and executed the tests.

The baseline was green: 49 tests passing. Then I deliberately introduced a regression in the checkout logic.

One small change, one failing test

The application offered free shipping for an eligible subtotal of $50 or more. Consider this example:

  • Cart subtotal: $65
  • Discount: $20
  • Discounted subtotal: $45
  • Expected shipping charge: $5

The checkout service was incorrectly passing the original cart subtotal into the shipping calculation:

subtotal: cart.subtotal

Instead of using:

subtotal: discountedSubtotal

The result was straightforward: 48 tests passed. 1 test failed. The test correctly detected that the application was granting free shipping when the discounted order no longer qualified.

First, I asked Antigravity to investigate

I connected Google Antigravity to Harness through MCP and asked it to investigate the failing pipeline before making any code changes.

Antigravity inspected the CI execution and relevant source code, reproduced the failure, and identified the incorrect subtotal calculation. This was useful because the failure explanation came back into the coding environment instead of requiring me to manually work through the CI dashboard and application code.

But explaining the failure was only half the experiment. I wanted to find out what would happen if CI could initiate the repair attempt itself.

Adding a CI Failure Autofix Worker Agent

I added the Harness CI Failure Autofix Worker Agent after the test step in the existing Build and Test stage. The important part of the configuration was the conditional execution:

if: <+OnStageFailure>

This meant the Worker Agent could run when the stage encountered a failure. It had access to the repository, relevant pipeline context, and a Harness-managed LLM connector.

I then triggered another CI execution with the same regression. The test failed again. This time, the Autofix Worker Agent started automatically.

What the Worker Agent actually did

The agent first attempted to retrieve failure information through Harness MCP. Not everything worked perfectly. An initial diagnostic request could not analyze the still-running execution, and subsequent log retrieval encountered a storage-access problem.

Instead of stopping, the agent reproduced the failure using the checked-out repository. It inspected the failing test, found the incorrect shipping calculation, and applied a targeted one-line fix:

subtotal: cart.subtotal → subtotal: discountedSubtotal

No tests were removed or weakened. The agent then ran the project's build, lint, and test commands successfully. After local validation, it committed the correction to the existing pull-request branch. The fix was available for normal review; nothing was automatically merged into main.

The important part: CI verified the result

The new commit triggered another Harness CI execution. This wasn't just the agent reporting that its fix worked. The regular pipeline ran again against the updated code.

The result: 49 tests passed. 0 failed.

The earlier Autofix execution was eventually marked Aborted because the new PR update triggered the pipeline's auto-abort behavior. However, the agent had already pushed the correction. The subsequent execution completed successfully and provided the independent verification.

What I learned

Three things stood out.

  1. Diagnosis and automated repair are different capabilities. Antigravity helped investigate the failure from the developer's environment. The Harness Worker Agent handled the repair inside the CI workflow.
  2. Independent verification matters. The strongest evidence wasn't the agent claiming success. It was a fresh CI run passing all 49 tests.
  3. Automated repair needs safeguards. This was one deliberate, reproducible regression-not proof that an agent can reliably fix every CI failure. For production repositories, I'd want tightly scoped credentials, limits on repeated repair attempts, and human review of agent-generated changes.

The bigger takeaway

AI agents are making code generation faster, but developers still need to understand and resolve failures after a PR reaches CI. This experiment showed one possible workflow: Coding agent investigates → Worker Agent attempts repair → CI independently verifies.

The goal isn't to remove developers from code review. It's to reduce repetitive investigation and repair work while keeping the validation process trustworthy.

I documented the full experiment, including the pipeline configuration, code correction, execution results, screenshots, and limitations in the original technical walkthrough: Read the complete Antigravity + Harness CI experiment

Disclosure: I work on Developer Relations at Harness and conducted this experiment using Harness CI and its Worker Agent capabilities.

Read on DEV Community ↗ ← Back to News

Comments

No comments yet. Start the discussion.