Building an engineering agent

What an engineering agent really is: an intern that reads your codebase and opens a pull request. The loop behind it, and the one I am building at work.

By Daniel Chiwuzoh ยท

Building an engineering agent

Picture the most useful intern you have ever worked with.

You point them at the codebase and say, "the date on the booking confirmation is showing up in the wrong timezone for users in Australia, can you look into it?" They don't ask you which file. They go and read the code, find where the date gets formatted, notice the timezone is hardcoded, make the change, run the tests to be sure they didn't break something else, and a couple of hours later there is a pull request sitting there waiting for your review, with a little note explaining what they did.

You didn't write the fix. You described the problem and reviewed the result. The intern did the reading, the deciding, and the typing in between.

That intern is the thing I am building at work. We call it an AI engineering agent, which is a piece of software that can take a loosely described task, work through a real codebase, and come back with something a human can actually review. This article is about what that actually means, built up one piece at a time, because "AI agent" has become one of those phrases everyone says and almost nobody bothers to define.

First, what an LLM is (and what it is not)

At the center of all of this is a large language model, or an LLM for short. You have already met one if you have used Claude or anything like it.

Strip away the magic and an LLM does exactly one thing: you give it some text, and it predicts what text should come next. That is it. It is a staggeringly good autocomplete, trained on so much writing and code that its predictions often look indistinguishable from a thoughtful person's.

But notice what it cannot do on its own. It can't open a file on your computer. It can't run a test. It can't see whether yesterday's deploy is healthy. It has read enormous amounts of code in the past, but it cannot read your code right now. It is basically a brain in a jar: brilliant, and completely sealed off from the world.

An agent is what you get when you give that brain hands. ๐Ÿ™‚

The loop: read, decide, act, observe

Here is the whole idea, and honestly it is smaller than people expect.

An agent is a loop. It just goes around and around like this:

  1. Read the context. What is the task? What has happened so far? What did the last action return?

  2. Decide. Given all of that, what is the single best next step?

  3. Act. Use a tool to actually do that step: read a file, run a search, execute the tests.

  4. Observe. Look at what the tool gave back. Then go back to step 1, now a little wiser.

That is it. That is the whole engine. The model doesn't solve the entire problem in one shot. It takes one step, looks at the result, and decides the next step, exactly like the intern who reads one file, realizes the bug is somewhere else, and goes to look there instead.

Let me make it concrete with our timezone bug:

  • Read: "Booking confirmation date is wrong in Australia." Decide: I should find where the date is formatted. Act: search the codebase for "confirmation date". Observe: three files match.

  • Read: three files matched. Decide: the one in the booking module looks right. Act: open it. Observe: there is a formatDate call with a hardcoded 'Asia/Tokyo' timezone.

  • Read: the timezone is hardcoded. Decide: it should use the user's timezone. Act: make the edit. Observe: the file is changed.

  • Read: I changed the code. Decide: I had better not trust myself. Act: run the tests. Observe: they pass.

  • Read: tests pass. Decide: I am done. Act: open a pull request describing the change.

the-loop.png

Nobody told the agent which file or which line. It found its way there by looping. The cleverness isn't in any single step, it is in the fact that each observation feeds the next decision. I hope you are still with me ๐Ÿค”.

Tools: the hands

A tool is just a thing the agent is allowed to do, described to the model in plain enough terms that it can choose to use it.

The model never touches your machine directly. Instead, it can say, "I would like to run the command npm test," and the surrounding program (the part I write) actually runs it and hands back the output. The model proposes, my code disposes. That gap is the most important boundary in the whole system, and we will come back to it.

For an engineering agent, the useful tools are the same things a developer uses all day:

  • Read a file and search the codebase, so it can build up context the way the intern reads before touching anything.

  • Edit a file, so it can actually make the change.

  • Run a command (tests, linters, the type checker, a build), so it can check its own work.

  • Read a diff, so it can see exactly what it changed before committing to it.

  • Open a pull request, so its work lands in the normal review flow and not in some side channel.

propose-and-dispose.png

