My factory is better than your factory
The title is clickbait because no two factories are the same, so it's always going to be comparing apples and oranges. And it's a joke because my factory is built for my personal preferences and how I prefer to work, and I'm not trying to convince anyone else to use it. In fact, I would suggest that you don't use it. But I do think it's interesting for other factory builders out there to look at and to compare it to your own experiences.
As LLM capabilities have evolved, we've gone from coding by ourselves to letting an LLM complete the line of code we're writing, to effectively pairing with an LLM, to asking an LLM to do the work while we watch, and finally asking an LLM to ask other LLMs to do work. LLM.
The term factory is pretty overloaded and means different things to different people. A lot of times when people say factory, they really mean a workshop. They might have a room full of agents doing work. They pass work into that room and an agent owns that work start to finish. With the workshop model, there's no distinction between agents. There's no deterministic workflow to ship a feature. You rely on the agent and the quality of the workshop to avoid slop. Armin Ronacher has a great talk about building the workshop before the factory.
When I talk about factory, I think it looks a lot more like what you see when you picture an industrial factory. Think conveyor belts and a series of specialized robots. A unit of work starts as a design and ends as a product. Units are checked for quality and acceptance along the way. Individual steps of the factory can be measured and improved. I suspect my preference for this more deterministic state machine model comes from my background as a release engineer.
This post will get further and further into the weeds as it goes on. So feel free to hop off this train once it starts to get boring.
Why?
Why build my own factory? There's lots of prebuilt factories that I can use off the shelf. One reason is to avoid harness lock-in, so I can use personal subscriptions for any of the major agents and mix and match models as they come out. It's personalized for me, so as soon as I have an idea or if some part of the factory is getting in my way or not performing properly, I can have it changed immediately. It also helps me form opinions on the changing ecosystem, so as I see a lot of these topics being discussed, I have strong opinions on how well things work based on my own experience. And obviously, because it's fun.
The factory I'm focusing on in this post is not my first attempt at a factory, it's actually my 3rd, and it probably won't be my last. But I think my current design is flexible enough to take the shape of whatever ends up working really well, so it's worth stopping to reflect on how it's going. First I'll explain how I got to this design.
Attempt 1: The SWE team
The first factory was modeled around the shape of a traditional software engineering team, and it was very GitHub-centric. Every workstream started as a GitHub issue, every contribution was a GitHub pull request, and it really looked like an extremely accelerated software engineering team. What I found pretty quickly is that agents have different constraints than humans, and the traditional software engineering team is modeled based on the constraints of humans. We needed a completely different design for a factory of agents.
Attempt 2: The opposite
This led to my second factory, which was based around my theory that designing a full spec and doing all the bike-shedding up front works well for humans, but for agents, continuously bike-shedding a design is actually very cheap. If people are continuously bike-shedding, they'll get mad at each other, get burned out, or just straight up quit. The design was a hub-spoke state machine where we had an initial design, but every step along the way, anything that's contested would be kicked back to the shed. In the shed, a committee would debate whatever was contested and come up with a revised design.
A project had a committed spec with IDable clauses. A workstream started as a proposed diff to the spec. New work came from a Horizon document which talked about the future plans for the project, both near term and long term. A project also had an immutable and human-owned document called a charter, which described the project's purpose and boundaries.
This factory model was really good for bootstrapping greenfield projects and building something really quickly. The biggest problem was it couldn't act as an effective contributor to your project because, as Steve Yegge describes, the factory becomes a facehugger for every project it works on. The factory configuration and constraints just leak into the project.
Both of these have led to my third design, which is somewhat of a middle ground between the two, taking the strengths of each. It can efficiently deliver good code without me babysitting it while also being a facehugger-free contributor.
What does it look like?
Quick TLDR about the shape of it. It has a web app served on my tailnet so that I can access it from my laptop or my phone when I'm away from my desk. It uses my Go library agentcore to orchestrate Claude Code, Codex, OpenCode, and Pi sessions. It uses a Whisper server for transcription so I can talk to it. It uses a decision model (Jev) to make contextual decisions throughout the factory. It's deeply integrated with Dagger, not just because I work there, but because it's the best way for agents to have repeatable and fast validation. Every agent session runs in Docker Sandboxes on a box in my office. Every agent role gets a configured environment and set of skills.
Of course, every single part of the factory must be measured. I have really cool dashboards in Grafana. I can see how much time the factory spent idle, my average time spent per turn, average time spent per role, cost per role, cost per workstream, anything I could want to know about the performance of the factory.
The compute heavy part of the factory is building and testing. Every build and test runs on a Dagger engine that the whole factory shares. This separation of agent compute with test/build compute allows me to scale my available agent slots extremely high relative to my total available compute. I can also extend my available compute to other available machines by connecting clients on those machines to the factory scheduler.
My personal agent has access to the factory's API, so it can quickly tell me if anything in the factory needs my attention. Maybe I'll do another post about the personal agent later if people enjoy this one.
This factory can build features from my own side projects. It can contribute to my work projects. It can help me brainstorm through design sessions, and it can kick off greenfield projects based on an idea that I pass in.
For some work, I still sit with a coding agent and work through things "workshop style". In the workshop I use Pi, and that agent has the ability to hand off work to the factory. So if we discover a bug unrelated to our ongoing work, it can just pass it off to the factory and we stay focused on our task.
How does it work?
Just like any factory, it is composed of inner and outer loops.
The Outer Loop
The outer loop is essentially the delivery of a feature from request to PR merged. In the factory, this is represented by a workstream or a workgroup if it spans multiple repos. I'll just say workstream from now on to keep it simple.
A workstream starts with a spec hand-in, a design session, or a GitHub issue. In a design session, I iterate with a design agent on a spec brief, and once we finally agree on the shape of the brief, that kicks off a workstream. The design agent is basically a chat agent that has access to any of the projects the factory can see. It decides what projects need to be included in the brief. I don't really look at the brief directly, instead we chat through the proposal and make sure the brief fully captures the intent of what I'm trying to hand in.
Once that is handed in, the brief reaches the architect and the committee. The architect turns the brief into a spec and plan. The plan is structured data, breaking down implementation of the spec into multiple units of work, each with their own scope, acceptance criteria and dependencies. The committee then reviews that plan, raises any objections, and goes back and forth with the architect until they reach consensus. When a consensus is reached, the plan is moved forward for ratification.
Once a plan is ratified, either by Jev or me, we now have the dependency graph of all the units that need to be built to satisfy the workstream, and the factory can begin working through each unit. Some units can be done in parallel depending on the DAG. I'll talk about the inner loop of a unit further down. Each unit starts from its own snapshot of the git worktree, and once it's complete, the completed work is merged into the workstream's git worktree. Just like with the shed model, if along the way a unit discovers new work that was not accounted for, or part of the plan that no longer makes sense, the plan can be sent back to the committee to either amend the plan or give the agent instructions on how to fulfill its unit.
When all units are complete, a draft PR is opened, and the final review starts. The final review can either lead to an amendment to the plan, which will lead to more units, or approval, which means the PR will be moved to the open state and ready for the next steps for delivery.
The Inner Loop
Units move from planned to ready to building to checking to reviewing to done to merged. I think most of these states are pretty self-explanatory, although we'll dig into the interesting ones.
Like every other role, the builder runs in a sandbox. It has access to the specific tools that I've decided need to be in the sandbox, which is pretty minimal because it runs checks and validation in Dagger. With Dagger, it can define any build requirements or test requirements that a project needs. The builder has access to its part of the plan: the spec for its unit, the acceptance criteria, and most importantly, the intent from the overall spec. Without knowing the big picture, it's really hard, even with these really focused units, for them to have the context to make the right decisions on implementation.
When we move to checking, the factory has its own check service where it looks at the code changes that the unit has made and the intent of the workstream, and a decision model decides what checks actually need to be run for that particular unit. If any checks fail, that gets passed back to the builder to fix the broken checks. When it passes, the check report is passed with the rest of the brief to the reviewer.
The reviewer is given a read-only checkout of the unit along with the unit's spec, acceptance criteria, and intent. It's able to use tools like Git to see the changes that have been made in that unit. Using its review skill, it does a code review and decides if anything needs to be sent back to the builder.
Data
Good tracing is an absolutely critical part of any factory. You need to know how every part of the factory is performing, where the bottlenecks are, and where the waste is. In my factory, every single operation sends OTEL to a ClickHouse database, and I have Grafana dashboards showing everything I care about. One cool note here is that the telemetry stack is another project that the factory owns. So whenever I have a new question that I want answered in a dashboard, the factory can modify that in a workstream and next thing I know, I see it in Grafana.
This data tells me that I am the bottleneck.
Configuration
The configuration for my deployment of my factory is in a separate private repo. The configuration covers the default profile (agent + model + effort + sandbox) for each role. That means I can ask the factory to change the default setup when a new model comes up, or when Opus gets nerfed too hard. I can still change the role profiles in the app if I run out of usage on Codex or something. The configuration also specifies my transcription model, Jev thresholds, slots per role, skills per role, and more.
The great thing about having this committed in a factory owned project is that if a workstream brings schema changes, that can be done in the same workgroup and they'll be deployed together.
Challenges
I think there's effectively two ways you can start building a factory. One: extremely deterministic and rigid, and slowly open it up over time, or two: completely open, and slowly add guardrails over time. I've obviously chosen the deterministic route, and at first the factory got stuck a lot. I was constantly needing to unstick it, to answer questions, or just tell it what to do. Over time, I've refined the state machine and crafted the right rules and skills so that everything flows smoothly. One of the biggest improvements was adding a decision model, Jev, into every gate. Each gate has its expected next step as well as every possible step, and in the gate, Jev can use the available context to determine if the expected next step is actually the correct one or if a reroute is required.
The factory pretty much always has at least one workstream working on improving itself, whether that's something annoying I ran into or a new way of getting stuck or performance issues. That's part of the beauty of it. Like I mentioned before, if anything's just not working quite the way I want it, I just hand in a request that says "hey, this part's really annoying me. Just don't ask me about that anymore." and the factory will do it. Or, if I see an interesting talk at a conference about how to have more effective agents, I can tell my factory to go watch that and propose some changes. And next thing I know, it'll be deployed to the live factory.
Conclusions
Reflecting on this, I think it's reached a really nice state where I'm happy with almost everything the factory outputs. I can trust it to produce good code. I love the async nature of it. When I'm away from my desk, I can just ask it to build something or check on the status of something, and it's always accessible. When I have a wild idea at 2 in the morning when I'm trying to fall asleep, I can just tell it to the factory and it'll be ready in the morning.
Whether you have a workshop, a kitchen, or a factory, the goal is to be able to scale. You need to know what the maximum output is, and what the next bottleneck is. To scale, you must be able to produce trustworthy code consistently. To identify bottlenecks, you need to trace everything.
So, is my factory the best? Honestly, I don't even know if it's good, but it's working pretty well for me right now.