Building an agentic development pipeline twice

·

When one AI agent writes both the code and its tests, the tests tend to check what the code does, not what it was supposed to do. A bug becomes expected behaviour, CI stays green, and nobody notices. A colleague proposed a different structure for AI-assisted development to get around that, and over the past few weeks the two of us built it, twice, on our data engineering monorepo. This post is about what the first version taught us and what we changed in the second.

The idea

Instead of one agent doing everything, separate agents with deliberately opposed goals, each doing one job in a fixed sequence of phases:

  • A project manager agent turns a request into written requirements, and is the only agent that talks to the human.
  • A developer agent implements the requirements and writes unit tests.
  • A tester agent writes a test plan from the same requirements, at the same time, without being able to see the code being written. Later it runs that plan against the real output.
  • A code review agent only ever sees code that has already passed the local tests.

Agents never talk to each other. Every handoff is a file committed to the task’s branch, and a deterministic program, not an LLM, decides when a phase is done and what runs next. It’s closer to waterfall than to anything agile, on purpose: agents don’t benefit from standups and shared context built up over time, they benefit from one clear input and one measurable output.

The tester is the point of the whole thing. Because it plans from the requirements without seeing the implementation, a mismatch between the two shows up as a failing check instead of a test written to match the bug.

Attempt one: prove the structure

The first version followed the proposal directly: a Python state machine moving a task through requirements, development and test planning, local tests, code review and end-to-end testing, with agents passing Markdown files and every transition committed to git. It took about nine days to get to a working pipeline, and it produced two real pull requests.

The core idea held up. The tester, planning from requirements with only a read-only copy of the main branch to look at, found genuine gaps between what was asked for and what was built. One of its findings became a documented follow-up action on the merged change. And because every handoff was a commit, the task branch’s git log read as a complete record of who decided what.

What broke was everything around that idea:

  • Roles bled into each other. All the agents worked in the same checkout, separated only by their prompts. The project manager agent kept drifting into coding and testing decisions that weren’t its job.
  • The branch got contaminated. Artifact commits piled up on the same branch as the code, and one pull request needed a note telling the reviewer which commits to ignore.
  • Markdown was the wrong format for machines. Agents had to parse each other’s free-form sections, and most of our iteration went into tightening prompts to keep those formats stable.
  • Recovery was prose. When something went wrong, the system printed multi-step manual instructions, some of which led to dead ends.
  • Orchestration leaked into prompts. Bits of “what runs next” logic crept into agent instructions, so transitions weren’t fully deterministic in edge cases.

Attempt two: design first

Before writing any code the second time, we wrote a product requirements document and passed it back and forth between two models, Codex (GPT-5.5) and Claude (Opus 4.7). They pushed in usefully different directions: Codex on generality, isolation and the security model; Claude on how it would feel to operate and how to recover when things fail. Once the document converged, the implementation took about a day. The changes:

  • The state machine owns everything that isn’t judgement. Transitions, retries, recovery, artifact validation, redaction and rendering the pull request are plain Python. The project manager agent owns requirements and nothing else.
  • Isolation is enforced by the operating system. Every phase runs in a fresh container with only the mounts and network access its policy allows. The tester’s container gets a copy of the repository at the base commit with the files under change removed, so it can’t see the in-progress diff however it’s prompted. Reading those files just fails.
  • Artifacts are JSON. Every handoff has a JSON Schema the orchestrator validates. The Markdown people read is rendered from the JSON, so agents never argue over formatting.
  • The pipeline is a manifest. Phases, agents, models, mounts, networks and budgets are declared in a YAML file. Adding a phase or swapping the agent harness is a configuration change.
  • Interruptions are part of the state machine. If a person interrupts a running agent, they choose to continue, rewind or abort, and their steering is saved and fed into the next prompt.
  • Everything is recorded. Each run stores the harness, model, container image, network and a checksum of the prompt and every input and output artifact.

Artifacts still live on the task branch as commits while the task runs, which keeps the audit trail. A final commit removes them just before the pull request opens, and with squash merging the main branch only ever sees the code. On one pull request, that last commit removed 13 artifact files and more than 2,000 lines.

Running the same task twice

To see how much the output varies, we gave the second pipeline the same task twice: add two fields to an operations table. The runs broke the request into different requirements (eight in one, ten in the other, including two about handling failures in the sandbox), wrote different test plans (nine checks against five), and changed slightly different amounts of code. Both produced correct implementations that passed review. The details varied; the property that mattered, output that matched the requirements, held.

Cost and speed

We built both versions with Claude Code, using Opus 4.7 for the work and Haiku 4.5 for small loops, on a flat-rate subscription. In API-equivalent terms, the first attempt came to about $282 and the second about $325. The second was larger and more isolated, with roughly 9,350 lines added against 8,600, yet used less API time, about four and a half hours against six and a half.

It is also slow to use. Every phase starts a container, mounts things, validates, redacts, archives and commits. A typical task takes from tens of minutes to a couple of hours. That’s a poor fit for sitting and watching a run, and a good fit for a queue: agents pick up tasks in the background and the project manager agent marks a ticket as waiting for input when it needs a person. The second version was built with that in mind, with checkpointed state, saved steering and a draft pull request as the handoff.

Building it also exposed gaps in our surrounding setup that had nothing to do with agents: containers needing credentials for our internal package repository, the lack of written coding guidelines that agents could follow (their Scala drifted on small style points until we wrote them down), and the need for declarative permissions for what each role is allowed to do. We fixed those as separate changes.

Two things worth saying out loud

Keep the orchestration deterministic. The biggest difference between the two attempts is how much decision-making sits in code and how much in prompts. Anything an LLM decides inside the orchestrator is a place where the system can surprise you. Code you can read, test and step through.

Prompts still decide the quality. The structure gives the work a frame. Whether what fills it is any good depends on prompts that tell agents what tools exist, which conventions apply, where to look and what’s out of scope. A good share of the late changes to the second version were prompt changes: forbidding edits outside the developer phase, making the project manager interview the user before proposing requirements, sharpening the reviewer.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *