Stop Waiting for CI to Catch Bugs with Paul Stack

AI code can pass 20,000 tests and still break for users. Paul Stack explains the missing release gate.

Subscribe at Apple Podcasts Spotify RSS

CI catches agent bugs after the pull request, adding delays and token costs. Paul Stack explains how local verification and end-user release tests shorten that loop. The conversation covers Swamp's repeatable workflows, reviews in fresh agent contexts, commit-bound attestations and their trust limits, and black box tests that catch regressions despite passing unit tests. Human approval of issues and plans, plus explicit architecture rules, keeps judgment in the process.

Summary

Your agents can open 30 pull requests in a day. Then those pull requests sit there. Paul Stack met a team where that’s exactly what happened: 30 agent-written pull requests in one day, still open three months later. CI doesn’t help much either. The pipelines we’ve worked with assumed roughly one push per developer per day, with checks run locally first. Many developers skip the local run because they know CI will catch it. Agents push all day, and CI finds every failure only after the code has crossed the pull request boundary. Each failure costs you a round trip and tokens, and every failed run delays whoever is queued behind it.

Paul is co-founder and VP of Product & Engineering at Swamp Club, which builds Swamp, an open source CLI that turns agent work into typed, repeatable behaviors and workflows. Before that he was Director of Product at System Initiative and a staff engineer and engineering manager at Pulumi, where he wrote Terraform and Pulumi providers. His team builds Swamp with Swamp and releases it 30 to 50 times a day. We picked up his essay AI Broke the Assumptions Behind CI in episode #26 and wanted the full version.

The argument goes like this. Run verification on the laptop, in a fresh agent context, before the pull request exists. Have CI validate a recorded attestation of what ran instead of running the checks again. Then gate the release on end-user black box tests the agent is told never to edit. A human still reads every issue and approves every plan, because thinking is the part agents haven’t got. With that in place, nobody on Paul’s team has read a line of code this year. Architecture checks do that job.

Let the Agent Pick the Method Once

Before getting to CI, look at how most agent tools work, because that explains why runs are expensive and hard to repeat.

Why does my agent solve the same task differently every time?

Because the agent decides the steps every time it runs. You hand most agent frameworks a goal, and the agent controls the flow: which steps run, in what order, and when the task counts as done. It’s a probabilistic system finding a path from A to B. Without the same context, it works out that path again from scratch.

“when you ask things a second time, the agent has to try and reinvent how it gets there”

Swamp flips that around. Paul calls it behavior-led instead of agent-led. A behavior is a strongly typed schema plus methods, roughly a class in object-oriented code. Once the agent has worked out how to get from A to B, that path becomes a method. On the next run the agent doesn’t plan anything. It sees that a method exists and calls it. That’s cheaper and faster, and it uses less memory. Deterministic code decides when the outcome has been met, so the model doesn’t grade its own work. It also lets the team choose which model handles which step, which usually means a cheaper one.

One of us tried this on our own work. We pointed Claude at the Swamp repository and at a week of our own Claude transcripts, and asked where the tool would fit. It found the episode processing pipeline: a deterministic Python script that shells out to the agent harness at certain steps to read files and write drafts. That’s the shape Swamp workflows are made for. Swamp has a preview feature, Swampify, built for this kind of discovery. It goes through your agent sessions from the last week or month, finds what you do again and again, and suggests behaviors for it.

The same workflow runs from several places. An agent can drive it and call other agents from inside it. You can also run it by hand, on a schedule, from a trigger or in a CI pipeline. Paul is clear that this isn’t a magic pill. Swamp gives you primitives (behaviors, schemas, vaults, data stores, workflows), and his team’s pipeline built from them won’t look like yours. It also never stops changing.

Lights On, Because Taste Doesn’t Automate

“Software factory” gets used for so many different things that it’s worth pinning down. Paul doesn’t like the term. To him it’s just the software development lifecycle with a new name. He splits it into two modes, and the split is useful.

When should a human stay in an automated agent pipeline?

Whenever the output needs taste, perspective or creativity. A lights-off pipeline takes a well-defined input and a declared outcome, and nobody touches it until something comes out the other end. Swamp Club runs production alerts that way. An alert fires, a small model classifies it, a larger model investigates, and the humans get a detailed analysis. We’d call that a triage pipeline. The product itself runs lights-on.

