• AI
  • RAG
  • LLM
  • Workflow
  • Product-driven software studio

Self-Healing AI Software Engineering Agent

Debugging dropped from 4-5 hours per iteration to under 15 minutes, with 87% of failures repaired on the first loop and no human in the repair cycle. Deployment frequency rose 42%.

first-loop repair success rate
87%
debugging per iteration, down from 4-5 hours
<15 min
deployment frequency
+42%
Self-Healing AI Software Engineering Agent - Product-driven software studio, built by MacroCoderz

Overview

We built an agent that writes, tests and repairs applications on its own, inside isolated environments. It finds, debugs and fixes functional errors in the code it generated, with no human in the loop. Code generation used to run one way. Now it runs as a closed loop that checks and repairs its own output.

The client is a product-driven software studio that was trying out AI-assisted development pipelines. Their automation stack could already generate code snippets with large language models. But people still had to check the quality and debug the output. The studio wanted less manual work, shorter test cycles and more reliable generated code. The answer was an agent that adapts and repairs itself.

Core Challenges

01

Testing Reliability

The old tests were Playwright scripts that often gave inconsistent results. A failure could come from the generated code or from the test itself, and there was no way to tell which. With no deterministic environment, tracing an error to its source was hard.

02

Environment Control

Different frameworks and package dependencies made the runtime unstable. Developers hit the same configuration mismatches again and again, most often when switching between backend and frontend builds. Runs could not be reproduced reliably, and that blocked automated end-to-end testing.

03

Repair Feedback Loop

Most code generation agents work in a straight line: generate, test, fail, then regenerate the whole codebase. That wastes tokens, adds needless variation and slows every iteration. The client needed selective repair: fix only the broken section and keep the code that works.

Solution Overview

01

Autonomous Generation Layer

Claude 4 Sonnet writes the backend and frontend components from structured prompts. Context metadata walks the model through environment setup, dependency installation and module linking.

02

Testing and Diagnostics Layer

Playwright and Browser-Use run the automated checks. The agent logs and parses test results in real time. It turns them into structured feedback tokens for the repair step.

03

Self-Healing Feedback System

A targeted RAG pipeline finds the faulty code segment and retrieves its context. It sends only that block back to the LLM to fix. This cuts the cost of each iteration significantly and makes fixes more precise.

04

Containerized Runtime Management

Every run happens inside an isolated Docker sandbox. That keeps dependencies intact and makes each run fully reproducible. Each run starts from a fresh container snapshot, so nothing carries over from the run before.

Solution Description

The system is modular. Explicit orchestration hands work between three phases: generation, testing and repair.

Language Model
Claude 4 Sonnet (primary), with GPT-4.1 as a fallback for cross-model comparison
Testing Stack
Playwright for browser-level checks and Browser-Use for headless task automation
Runtime Control
Docker containers in ephemeral sessions, with shared mounted logs
Repair Logic
Selective patching with RAG, using similarity embeddings on function-level chunks
Data Storage
SQLite local cache for error metadata and repair history

Process Flow

  1. 1

    The agent generates the code and compiles it in a container.

  2. 2

    Automated tests run as soon as the build finishes.

  3. 3

    When a test fails, the agent parses the logs and matches them to the code segment at fault.

  4. 4

    It retrieves context embeddings from earlier working builds.

  5. 5

    It sends the faulty block back to the LLM for a targeted fix.

  6. 6

    It merges the new patch and re-tests automatically until the success criteria are met.

Results

  • Manual debugging time per iterationUnder 15 minutes, down from 4–5 hours
  • First-loop repair success rate87 percent
  • Deployment frequency42 percent higher
  • Runtime drift, with container snapshots keeping every environment fully reproducibleEliminated

What changed

The agent turned passive code generation into a development process that adapts. Engineers no longer step in to validate or fix the code. The AI drives the continuous integration cycle on its own.

The framework laid the groundwork for autonomous development systems that run an application's whole lifecycle: writing, testing and repeated self-repair, under controlled conditions that can be verified.

Want one of these for your product?

Fixed scope, fixed price. You own the code, prompts and eval data from the first commit.

Book a call

Pick a time for a strategy call

It goes straight into our calendar, with no form to fill in first.