Posted in Software Development tagged AI

Lobotomizing My Agent

I've been learning a lot about myself as I've been interviewing recently. I'm reminded where I have gaps, and I'm finding new ones. Not always with the knowledge, but often in the lingo. I'm also realizing that I work in creative ways that don't always land if you're expecting some known conventional approach to a problem.

Regardless of my shortfalls, I'm always open to feedback. When I know I've fallen short, I am quick to ask for feedback because I know I may not get it later. With my own personal work, I try to log as much as possible. Not just slop docs about the design and decisions, but any and everything I can. Having these things available, unabridged, with full git history makes it easy to do retros, especially when you're the only one on the project.

I like to do this periodically, pointing an LLM at a whole mess of context, and figure out how things went, and how to improve. Having run my personal agent Igor for the last 6 months or so, it was time to run it through its paces.

Agent-in-waiting

Igor v1 (the OG) grew to ~5,200 lines of shell scripts wrapped around claude -p as my economical workaround to usage-based pricing and renting things like context compaction rather than building. Anthropic had announced in May that billing would move to usage-based API rates, but then paused the change in June.

There were some changes back in June, was almost closed back in June, but it angered enough customers for Anthropic to slow their roll a bit.

From the outside looking in, I had built an always-on autonomous agent. The problem was the human-in-the-loop, yours truly, ended up being the biggest blocker resulting in the agent mostly sitting idle. I knew it going in as it was part of the exercise to automate myself out of the loop. The logs told the tale, and things got worse as I had been focusing on side quests, and was expecting the agent to keep on truckin'.

It had accumulated memory files, and was self-authoring rules, and tweaking prompts that nobody had evaluated. Was it helping or hurting? Who fucking knows because I was running mostly on vibes for the first iteration. So it goes.

I've long held opinions against ground up rewrites, but with LLMs burning it to the ground and starting over is supposed to be a viable option, right? RIGHT? Challenging my own beliefs, I went back to first principles and started to rebuild from scratch, keeping all the lessons learned and throwing out the cruft.

It's only after we've lost everything that we're free to do anything

One of my most productive days was throwing away 1,000 lines of code.

Ken Thompson

To me, context engineering is more about what you take away than what you add. I'm not even sure it's a hot take at this point, but it's an opinion I had formed before the frontier labs were publishing papers on the matter. A lot of the news in the last week about sabotage seems related to long-horizon tasks that rely heavily on auto-compaction that keep filling the window until rot sets in.

Even easy work suffers in this scenario, and it's why I've continually focused on descoping of larger tickets and building in phases. Not a popular opinion, but when the time to complete tasks is exponentially lower, the waterfall model reduces a lot of the headaches.

In the OG, I was capping turns and when the cap was met, it would commit to a branch and draft a WIP PR. The next tick picked up from the branch and continued on its merry way. In the rebuild, the agent runs in a fresh process and the harness builds a small dossier (ticket, repo rules, and the previous turn's hand-off note), stable context, ordered from least to most likely to change, so prompt caching has a chance to hold.

The hand-off note is lossy compression on purpose, similar to handing work over to another engineer. It forces decisions about what actually matters. The data from the OG backs it up as roughly 95% of tickets wrapped up in under 100 steps (the cap I set), because as mentioned, I like to scope work into small bites.

The proof is in the pudding

I've discussed previously that my trust needs to be earned, because at the end of the day, LLMs are just prediction engines and not these magical thinking creatures. While my trust has to be earned, the OG skimped on actually proving it.

For the rebuild, nothing LLM-based runs without evals up front. By design, each and every prompt is getting a golden dataset, holdout test split, a grader, and ultimately my sign-off on that specific prompt and model config.

The first thing to tackle was a risk-tier judge to figure out if a human should even look at the change. I ended up building and labelling the dataset from years of my own projects' repos, before and after moving toward AI engineering.

Then I relabelled a blind sample and found that I only agreed with myself 74% of the time. Cohen's kappa of 0.48 if you're a smarter kid than I am. Knowing the noise ceiling means knowing the best score that can actually be measured, because the labels themselves are only so consistent.

Because I'd rather keep as much out of the LLMs as possible, anything that could be handled deterministically was pulled out as rules, rather than leaving them in the prompt. Everything left goes to the LLM and the config that clears the bar for the lowest spend wins.

Not too shocking, for this particular task, the cheapest model was the fastest model. Spoiler, it was Jev, the System One model.

Trust is scored, not felt

I see a lot of folks stitching together several LLMs to have each one check the other's work. They are using shared Markdown notes (context library), and it feels sharper. I totally get it, you argued with the robot over every single detail. Even if you didn't write a single line of code, you steered so you trust it.

Feeling sharper isn't the same as being measured. If you don't track it, you can't improve it. Hell, if you don't track it, are you sure it even happened?

The thing with model diversity is that it only helps when the models fail on different cases. It's why you shouldn't use the same family of models in the same jury. For my ensemble, I'm using Jev, Gemma as my open-weight judge, and Haiku as the cheap frontier model. The group together didn't measurably beat the best individual model either, because it's already at the noise ceiling.

Throwing out the vibes, the rebuild is starting painfully strict, and Igor isn't shipping anything quite yet. I've been focusing on spec, poking holes before laying the foundation. Evals landed first (because of course), then a judge that's earning its keep. Endgame is Igor working on its own code to finish the build-out. I'll still be the one reviewing and approving PRs, with the autonomy coming later.

Once we're there, if I'm accepting the work untouched and the work isn't drifting from the spec I signed off on, I'll take my hands off the wheel. If (honestly, when) things slip, I'll get pulled back in. And if things don't slip, I'm building in regular relabelling and grading sessions to tighten the loop.

Building and labelling datasets takes time and effort which usually means they are skimped on. Even if you put that time in up front, solid chance you'll forget about putting together regressions and doing periodic relabelling sessions. Rather than focusing on the output of my agent, I'm rebuilding around the systems needed to track how well it's all working.

Follow along at home

Since this is a rebuild, I felt like I'd give GitHub another shot both for code hosting and as the first source forge adapter. The OG code is still available for the time being.

The skills powering Igor will also be available, but I've made the decision to keep the eval datasets private. My thought is that there's nothing wrong with everybody enjoying the meal, but I'm not handing over the actual recipe.

This project, like everything else right now, is still very early.

:wq


Like this drivel? There's a whole RSS feed of it, or subscribe via email.