Lights-on means gates. Someone reads every issue that comes in, for two reasons: is this the direction the product should go, and is someone trying to slip a prompt injection in through hidden text in the issue? Then the agent triages. Is it a bug? A regression? Can it reproduce it? The team challenges each answer. The plan goes through an adversarial review where two agents argue for up to five rounds, because the first plan an agent produces is always “the best plan ever” until someone pushes back. Findings are classified, and anything critical or high blocks the plan until a human steps in.

The plan the human reads isn’t a raw Claude plan. Paul calls those “verbose pieces of novel history”. Swamp has a schema for a plan and for its review findings, so the person approving it sees five steps, where they happen and what the risks are. Every run of a behavior or workflow also leaves an immutable artifact. CI can validate that record before allowing a merge.

“You still need to have a provider of intelligence in there somewhere in the loop.”

This is the gap in the “magic pipeline” pitch. LLMs generate a lot of code fast. The thinking that defines what to build still comes from a person. We’ve been pitched fully automated pipelines more than once. One of us built one, and it doesn’t work.

The Agent Never Sees the Token

There’s a practical reason fully automated pipelines struggle, and it isn’t about intelligence.

Can a fully automated agent pipeline build new features?

Not easily if its permissions are fixed. In our experience, bugs and regressions are the easier case: they touch existing behavior that existing tests already cover. A new feature, say an OAuth flow, has the agent building throwaway clients and spikes against real endpoints to see how things behave. A pipeline with a fixed set of permissions can’t do that. Either you widen them by hand for every feature, or you hand the agent a whole AWS account as a sandbox.

Paul’s answer is that his agent has no access to any account. Testing runs against emulators. Secrets sit in vaults behind an abstraction in Swamp, in the HashiCorp Vault sense, which can reach out to a real vault provider. The agent can run a workflow that fetches a token with a Common Expression Language (CEL) expression, but the workflow runs that fetch, not the agent. The token never enters the agent’s context.

Please never give your agent your tokens. It’s the worst possible thing in the world.

This is a building block, not a full answer. Emulators cover a lot, though not every managed service behaves the same way in an emulator as in the cloud. And keeping a token out of the agent’s context doesn’t decide what access a new integration needs. Someone still has to grant that. The idea carries over either way: the agent asks for an operation, and something deterministic holds the credential.

Verify Before the Pull Request Exists

Once the plan is approved, the agent writes the code. The interesting part is where it gets checked.

Where should AI code review run if CI is too slow?

On the developer’s machine, before the pull request is opened, in a separate context. Swamp Club already had a strict review setup in CI, with a persona for each angle: adversarial review, code structure, user experience, security. It produced good results. Some reviews took six to nine minutes, though, and each one burned tokens. When one failed, the result had to go back into a development loop the agent had already moved on from, which meant interrupting agents that were busy with other work.

So they moved the same process to the laptop. The first lesson was that the agent that wrote the code can’t verify it. Its context is poisoned by its own reasoning. Verification runs from a fresh checkout with a fresh agent and a fresh context window, so it looks at the code as an outsider would. Bugs turned up sooner and went straight back into the agent’s loop. By the time a pull request opened, it had already passed every check.

We made the same case in episode #26, partly on cost: locally you run on a subscription, in CI you usually pay API prices. Paul’s version adds the isolation rule, and it’s the part people skip. A review that runs in the same session that wrote the code is mostly the agent agreeing with itself.

CI Checks the Record, Not the Code

That leaves an obvious question. If the checks ran on a laptop, how does anyone know they ran?

How do you trust checks that ran on someone else’s machine?

You require an attestation, CI validates it, and you accept one trust assumption. Agents lie. They make things up and report steps they never ran. Swamp Club built an attestation schema the agent fills in when verification finishes: what it did, which steps it went through, which reviewers ran, which machine, which Git SHA, which models. The attestation is tied to the exact commit. Push a new commit on top and the build fails at once, because that commit isn’t what was verified.

