All posts

Blog

Making agents behave

Two weeks of tuning Mumble, one knob at a time

Making agents behave. You talk, it draws onto the canvas; speech, model, prompts and tools all feed the canvas, and the goal is the same result run after run, one version per turn, measured not guessed.

Building an agent is a lot like cooking a dish. Sometimes you have a recipe, sometimes you start from your head, but either way you know roughly what you want on the plate. Getting the right ingredients is only half of it. The other half is controlling the steps so the recipe holds up the next time you make it.

And it never comes out exactly the same. The flour is a different brand this week, the kitchen is warmer, your arms are sore when you knead the dough. The job isn't to make one perfect plate. It's to write a recipe that's good enough for a thousand batches.

That's most of what I do with agents.

About two weeks ago I had some extra time on my hands and wanted a project to tinker on. So I reached out to my friend Quynh and asked for access to a demo she'd been building. It's called Mumble. You talk, and it draws what you say onto a canvas in a few fun ways, while the transcript builds up beside it.

It was exactly the kind of problem I like: non-deterministic, non-trivial, and a clear stretch for my skill set. Speech in, structure out, and a model in the middle deciding what your words mean.

My last post was about the how: how I split my days between agents, briefs and focus blocks. This one is about the what. What it actually takes to turn a promising demo into an agent that behaves the same way on Tuesday as it did on Monday and how to improve it by Thursday, and measure that difference.

The what

The first thing I do when I step into a project is answer three questions: what, how and who.

The what is the job to be done. It's less about the feature list, and more about what people are actually trying to achieve when they open the tool. For Mumble, that's turning a messy stream of spoken thought into something you can look at and reason about.

The what is the main driver of an agent's evaluation system. Once I can say what a good outcome looks like, I can reward the agent for it, build datasets to test against, and settle trade-offs with something solid on the table. It feeds marketing, tests, automations and most decisions after that.

It also tells you when your evals are looking in the wrong place. Early on I found a gap between what the existing checks rewarded and what the person who built the product thought was weakest. The checks were passing outputs a human would have sent back - this is a common mistake with early-stage agents, and the biggest reason we need human checks for early prototypes.

Three questions set the dials. What, the job to be done, sets the evals through rewards and datasets. How, the architecture, sets the config so it is easy to tweak or swap. Who, the audience, sets the knobs for cost and speed. Together they give an agent that behaves run after run. Get the what wrong, and you optimise for the wrong thing.

Each question sets a different kind of dial. Get the what wrong, and you'll optimise beautifully towards the wrong thing.

The how

The how is the architecture. I draw it out first, with Claude, and capture an intent layer in the codebase as it is: short files next to the code that say what each part is for, what it must never do, and why. Along the way I note any red flags and contradictions, and the strengths that make the product unique and different. There's a bunch of good articles on intent layers already, if you haven't used them, I suggest you start here: https://intent-systems.com/blog/intent-layer

In Mumble's case most of the architecture was already well built. It was a little thin in places, and the evals existed but lacked robustness. The bones were good - that's a very lucky place to be in, I know most people don't have this privilege.

With any AI-native product, I want it adaptable enough to take on new advancements quickly. Models change monthly, and the one you pick today won't be the one you ship in six months. So most of my foundational work went into two things: lifting logic up into a layer that's easy to tweak or replace, and measuring the core assumptions to see whether the decisions underneath were well founded.

Model access goes through Vercel AI Gateway (vercel.com/ai-gateway), so trying a different model is a line in the config, not a code change.

In practice, that meant one versioned config. Every knob that changes behaviour lives in it, and each version gets an ID that's stamped on every turn the agent takes.

One config, one version per turn. The config holds models, prompts, tools and limits, every knob in one place. A bump gives a version ID, one per change, like a release number. Model calls go through the AI gateway, so swapping a model is a config change, not a code change. Every turn is stamped with the version, and traces show versions side by side with cost, latency and what the agent did. Then keep or drop the change. Name the version, or you can't tell what helped.

Two versions can then be compared like two releases, instead of two vibes. If I can't name the version that produced an output, I can't tell whether my last change helped.

Every turn lands in Langfuse (langfuse.com) as a trace, tagged with that version ID. That's where I line two versions up side by side and see what actually changed - cost, latency, and what the agent did along the way.

The who

Lastly, the who. The target audience is what lets you set the knobs on the agent at just the right spot. The audience doesn't only define go-to-market and pricing. They're the real decision makers for the technology inside the product.

