How to build an agent factory: the loop, stage by stage

An agent factory is not a faster software lifecycle. It is the same lifecycle closed into a loop, in which every stage leaves a record and people move from doing the work to three decision points: they approve the specification, confirm the verification and agree to the release. Agents prepare everything in between. A team that copies its old process one to one, with an agent where the developer used to be, gets more code, not a better product.

This is the third part of a series. The first argued that factories will spread beyond engineering, the second asked who owns what the factory learns. This one is about the loop itself.

The old lifecycle in one paragraph

The classic software development lifecycle (SDLC) is a relay of people. An analyst gathers requirements, an architect designs, a developer writes, another developer reviews, a tester tests, an administrator deploys, somebody watches the monitoring. Between each pair there is a handover: a document, a ticket, a conversation in the corridor. Why something was done one way and not another lives mostly in people’s heads, and leaves with them. That model worked because the developer’s time was the scarcest resource. In a factory execution becomes cheap and human attention becomes the scarce resource. That reverses the logic of the whole cycle.

The loop in eight stages

Over the loop sits a coordinator: an agent that receives a trigger (a ticket, a chat message, a monitoring alert, a request from a developer’s laptop), decides which stage the work is at, and starts the right agent with the right model and context. A cheap model for sorting, a stronger one for writing specifications, and for review whichever scored best on your own test set.

1. Intake: work arrives through one door

Ideas, bug reports, alerts and requests land in one queue. A factory with six entrances does not know what is on its table, so it cannot measure throughput or cost. Without this stage half of the agent work happens outside the loop, on laptops, with no trace and no metrics.

2. Triage: the cheapest saving in the loop

An agent reads each item, tries to reproduce it and sorts it into one of three bins: ready to do (a clear, small defect), unclear, needs a specification (a feature, a requirement open to several readings), parked, needs a person (missing data, a business decision). In the old cycle sorting and first diagnosis eat hours of the most experienced people. Without it, the executing agent receives a vague task and produces a lot of code that solves the wrong problem.

3. Specification: where the quality of the loop is decided

For unclear work an agent drafts two documents. A product description says what the user will see and do from start to finish. A technical description says how the change fits the existing architecture. A person reads both, corrects them and approves them before a line of code exists.

This is the control point with the most leverage. Correcting a sentence in a specification takes a minute. Correcting the same decision in a finished thousand-line change takes a day. In the old cycle people reviewed finished code; in a factory they review intent. Without this stage review turns into archaeology: reconstructing from the code what the agent meant to do. A specification that drives agents needs its own versioning and review, as we argued in if the spec is the source of truth, it needs a lifecycle.

4. Execution: the least interesting stage

An executing agent takes a triaged item or an approved specification and prepares the change, inside a sandbox whose exits are controlled — see an agent sandbox is mostly about what can leave it. Everybody wants to start here because this is where results are visible. That is the mistake. If intake, triage and specification work, execution is the most predictable part of the loop. Start with it alone and people spend their time rejecting changes instead of approving them.

5. Review: the stage that learns

A reviewing agent looks at every change before a person does. It works in a sandbox with the code, so before it suggests a fix it can run it. It has the specification in front of it, so it judges the change against the intent, not only against style.

Around it runs an outer loop. A second agent collects the comments people leave in reviews and from time to time proposes a change to the reviewer’s instructions. That proposal is an ordinary change, approved by a person. Team conventions no longer need a document nobody reads; they accumulate in the reviewer’s instructions. Without this stage people receive raw code and repeat the same five comments every week, and review becomes the bottleneck described in when agents write the code, review is the bottleneck.

6. Verification: a person confirms instead of tracing

An agent gets a machine, starts the application and walks the user’s path from start to end, as a tester would, attaching screenshots or a recording. Separately it checks whether what was built matches the specification it started from. Automated tests check what someone foresaw; a live walk catches what nobody did, like a button hidden behind a message or a form that cannot be filled in on a phone. Tests remain necessary, but a coding agent treats them as a target to hit, not as a check — to a coding agent, CI is a target, not a check. Without this stage the last step before release again depends on whether somebody had time to click through the application by hand.

7. Release: the decision that stays with a person

A person accepts the change and releases it. This is the moment when risk passes from the team to the customers, and somebody has to sign for it. In an AI system the release is more than code: it is the code, the prompt, the model and the index together, as described in a release is the code, the prompt, the model and the index.

8. Monitoring: the loop closes