The second hole is weakened checks. Anyone could soften a review prompt locally and produce a clean attestation. So every prompt, every agent instruction file and every script that produces the attestation is hashed with SHA-256, and the hashes go into the attestation. When the pull request opens, CI compares them with what the repository says they should be. If they match, it passes. If they don’t, it fails immediately. Prompts do need to change over time, so a changed prompt goes to review in CI with a specific question: did someone weaken it, open a back door or make room for prompt injection?

Here is the limit. An attestation is verification evidence, not proof. CI can confirm that the record belongs to this commit, that it lists every required step, that it is fresh and that it was produced with the repository’s own prompts and scripts. It can’t prove the tests actually ran; Paul’s essay says so directly. You are trusting the machine and the process that wrote the record. That’s why the release gate below doesn’t rely on it.

“CI for us became less of checking code, and it actually became more of a governance step to be able to understand what happened.”

Put more simply, CI exists to keep the main line green, so whoever checks out next doesn’t have to fix your broken unit test first. That job stays. What changes is how CI does it: it validates the record of the checks instead of repeating them. When we described it as proof of work, Paul’s answer was “Oh my god, we’ve built a blockchain!” They haven’t. What they have is a trail. From any Git SHA, the team can trace back through the attestation and the typed behavior records to the issue that started it, including every decision the agent made on the way. If a release of the CLI were ever hit by a supply chain attack, that trail is where the investigation would begin. It hasn’t happened yet.

Merging Isn’t Releasing

A green merge still doesn’t prove the software works, and agents make that gap wider.

Why do my AI agent’s tests pass when the feature is broken?

Because agents are very good at making their own tests green, sometimes by changing the tests. Swamp Club handles that by separating merge from release. A merge builds a binary. The binary then goes through black box and user acceptance tests (UAT): adversarial cases, performance, “does it break when I do X”. There are over a couple of thousand CLI tests, each written as what a user does and what should happen.

The agent running them gets one strict instruction: never change the test. If a test fails, the agent investigates the code for a bug or a regression. The end-user test is the definition of correct. Note that this is an instruction to the agent, not a lock on the files.

The numbers show why the stage earns its place. The main repository has about 20,000 unit and integration tests, and they pass. Out of roughly 2,500 releases in a few months, the UAT stage still caught about 100 real end-user regressions that would otherwise have shipped. At 30 to 50 releases a day, one regression that ships quickly gets buried under the next one. The whole path is lean: two to three hours for a person to pick up a new issue, then one and a half to two hours from approval to a shipped binary. Twenty-five minutes of that is UAT, and Paul won’t give it up.

The industry moved away from black box testing because the tests cost a lot to maintain and needed people to judge the results. Agents change both. Agents don’t mind toil, the manual, repetitive work Google’s SRE book taught us to hate. We’ve seen it in our own work too: an agent running a release reads every log line and points out what’s different from last time more carefully than we do. Long, repetitive checking of results is a natural fit for LLMs. Pair it with deterministic gates and you get the setup Paul describes.

Skills Aren’t Deterministic

Behaviors and gates are one way to get determinism. Plenty of teams are reaching for skills instead, and that has limits.

Can agent skills make an agent behave the same way every run?

Not reliably. The agent decides when to load a skill and when to drop it. Most teams never test how their skill behaves next to the 500 others that various tools install. Unless you write evals for your own setup that check when skills actually fire, Paul puts the chance of real determinism from a skill near zero. The model also changes underneath you, so a skill that worked yesterday may not work tomorrow. We covered what skills are good for in episode #3. Here’s the limit.

The more promising approach gives the agent a fixed set of functions and tells it to solve the task with those and nothing else. It’s close to what Swamp does, and other builders are working on it too.

This is also why many enterprises say they aren’t getting a return. They were sold 10x productivity at no cost and cut engineers on that promise, and some are now hiring them back. Gartner predicts that over 40% of agentic AI projects will be canceled by the end of 2027, citing rising costs, unclear value and weak risk controls. Coding with agents on a laptop is now well understood: grilling, planning, cross-model review. The next step is harder. You get the real benefit when agents work where it counts, in production, and that requires context about your systems plus read-only tools that won’t drop a table or show the model a secret. Most teams don’t have either yet. The context half is the job a context layer like B.O.R.I.S does. Until both halves are there, the gains stay on the laptop.

Stop Reading Code, Encode the Architecture

