All Writings

An AI Agent to Profile an AI Agent

We used to write code to profile our code. Now we run an agent to profile our agents.

Before coding agents existed, or before they were any good, we wrote code to get things done: run a task, run an experiment, make a build. Sometimes a run took a while — five minutes, sometimes two hours.

When we wanted to make progress faster, we wrote more code: diagnostics and profilers that went through the runs we had already done and showed us where the bottlenecks were. What was taking so long? What was using the most resources? Then we worked out how to remove those bottlenecks. We wrote code to profile the runs we had started with code.

Now we start a coding agent and ask it to do something, and it often takes 15 minutes, or 2 hours, or 20 hours. So we start another AI agent and ask it why the first one is so slow, what is slowing it down, and how to make it faster.

We use an AI agent to profile another AI agent.

That changes what we need to profile. A slow agent run can spend most of its time waiting for tools, retrying the same approach, or building on something it never checked. A faster model only shortens part of that. If the agent is working from a wrong assumption, making it faster can just get us further down the wrong path.

So a useful question for the profiling agent is: where was the first point that the working agent acted on something it had never verified? Maybe it assumed a command had finished, that its change was running, or that a passing test meant the task was done. Find that point, then ask what small check would have caught it before more work depended on it.

This also changes how we think about tests. A simulator can pass while the real target fails. A scorer can reward something that only looks like success. Those tests help us choose what to try, but we still have to check the result where it matters: in the deployed software, on the actual device, or in the physical task. The profiling agent should ask what each test proves, and what it leaves unknown.

We also need to keep the failed attempts in the record. If we only look at the final successful run, we lose the retries, failed starts, and time spent discovering that the earlier tests were incomplete. Compare the same task, under the same conditions, and count the whole path to a checked result. Otherwise we can make a run look faster simply by forgetting part of it.

The second agent needs evidence too. Give it the commands, outputs, timestamps, and test results, along with the first agent's explanation. It should be able to point to the observation behind each claim. Two agents agreeing on a story does not give us two independent checks if both are relying on the same untested assumption.

And give the profiling agent a stopping point. Ask it to find one expensive mistake, propose one change to the workflow, and say how we will check that change on the next comparable run. Profiling takes time too. A longer report is only useful if it helps us avoid more work than it creates.

The result should be a better next run. Put a check before the expensive step. Define what success will look like before starting. Stop repeating an attempt when it no longer tells us anything new. These are small changes, but each can prevent a whole chain of unnecessary work.

We used to profile code to find where the machine spent its time. Now we can profile an agent to find where the work stopped producing evidence. The useful measure is how long it takes us to reach a result we have actually checked. That is what the second agent should help us improve.