Mumble's audience is price-sensitive and doesn't come with an AI subscription of its own. That one fact reshaped the engineering. If we provide the model, every turn costs us something, and a canvas that draws itself as you talk is a lot of turns.

So I landed on two north star metrics for my side of the project:

  • Cost per turn has to be very low.
  • The local speech-to-text model has to be fast enough that you see something on the canvas almost as soon as you stop talking.

I chose them because that's where ten-plus years of building products tell me this audience will feel it. A slow first drawing reads as broken. An expensive turn quietly kills the business model before anyone notices.

Quality still has to clear the bar. But cost and latency are what I steer by.

The noise floor

One part where traditional SDLC usually has us scratching our heads is the non-deterministic nature of agent outcomes. Takes a lot of thought to unlearn this, but bear with me.

If you run the same input through the same config five times, you get five slightly different canvases, and five slightly different scores. That spread, measured as the standard deviation of the scores, is the noise floor. Any improvement smaller than the noise floor is luck, not progress.

When I picked up Mumble, the benchmarks had been run once per variant. That's completely normal for a demo built fast, and it was the first thing I wanted to fix. One run per variant tells you which run came out better that day. It doesn't tell you which config is better.

One run each can pick the wrong config. With one run each, config B looks better, but the same input gives a different canvas each time. With five runs each, the average of five shows config A is ahead, with noise of plus or minus one standard deviation around each average. Run it again before you believe it. Smaller than the noise floor is luck, not progress.

So the first real experiment wasn't a change at all. Same config, same pilot cases, run several times over, just to see how wide the band is. Averaging more runs narrows it: the noise on an average, called the standard error, shrinks with the square root of the number of runs. Five against five is far more honest than one against one. In the long term, you want to make your noise as small as you can, and that's by tightening guardrails, introducing more deterministic steps in your tools, and getting very very clear on your job to be done. If you can narrow your noise floor to 5-7%, you are doing really well.

One knob at a time

Once I know the noise floor, the loop is simple, and a little boring on purpose.

One knob at a time. Change one knob, a model, prompt or tool, never two at once. Run it on the same cases, five runs, to measure the spread. Does it beat the noise compared to the current version, not to memory? If yes, keep it as a new version and ship it. If no, drop it and go back to the last version. Either way, write down why in the decisions log, then move to the next knob. Boring on purpose.

One knob at a time sounds slow. It's the fastest way I know to learn something I can trust. If I change the model and the prompt in the same PR, I'll never know which one did the work.

Mumble gave me a nice example of why. I gave the agent a stricter, typed contract for how it writes to the canvas. Protocol errors disappeared on every model I tried. The structural mistakes in the drawings barely moved. A typed tool fixed the protocol, not the judgment. The contract moved reliability, and the model moved quality. If I'd bundled those two changes, I would have credited the wrong one.

Speed is the easy thing to measure, so it's tempting to stop there. But quality is the product. The next step is a judge: an LLM grader calibrated against canvases a human has already reviewed, so "better" means what a person would say, not what a script can count.

What I share, and why

None of this came out of nowhere. It's compounding knowledge from several years of building products, and I haven't built any of it alone. Some of the patterns here take inspiration from earlier work, and I've kept the details of those products out of this post.

I don't think we should let AI push us into working in silos either. We need to be able to talk about how these systems are built - the architecture, the loops, the mistakes - without the fear of being copied or sued over IP. That's how a craft gets better.

The technology is only as good as we make it, and we make it with humans, for humans. Quynh built the thing that made all of this possible. My job was to help make it repeatable.

Part structure, part judgment

Looking back over these two weeks, the split looks a lot like my last post.

The structure is what can be written down: the what, how and who, one versioned config, a measured noise floor, one knob at a time, and every decision logged as it happens.

The judgment is everything a config can't hold: noticing that an eval passes outputs a person would reject, choosing which two metrics matter for this audience, and knowing when a difference is worth chasing and when it's just noise.

You need both. Structure without judgment gives you a very reproducible bad agent. Judgment without structure gives you one great demo you can never repeat.

If you want to try some of this on your own agent this week:

  • Write the job to be done in one sentence, then check whether your evals reward it.
  • Put every behaviour knob in one versioned config, and stamp the version on every turn.
  • Run your current setup five times before you change anything.
  • Change one thing per experiment, and write down why you kept or dropped it.
  • Pick your north star metrics from your audience, not from a leaderboard.

If you take two or three of these and try them, I'd love to hear which ones stuck.