Back to the question every team ends up at: when agents write the code and other agents review it, what does the human look at?

What should humans review when AI writes all the code?

The rules the code has to follow, not the code. Paul hasn’t looked at a line of Swamp code this year, and he can still explain in detail what the system does. Swamp uses domain-driven design, which suits a CLI: a core engine, an infrastructure layer, and a presentation layer on top. The architecture guidelines are written out for the agent and checked: no leaking internal imports, everything goes through an API, and every API needs property tests, contract tests and architectural fitness tests. Anything left is subjective, such as naming or file length. If it matters, it gets encoded too. Otherwise it’s one person’s taste.

Each repository has the same structure of agent constraints, split into triage, plan, verification and conformance. The documents include Swamp commands that move the work to the next phase. If you squint, it’s a state machine. You don’t write these once. They change as the system changes, the same way architecture does.

Two caveats. Swamp started as a greenfield project with good code, and agents copy what they see. Paul repeats a heuristic he’s half convinced of: the first thousand lines a model sees set its direction. Brownfield teams have to find the architectural seams first. And as we argued in episode #16, AI multiplies what you already have. Years of building CLIs and providers let Paul’s team write the constraints before writing code. Once the thinking is encoded, the loop needs less human judgment.

The payoff showed up in October, when the Deno team joined Cloudflare and announced that runtime development ends after a year of maintenance releases. Swamp runs on Deno. Paul’s team isn’t panicking about a rewrite. Strict guidelines and end-user tests make a language change mostly a question of trade-offs and tokens.

What This Means for Teams

The pipeline Paul describes isn’t something you install. It’s a set of constraints a team pulled out of people’s heads over time. His three recommendations are the order to work in. First, write down how you review code, for security, performance and conformance, so an agent can code against it. Second, write down your architecture, because you have one whether or not it’s documented. Third, don’t count on unit tests to catch agent bugs, since agents change them. Test across the seams and test what your end users do, even if that’s just a set of API contract tests. The teams doing best with agentic engineering already had strong continuous delivery. A weak lifecycle just gets more of the same.

Four things to do this week:

  • Turn review comments into constraints. Export the comments you’ve left on pull requests, give them to an agent and have it write them up as rules. Those are the nitpicks you keep repeating. Then run some code through them and see what comes back.
  • Move one CI review to the laptop, in a fresh context. Run it from a clean checkout with a new agent session, not the session that wrote the change.
  • Put one end-user test suite out of the agent’s reach. Paul’s team tells the agent never to edit the tests, and that instruction is a good start. An instruction can still be ignored, so go one step further: keep the suite where the agent has no write access, such as a separate repository or a read-only path, or have CI fail when those files change.
  • Find where your agent holds a token. If a credential sits in the agent’s context or environment, move it behind a workflow or tool that fetches it for the agent.

Common Questions, Answered

How do I stop AI agents from editing tests to make them pass?

Separate merging from releasing, so a merge builds a binary and the binary has to pass end-user black box tests before users get it. Swamp Club instructs the agent never to change those tests and to investigate the code for a bug or regression when one fails. With that stage, the team still caught around 100 real regressions across roughly 2,500 releases, despite about 20,000 passing unit and integration tests. An instruction alone doesn’t stop edits, though. To enforce it, keep the suite outside the agent’s write permissions or in an independently controlled repository, and fail the build if test files change.

When must I rerun local verification?

After every new commit. The attestation is tied to the exact Git SHA it was produced against, so pushing even a small fix on top makes CI fail the build: the new commit isn’t what was verified. It also fails if the hashes of the review prompts, agent instruction files or scripts in the attestation don’t match what the repository says they should be, so verification has to run with the repository’s current versions.

How do I keep my AI agent from seeing API tokens and secrets?

Keep credentials in a vault and let a deterministic workflow fetch them, so the agent triggers the operation without the token entering its context. Test against emulators instead of giving the agent cloud account access. This is a partial answer: it keeps secrets out of the agent’s context, but it doesn’t decide what access a new integration needs, and emulators don’t match every managed service. A pipeline with fixed permissions still needs a human to grant access for new features.

Resources

Give your AI tools the context they're missing

Partners

Need a HIPAA foundation first?

Talk to our partner network