What I won’t hand to an agent without understanding it

In five days, 68 PRs were merged in Keboola Connection and the number of files coupled to Zend dropped from 1295 to 706. Agents did most of the work. But when it came to login, authorization and behaviour changes, I made the calls. Here is exactly where that line was.

It will write it. But will I know if it’s right?

In Vibe engineering won’t be enough I had a short list of things I won’t hand to an agent without understanding them. I later posted the same list on Threads: encryption, authorization, data, performance, security, operations.

And on X on 17 November I brought up the refresh token example again:

An agent wrote the refresh token code. The code looked fine, the tests passed.

Except a short-lived token could create a long-lived one. No test failed, no error message.

A list on its own doesn’t say much, though. The more interesting part is how to actually stick to it when agents are running at full speed. And I’ve just tried that.

Five days, 68 PRs

In Dark factory in two sentences I wrote about the first roughly 22 hours. At that point, 13 PRs had been merged. The line kept running, though. We started on 11 November and finished on the evening of Monday, 16 November.

Metric At the start At the end
Files in src/ coupled to Zend 1295 706
Zend controller actions 70 70
.phtml views 61 55
Zend_Json in src/ yes 0

Over the whole sprint, 68 PRs were merged. 589 fewer files are coupled to Zend, a drop of 45 %. Every PR went through a filtered single-suite E2E run on CI and the CI Status Gate. The approval came either from the reviewer bot or from a human.

Most of the work was fairly mechanical. Constants and enums got a native owner. Native services and factories replaced Storage_Service_*. Controllers and processors got the Doctrine DevBranch instead of the Zend row. Library classes moved from the legacy library into src with the same FQCN. This is exactly what an agent is great at, and I don’t need to stand over it.

Now for the important part. Those 70 controller actions didn’t move. And a few things that could technically be done right away were postponed. Not because the agent couldn’t write them.

Authorization: hands off without permission

The sprint rules were clear. Auth, SAML, MFA and SOX. Type hints in those parts don’t change without explicit permission. Changes in Auth and SOX were always approved by a human, never by the bot. SAML and partner integrations only with an explicit OK.

The funny thing is that the biggest piece of the whole sprint was right there. A native StackFeatures and the audit log dispatcher in Auth, SAML, MFA and OAuth. One PR, 88 fewer files coupled to Zend. On paper, a clean swap of a type hint for a native class. The agent prepared it and waited for my decision. I let it through as an exception for those two classes, and a human did the review.

And that “clean swap” wasn’t entirely clean. An integration test revealed that the alias for StackFeatures initialized the legacy service. The alias went away, E2E green again, rebase, CI green. Only then the review.

It turned out fine here because that test existed. With the refresh tokens, no test failed. The code did exactly what it said. Just not what we wanted.

A behaviour change? That’s my call

The second line is anything that changes behaviour. The agent can find such places on its own, and that’s good. During the sprint it ran into three: Storage_Service_Version::url(), TableExportOptions and Admin_Service_ManageApps. It can’t get any further with them without a behaviour change or a legacy baseline. So it parked them and left them to me.

Then there are decisions about which variant to pick. For Storage_Job_Exception I chose how to do the native exception. A subclass without class_alias won. The consequence: the error name in Datadog changes only for native throws, and 103 direct legacy throws stay as they were. That’s no longer refactoring, that’s operations. Somebody looks at those error names in monitoring.

For ValidationException I approved physically moving it into src with the same FQCN. For controller actions I allowed migrating only those with real E2E coverage, and again outside Auth, SAML, MFA, SOX and OAuth. The API doesn’t change, Datadog changes are OK, the DB schema only after my approval.

Some things we rejected outright. Moving MergeRequest to Doctrine came out at 8 points with high risk. Snapshot on Doctrine would call the parked url(). So no.

Data: a flaky test that wasn’t flaky

During the sprint, cli-tests kept failing. It looked like a flaky test. It wasn’t. It was a real bug in the local provisioning rollback, which overwrote updatedAt. The fix went out as a separate PR.

Another E2E run failed with Storage in region us-east-1 cannot be assigned to project in region us-east4. It had nothing to do with the PR. The test took the last S3 storage with owner keboola, and the test stack had a storage from a different region lying around. Another session had created it by hand for other suites, so deleting it wasn’t an option. The agent tracked down the cause on its own. But it only touched the shared stack after I agreed, and it just switched the owner to client. Fixing the test so it only picks storage from the project’s region is being handled by another session.

Operations: when the whole machine goes down

Then there are things that have nothing to do with code. In the night before 15 November the subagents stopped responding. Full Btrfs metadata, filesystem in read-only. The factory wasn’t cleaning up its worktrees, and there were dozens of them by then. Two tasks in progress were left uncommitted.

I deleted the worktrees of merged PRs and a new rule was added: always remove the worktree after merge. The main session then restarted four subagents. Since then they stop at a draft PR, E2E and the ai-review label. Switching to ready and putting it into the merge queue is handled by the main session itself.

BTW, the whole Btrfs thing had a few more interesting twists. But more on that another time.

Two things proved their worth: at most 3 ready PRs at a time and serialized E2E suites.

And performance and encryption?

I don’t have an example for those two from this sprint. Removing Zend is mostly about moving dependencies around, not about encryption or latency. They stay on the list, though.

How I have it set up

  • Auth, SAML, MFA, SOX, OAuth: hands off without explicit permission, approval always by a human.
  • Behaviour changes, API, DB schema: my call.
  • Everything else: E2E and CI Status Gate, the reviewer bot can approve.
  • Anything that doesn’t fit the rules: the agent parks it and leaves it to me.

The agent also wrote that biggest PR in Auth. Whether it wrote it well, though, I had to judge myself. And passing tests aren’t enough for that.

There are 70 controller actions and 706 files coupled to Zend left. More waves are next.

Where do you draw the line for your agents? Which parts of your codebase always need a human to approve, no matter how green the tests are?

Leave a Reply