Zero Labs
Industry News / AI

Inside Our Autonomous Software Factory: How AI Agents Write, Test and Ship Our Code

Source · Towards AI By Mukesh Vast

From the publisher’s feed, collected in the ZeroLabs newsroom.

You hand it a few feature requests. Minutes later it hands back a pull request that has been planned, tested, reviewed and tried out by an agent playing your customer.What we learned running AI agents as an assembly line, told through one small made-up example: a loyalty card for a coffee chain.For two months, a team of AI agents has built the features of our in-house product. They work like a production line: each agent has one job, and its work gets checked before the next one starts.Our first version cost more to build than the product it shipped. The second one works, and it rests on one rule:Code decides what runs next. Agents only judge.A small Python program called fx keeps each batch's state in files, picks the next agent and refuses any hand-back that breaks a rule. Agents read, plan, code and review, but none of them can move a batch forward.The whole line on one screen. A person works at only two stations, the brief and the ship. Everything else runs in the background, watched by fx.The exampleThree small wishes for a coffee chainPicture Brewline, a loyalty app for a coffee chain with three outlets. The owner wants three things, each written as a short story with numbered acceptance criteria.Hidden in it are a money question (is a free coffee any size?), a time-zone trap (when does a birthday start?) and a privacy hole (can outlet A see outlet B’s customers?). Watch where each gets caught.The teamWho works on the lineSixteen roles work the line. Some are agents on a strong model, some on a cheaper one, and some are plain code that never makes a judgment call.PlanThe crew. Amber is you: once in planning, once at the end. Every other role gets a narrow job and hands back JSON that fx checks before anything else happens.Step 1 · PlanningWhat do robot planners argue about?One command starts it: /factory new loyalty S1 S2 S3.Planning the loyalty batch. Two problems get caught here, before anyone writes a line of feature code.A cheap reader per story lists every spot where a builder would have to guess. The birthday reader asks: with servers on UTC, does a customer in Mumbai get the pastry at midnight or at 5:30 in the morning?S1 and S2 both touch RewardService, so fx builds them as one group. Planners read the code and outline a test for every criterion. The product lead never reads code, on purpose, because an agent that reads code tends to accept whatever it already does. It settles three questions from the spec and sends the two about money to a person.The critic tries to break each plan, with evidence. It finds that a refunded coffee keeps its stamp and that baristas would see all three outlets, both fixed before any test exists. Then the tests are written and run on today’s code. Each must fail, because a test that passes before the feature exists proves nothing.Step 2 · The only meetingTwo questions, one reply, six minutesFive questions come in and two reach the owner. The brief fits on one page and can be answered from a phone. Here the owner takes the recommendation on size and overrides it on the birthday window.On approval, fx locks the nine tests, moves the Jira tickets and writes each answer back into the story file, so the spec stays the one source of truth. Anything that isn't money, rules, access or a surprise gets a default the owner can overturn.Step 3 · BuildRound after round, until nothing is left to findThe build loop. Reviewers only look at code whose checks pass, and every way out of the loop leads either to “ready” or to a personEach story gets a fresh builder, and risk picks its model: the birthday story gives away food, so it gets the stronger one. Gates check every commit the moment a builder says “done”. If a locked test was changed, or a test deleted or skipped, the work goes straight back to the same builder while it still remembers why.Reviewers only see code whose checks pass, and later rounds re-read only what changed. A reviewer can record anything, but to block it must bring proof that fx can verify:The loyalty batch, round by round. Group 1 needed three rounds and group 2 needed one. They ran at the same time, each in its own copy of the code.The reviewer that orders the coffeeIn round 2 every test passed and the code looked fine. One reviewer still failed it, because it doesn’t read code. fx starts a throwaway copy of the app in Docker, and an agent signs in as each persona and works through the criteria the way they would. It buys ten coffees. It asks for another outlet's numbers. Anything short of a pass blocks.Everything that reads code said yes. The server even sent the reward, but the screen had no way to show it, so the customer saw an error. Only an agent using the app could catch that.This part is real. In our first real batch, the live check found the only two real bugs, and no test or code reviewer had caught either. That’s why it now runs in every round.Step 4 · Ship and learnOne yes, then three lessons at mostfx ship merges in the latest main branch, reruns every check and writes the pull request: each criterion with its test and result, plus what got fixed and what's still open. The owner confirms once, and the factory never merges its own work. All of its state lives in files, so a crashed session or a closed laptop just means typing /factory next later.Afterwards a lessons agent proposes three lessons at most, like “a birthday is a local date, so test 00:30 and 23:30 India time.” The owner keeps the good ones, and the next batch reads them.Brains and tokensWho gets the expensive brain?Each role’s model is a line in a config file. A round that fails on the cheaper model moves the next round up to the stronger one.Two things surprised us. A cheaper model saves only 17 to 40 percent, because most of what an agent reads comes from the cache, which costs about the same on both. And the biggest waste is reading the same thing twice, so nearly every saving came from agents reading less.TOKENSWhere do the tokens go?Every agent run is logged with its tokens and tied to the group, story and round it worked on. We show tokens rather than dollars, so you can price them at whatever rate you pay.Where the tokens went in our biggest batch. Builders use the most, and the session that steers everything comes second. That second line is the one we most want to shrink.Four real batches, in the order they ran, counting the agents only; the steering session comes on top. The 3-story batch ran long because one criterion depended on a story nobody had linked, and it failed the live check the same way for six rounds. A circuit breaker now stops that after two.LessonsWhat we’d tell anyone building oneThe factory can cost more than the product. Our first engine grew to 19,000 lines and cost about five times the product work it shipped. The second has a line limit a test enforces.Make reviewers prove it. An agent that double-checked every block overturned 0 of 16, so we deleted it. Now a block needs proof the engine can check.Use the product, don’t just read it. The agent that taps through the running app caught what tests and code reviewers missed.The conductor is the hidden bill. The session that steers everything still takes 18 to 41 percent of each batch, against our 15 percent target.Count tokens, not dollars. On a flat subscription, one more batch costs no extra cash. Tokens show the work, and the real limit is the plan’s usage cap.The product got better, not just faster. Every criterion has a test that failed before the code and passes after, and bugs get caught in the running app before the merge.None of this replaces engineering judgment. It moves that judgment to the two moments that matter most: writing the spec before the work starts, and saying yes before it ships. Everything in between is a line we can measure, and we keep making it cheaper.If you like this topic :Clap this article 10+ times; that will really help the article reach more readers 👏Follow me on Medium and/or LinkedIn and subscribe to get my latest article for Free🫶Feel free to connect or drop a comment about the article !Stay tuned for more Tech explorations!Inside Our Autonomous Software Factory: How AI Agents Write, Test and Ship Our Code was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.