Give a language model that handful of tools plus the read-decide-act-observe loop, and you have the skeleton of an engineering agent.

What makes a code agent different

Plenty of agents answer questions or draft emails. A code agent is a harder animal, and in one funny way an easier one.

Harder, because code is unforgiving. An email that is 95% right is fine. Code that is 95% right doesn't compile. One misplaced bracket and the whole thing falls over.

But here is the easier part, and it is the reason engineering agents work as well as they do: code can check itself. Most work in the world has no answer key. Code has tests, type checkers, linters, and builds, which are automated graders that say, flatly, this is broken or this passes. The agent doesn't have to guess whether its change is good. It runs the tests and finds out, then loops on the failures until they go green.

That single fact, that the agent can grade its own homework, is what separates a code agent from a chatbot that happens to write code. The chatbot writes something plausible and hands it to you. The agent writes something, runs it, sees it fail, reads the error, and tries again, the same way you do. Working inside a real repository, with the ability to run that repository's own checks, is the whole game.

grades-its-own-work.png

Guardrails: the boundary between propose and dispose

Now, the part that keeps me up at night, and the part that makes this whole thing responsible rather than reckless.

The model can be wrong. Confidently, fluently wrong. So you do not hand it the keys and walk away. You build guardrails, which are limits on what the hands are allowed to do without a human standing in the way.

Some guardrails I think about, in plain terms:

  • It opens pull requests, it does not merge them. A person reviews every change before it reaches the main branch. The agent's output is a proposal, always.

  • It works in a sandbox, on a copy of the repo, on its own branch, so a mistake can't damage anything that matters. The worst case is a bad PR that gets closed, which costs nothing but a click.

  • Dangerous actions are simply not in the toolbox. It can't delete a production database because no tool lets it. The safest way to forbid something is to never offer it in the first place.

  • Everything it does is logged. Every tool call and its result, so I can read back exactly what it did and why.

  • Pre-tool and post-tool guardrails. There are checks that go on before a tool call and some after a tool call. For example if the action is to delete a file the guardrail runs before that and then post tool calls basically for logging or PII scrubbing etc

The principle underneath all of these is the same one from the tools section: the model only ever proposes. My code decides whether to carry the proposal out. Keep that boundary sharp and an agent being occasionally wrong becomes a non-event: you reviewed it, you caught it, it never shipped.

Evaluation: how you know it is actually any good

The last piece is the least glamorous and the most important. How do you know the agent is actually helping, rather than producing tidy-looking pull requests that quietly waste everyone's time?

You can't just ask it "are you doing well?" because it will cheerfully say yes. You need an evaluation: a set of real tasks where you already know what a good answer looks like, that you run the agent against so you can measure it. Did the PR pass review? Did the change actually fix the bug? How often did a human have to throw the work away and start over? Without this, you are flying on vibes, and vibes are exactly how teams end up with impressive demos that fall apart in daily use.

Where this sits, and why I am building it

At work I own the release lifecycle for a platform that serves a very large number of users, and a lot of that work is the kind of careful, repetitive, context-heavy labor that an intern could do with supervision: triaging, checking, the first draft of a fix. That is precisely the shape of work an engineering agent is good at. It is not about replacing the engineers, but about taking the predictable first pass so the engineers spend their judgment where judgment is actually needed.

I am building it in Python, using a framework called Chainlit for the interface, which is the chat-style front door where a developer describes a task and watches the agent work through it, step by step, out in the open rather than in a black box. Seeing each read, each decision, each tool call really does matter: trust in an agent comes from watching it think, not from being told to trust it.

Strip away the buzzwords and an engineering agent is a humble idea. It is a very good text-predictor, given a set of hands and a loop, working inside a real repository where it can check its own work, with a human reviewing everything before it counts. It is the intern who reads the codebase and opens a pull request. And the interesting work, the work I spend my days on, isn't the brain in the jar. It is the hands you give it, the limits you set, and the patience to measure whether it is truly helping.

Seest thou a man diligent in his business? he shall stand before kings; he shall not stand before mean men. - Proverbs 22:29