I’ve substantially rebuilt the system around our internal data platform agent, Luigi, four times over the past few months. I’m considering doing it again.
Each time, I’ve tried to make the system simpler while also giving Luigi more responsibilities. And each time, I’ve ended up with complexity that I’m not entirely sure needs to be there.
A lot of it comes down to something I’ve been struggling with since I started building it: how much of the work should I organize through code, and how much should I leave to the intelligence itself?
What I hadn’t really appreciated when I started was how much the answer to that question could change over time.
How much of the work do we need to organize?
Luigi started with a skill I was using locally to investigate data quality issues. I wanted something running continuously that could pick up these issues without me having to initiate the work.
I came across Eve, an agent framework, and started experimenting with it. I quickly realized that a lot of the work needed to happen across multiple sessions. Luigi might investigate a problem, create a pull request, and then need to come back to it once somebody had reviewed and merged the changes.
I needed some code around the agent to keep track of the work.
One of the first things I had to figure out was how to group incoming alerts. If an upstream data model fails, we might get alerts about thirty downstream models. They don’t necessarily arrive at the same time, and Luigi might already be investigating the underlying problem.
I’ve gone back and forth between using a model to figure out which alerts belong together and trying to solve more of this through code.
It still doesn’t work the way I’d like, but I’ve started questioning how much more time I should spend on it. If Luigi ends up with two cases for the same problem, but can figure that out during its investigation, does it really matter?
We’ve had situations where a single problem resulted in more than twenty cases that eventually needed to be closed manually. That’s obviously something I want to avoid. But what I really care about is whether problems in our data platform are correctly identified and resolved, and how much of our time that takes.
I was building Luigi alongside my actual job. I wanted to see whether we could get value out of having an agent do this kind of work before investing much more time in it. So I often took the quickest approach to solving whatever problem I was dealing with.
I’ve spent several evenings trying to get Luigi to close a case that it wasn’t allowed to close because there was an outstanding local change in its Git repository. I’d added a restriction to prevent it from abandoning work, but hadn’t given it a way to deal with situations where abandoning that work was perfectly reasonable.
Eventually, I went into the database and closed the case myself.
A lot of these restrictions came about because Luigi did something I didn’t like, and preventing it from doing that again through code was relatively easy.
There’s an asymmetry here. When something goes wrong, there’s an obvious reason to introduce a restriction. When things are going well, there’s rarely anybody asking whether we still need it.
Luigi is now doing a lot of useful work across our data platform, including cleanup and optimization work we previously struggled to justify spending time on.
But the system around it still contains a lot of decisions I made when both Luigi and I knew much less about how to do this.
What happens as the agent gains experience?
After experimenting with alternatives to frontier models, I moved much of Luigi’s work to a model we host ourselves. With GPU capacity already available, I became far less concerned about the cost of giving it another responsibility.
That also changed how much time I was willing to spend building code to solve things that the model might be able to figure out itself.
But even without changing the model, Luigi is getting better at certain things.
From the beginning, I wanted Luigi to pick up as much of our organizational knowledge as possible. I didn’t want to spend weeks writing instructions about our data platform and how we work. I wanted it to learn from our code, from doing the work, and from interacting with us.
We’ve been experimenting with a mechanism we call dreaming, where agents periodically look back at their sessions and propose changes to their knowledge and skills.
One of our monthly accounting adjustments, for example, results in a small restatement of annual recurring revenue (ARR), either up or down, based on actuals. While investigating this, Luigi learned from someone that dealt with this in the past why it was happening.
When it documented what it had learned, it was a little too specific to the numbers it had encountered that month. I asked it to make the learning more generic, since this is something that happens every month.
That knowledge has since been referenced in more than two hundred case closures.
A more intelligent model wouldn’t necessarily have helped much with that original investigation. Luigi was capable of investigating the movement. It just didn’t know something that the people working in Finance knew.
There’s an enormous amount of knowledge like this in a company. We learn it through conversations with colleagues, through making mistakes, and simply by doing our jobs. Much of it never makes it into any documentation.
I want Luigi to pick up that kind of knowledge over time. But I’m also interested in what I might be able to take out of the system as it does.
Going back to the grouping problem, if Luigi gets to know our data platform well enough to recognize related issues during its investigations, perhaps I don’t need as much code trying to figure that out beforehand.
We’re quite good at adding things
We have another learning loop that looks at the situations where humans have had to intervene in Luigi’s work.
For a while, I kept having to ask Luigi to verify changes after its pull requests had been merged. We could have given it better instructions around verification, but the actual problem was that nothing woke Luigi up when a pull request was merged.
That was something we needed to fix in the software.
What I like about having both of these learning loops is that we can see where Luigi struggles in practice and use that to improve both what it knows and the code around it.
Over the past eight weeks, dreaming produced 59 pull requests updating knowledge and instructions, of which 58 were merged. Looking back at human interventions resulted in around another 19 pull requests proposing changes to its instructions or the code around it.
But over that same period, the number of instructions Luigi had accumulated grew from 37 to 106.
And I’m not sure they’re all things I want Luigi to have learned.
I’d previously given Luigi some guidance on how big a warehouse cost optimization needed to be for it to be worth pursuing. Later, I declined two proposals, one because we were tackling it separately and another because I wanted to see whether it grew into a bigger problem.
Luigi interpreted those decisions as a reason to raise the monetary threshold in its instructions.
I merged that change without fully realizing.
I wanted Luigi to get better at figuring out which optimizations are worth pursuing. Instead, I’d helped it introduce another restriction.
Having a young child at home, I spend a lot of time thinking about how much freedom to give someone who is still learning. I want to leave room for exploration, even when I could explain how to do something more efficiently. There’s a lot to be learned through experience that I couldn’t have anticipated or explained beforehand.
There are obviously boundaries I need to set, but there are also things I wouldn’t have allowed a year ago that I’m perfectly comfortable with today.
The degrees of freedom I give my child change with experience.
I’ve removed plenty of things from Luigi over the past few months, but mostly when I was rebuilding large parts of the system. I’d like to get better at questioning whether we still need those things without having to rebuild the whole system.
Complexity should earn its place
Over the past few months at Aiven, we’ve been replacing a SaaS tool with something we’ve built ourselves. We made extensive use of feature flags because we were working against a deadline and didn’t have time to wait for every decision to be made before building something.
In many cases, having something working made the eventual decision much easier.
I want to experiment with a similar approach to building the system around Luigi.
I’ve built evaluations for parts of Luigi, but I haven’t spent nearly enough time evaluating the code around the model. I’d like to be able to run a collection of historical cases with and without a particular piece of code and see what difference it makes.
But I don’t think running that evaluation once would tell me everything I want to know.
If the code has always made a particular decision for Luigi, it might never have had to learn how to make that decision itself. Removing that part of the software could initially make Luigi worse at its job, even if it’s capable of learning to do it.
As a manager, I’ve always tried to give the people on my team a lot of freedom in how they approach their work. If I keep making decisions for them, I’m also limiting what they get to learn.
I’d like to give Luigi similar opportunities, but I obviously don’t want the quality of its work in production to suffer while it’s learning.
Perhaps I can remove some of the software in a separate environment, let Luigi work through a number of cases, and have it learn from doing the work in much the same way it does today.
What I’d then want to see is whether it gets better at doing the work without that code, including when dealing with cases it hasn’t seen before.
Our systems and data are changing all the time, though, and some of the things Luigi has learned might no longer be true.
I’d like to make questioning what Luigi already knows a more explicit part of dreaming, rather than mostly looking for things to add. Are there instructions we no longer need because we’ve changed the code? Are there things we’ve learned about a business process that have since changed?
I think we need to get as good at maintaining what an agent knows as we are at maintaining the code around it.
In an earlier article, The agent is the easy part, I wrote about the importance of building the machinery around agents. I still believe that. We need to enforce permissions, coordinate work that happens in parallel, and make sure certain decisions remain with humans.
But for much of the remaining code, it’s worth asking whether it’s there because of a limitation in the model, something the agent hasn’t learned yet, or an assumption I’ve made about how the work should happen.
I’m already thinking about this as we look at giving agents responsibilities outside our data platform.
If we’re going to give an agent responsibility for investigating overdue invoices, for example, we need to understand our billing process, what actually needs someone’s attention, and which actions require approval. But we don’t necessarily need to tell it how to go about every investigation.
Understanding the work well enough to give someone responsibility for it is different from telling them exactly how to do it.
In the next iteration of Luigi, I want to spend more time understanding the work itself. And I want to build the system in a way that makes it much easier to experiment with how much freedom I give Luigi as it learns.
As Luigi gains experience and takes on more responsibilities, I want removing part of the system to be as ordinary an improvement as adding something to it.