An agent watches the running product, catches failures and unusual behaviour, and opens an item that goes back to stage one. AI components rarely fail loudly; they drift, so the monitoring has to look at answers, not only at servers. Without this stage the factory is an assembly line. With it, the product reports what needs fixing.

The second loop: the factory improves the factory

Above the product loop runs a second, quieter one. An observing agent scores every run: what it cost, how many times a person had to correct something, whether the change came back later as a defect. On that basis it proposes changes to the factory itself: another model for triage, a sharper specification template, a new skill for the reviewer.

For that to be safe, the factory’s definition has to be code: versioned, with the ability to roll back a bad change, to try a new version on part of the work and to compare results on a fixed set of test tasks. A change to the factory goes through the same path as a change to the product: proposal, review, human approval. A factory that rewrites its own instructions without approval does, after a few months, things nobody understands.

The old cycle and the factory side by side

DimensionClassic lifecycleAgent factory
ShapeA relay of linear handovers between peopleA loop in which monitoring feeds new work
Where people lookAt finished codeAt the specification before code and the recording after verification
Scarcest resourceDeveloper timeHuman attention at the decision points
Team knowledgeIn heads and an outdated wikiIn agent instructions, versioned with the code
TestingTests written up front plus manual clickingTests plus a live walk with a recording, checked against the specification
Process improvementA retrospective once a sprintEvery run scored, changes to the factory proposed and approved
Work in progressPrivate, on a developer’s machineVisible to the team, in the factory’s queue
Accountability for releaseA personStill a person

The last row matters most. Requirements, architecture, approving the specification and the release decision stay with people. Everything in between changes.

Where the factory does harm

Automating work that only looks simple. “Bump the library version” sounds like an agent task, until the new version changes how rounding works in the invoicing module. Start where a mistake is cheap and immediately visible: small interface defects, obvious failures, updates with no change in behaviour.

Skipping the specification because the agent writes fast anyway. Fast writing without an approved specification is the most expensive way to discover that everybody understood the task differently.

Self-improvement without a brake. A change to the factory without human approval is drift, not progress.

A factory without people. A team told that the factory will replace it leaves before the factory works. The people who like hard system problems are usually the first to enjoy building one, if it comes as more responsibility rather than as a sentence.

How you know the factory works

Vanity metricOutcome metric
Lines of code written by agentsHow many times a person touched one change between intake and release (it should fall)
Tokens consumedCost of one closed change and its month-to-month trend
Number of agents runningShare of items that went through the loop with no correction after approval
“Agents write most of our code”Lead time for changes, deployment frequency, change failure rate, time to restore (the four DORA measures)

A second model scoring quality can add to this, but only as a supplement. If corrections after release are rising, no model score covers that up. Why the familiar delivery dashboards mislead once agents write the code is in delivery metrics that lie once agents write the code.

The order to build it in

The rule: every step leaves a working system. You can stop after any of them and still have something that pays.

Infographic

Five steps to a working loop

  1. 01TriageItems arrive sorted into three bins; clear small defects get a first draft of the fix.
  2. 02SpecificationsUnclear work gets a product and a technical description, approved by a person before execution.
  3. 03Review that learnsEvery change gets a first review in a sandbox; people's comments become proposals for the reviewer's instructions.
  4. 04Live verificationAn agent walks the user's path, records the evidence and compares the result with the specification.
  5. 05Connect and measureThe coordinator joins the stages, monitoring feeds intake, the observer scores every run. Only now does the second loop start.
Each step is useful on its own; none of them requires the next one to pay off.

The same order works outside engineering. Brief, sorting, campaign description, preparation, a check against the brand’s voice, a check of the figures and consents, publication, measurement: that is the same factory in marketing. In finance the item is an invoice and the release is a posting.

On Monday, do one thing. Take the last twenty items from your ticket system and sort them by hand, in a spreadsheet, into the three triage bins. If more than half land in “unclear”, the first agent in your factory should not be the one that writes code. It should be the one that writes specifications.

Our part

In AI agents spec-driven development we set up this loop in your repositories and your CI: the specification format, the agent pipeline, the review gates and the measurements, run by your engineers. If we are still running your pipeline a year later, it was set up wrong. More about predictes is on the home page.

The decision is yours. You can give the team an agent that writes code faster and watch the review queue grow. Or you can build a loop in which people stop writing and reviewing everything, and start approving what genuinely needs their judgement.