An autonomous AI agent built a complete Retrieval-Augmented Generation (RAG) stack in about twenty minutes and opened a draft pull request without a single line of human code.
Why the “loop” matters
Creating a RAG stack usually means stitching together a search engine, an embedding model, a language model, and glue code. Developers waste hours tweaking Helm charts, fixing auth glitches, and chasing mismatched model names. In this test the autonomous agent followed a five-step loop that forces a human-agent agreement before any code is written.
| Phase | What happens |
|---|---|
| Proposal | The agent reads the prompt and drafts a concrete plan, but does not generate code yet. |
| Agreement | The user reviews the plan, approves it or requests changes. |
| Implementation | The agent builds the feature on a fresh branch. |
| Draft Gate | The agent runs its own linting and test suite, fixing errors it discovers. |
| Draft PR | The code is pushed and a pull request is opened for final human review. |
Most AI-assisted coding tools jump straight to implementation, often producing code that misses the mark. By inserting an explicit agreement step, the loop stops blind execution and lets the user steer the project before any commit lands.
The stack that materialised
In twenty minutes the agent assembled a production-ready RAG pipeline:
- OpenSearch 3.7 configured for hybrid search (vector + keyword).
- Local Ollama LLM serving as the generative engine for retrieval-augmented responses.
- FastMCP server exposing four custom tools to the language model.
- Skaffold and Helm scripts that automate container builds, Kubernetes manifests, and service deployment.
The pipeline was seeded with thirty articles, allowing immediate testing of end-to-end retrieval and generation. A developer would normally spend a full day configuring each component; the speed is striking.
The bugs that almost broke it
The agent’s confidence was tested by five distinct failures that would typically stall a human-run deployment:
- OpenSearch credential errors – the agent supplied the wrong secret key, causing the cluster to reject connections.
- Regex typo in a URL – a single misplaced character turned a valid endpoint into a dead link, breaking the data loader.
- Model name mismatch – the connector expected a different Ollama model identifier, leading to “model not found” errors.
- JVM memory limits – bulk indexing exhausted the Java heap, triggering out-of-memory crashes.
- Accidental deletion of model chunks – a cleanup script misidentified essential files as duplicates and removed them, threatening the entire pipeline.
When the agent got stuck, “loop-police” stepped in
A companion watchdog called loop-police monitors the loop’s health. When the agent entered a non-terminating cycle during the deletion bug, loop-police detected the stall, aborted the current branch, and forced a pivot back to the Agreement phase. The agent then acknowledged the misstep, cleared the corrupted state, and rebuilt the pipeline from scratch. The self-healing cycle finished without human intervention beyond the initial plan approval.
What this means for developers
- Speed without sacrificing control. The loop lets engineers specify intent, then hand off execution to an autonomous system that still follows a human-approved blueprint.
- Built-in safety nets. Automated linting, testing, and a watchdog that can break a runaway loop reduce the risk of silent failures.
- Lower barrier to entry. Teams lacking deep Helm, Kubernetes, or vector-search expertise can spin up a functional stack by describing what they need in plain language.
The approach isn’t a silver bullet. The Agreement phase still demands a knowledgeable reviewer to spot unrealistic expectations or security concerns. The loop doesn’t replace domain expertise; it merely packages repetitive plumbing work into a repeatable pattern.
