AI Engineer World's Fair 2026
Agents Building Agents
Loading slides…
Read the talk
Agents Building Agents: Evals, Experiments, and Production Feedback
A coding agent can improve another agent when it can inspect failures, test a specific hypothesis, and retain only changes that survive evaluation.
From a talk by Alfonso Graziano
Before you start: Familiarity with LLM tool calling, automated tests, and Git branches will help; the TypeScript example requires only basic asynchronous programming.
How do you improve software that does not behave deterministically?
How do you make an agent reliable enough for workflow automation or search when its answers can vary, hallucinate, and incur substantial cost? Alfonso Graziano approaches that question from his work on agent projects at Nearform. He introduces himself as a tech lead supporting teams adopting AI-native engineering and as the author of Learning AI-Native Software Engineering. The demand for agents is clear; the engineering process for improving them needs equal attention.
Agents are software, so coding assistants can help build and improve them. The challenge is to give those assistants a repeatable way to recognize progress. Graziano’s process addresses non-determinism, latency, cost, and hallucinations only partially, but it makes improvement something a team can investigate and test rather than guess at.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Define the behavior before optimizing it
At its core, an agent is an LLM running inside a loop, connected to tools and able to retrieve context. Evals and observability surround that loop: they tell you whether it did the necessary work and help explain what happened. This creates two distinct places to look for failures: the evaluation suite and live use. Real users bring inputs and expectations that can be broader and messier than the cases already represented in an eval.
For evaluation, start with a Golden dataset: a file or set of files developed with subject-matter experts that pairs inputs with expected behavior. In a simple dataset, the expected output might be a number, text, or an IMPOSSIBLE label. These concrete examples establish what the system should return before anyone tries to optimize it.
For an agent that acts through tools, the expected output can describe execution rather than just an answer.
| Expectation | What an evaluator checks |
|---|---|
| Answer | Required text or value |
| Tool selection | The required tool was called |
| Tool arguments | The call used the expected parameters |
| Tool sequence | Calls occurred in the required order |
For example, a task may require retrieval before an update. A plausible final sentence would not establish that the agent followed that sequence. The dataset therefore works like a test suite for a non-deterministic system, with one or more scorers translating the observed behavior into measurements. Those measurements establish a baseline and expose regressions as the agent changes.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
A minimal agent exposes missing capabilities
The demonstration starts with a minimal Mastra agent named a math agent, although its Golden dataset contains several types of questions. It has a name, a few instructions, and a model, but no tools. Its evaluator is equally simple: check whether the model’s response contains the expected ground-truth output. The essential check can be expressed directly in TypeScript:
typescript
type AnswerCase = {
input: string;
expected: string;
};
type AnswerResult = AnswerCase & {
actual: string;
passed: boolean;
};
async function evaluateAnswers(
cases: readonly AnswerCase[],
answer: (input: string) => Promise<string>,
): Promise<AnswerResult[]> {
const results: AnswerResult[] = [];
for (const testCase of cases) {
const actual = await answer(testCase.input);
results.push({
...testCase,
actual,
passed: actual.includes(testCase.expected),
});
}
return results;
}
This preserves the demonstration’s deliberately naive scoring rule. It tests substring presence; it does not establish that an explanation is correct or that a required tool sequence occurred.
Graziano reports an 18% pass rate for the tool-free agent on this example suite using the substring evaluator. He attributes the passing cases, such as simple additions and multiplications, to knowledge available in the model’s weights. That attribution explains why an agent without external access can answer some questions; the score alone does not identify the limits of what its weights can answer.
The failures suggest three places to investigate, in order:
- Missing tools. If a task requires browsing or fetching a web page, an agent without those capabilities cannot complete the intended workflow.
- Incomplete system instructions. The system prompt defines desired behavior, prohibited behavior, and domain-specific instructions. Updating it may resolve failures without adding another component.
- Missing context retrieval. The agent may not know where to find the information it needs. Retrieval is commonly exposed through tools, such as a RAG search or web fetch, and those tools must provide access securely.
These are concrete changes a coding agent can make and evaluate.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Turn evaluation into an experiment loop
Andrej Karpathy’s autoresearch supplies the precedent: a coding agent changes Python training code and hyperparameters, runs experiments, and uses the results to decide what to try next. Each dot in the chart Graziano discusses represents an experiment. He describes progress as improving accuracy and decreasing loss; the project’s documented objective is more specifically validation bits per byte, where lower is better, under a fixed five-minute training budget. The transferable mechanism is a repeated, measured experiment. Can the same mechanism improve an agent?
AutoAgent applies that loop to an agent’s implementation. It runs evals, changes code or system prompts, creates tools when needed, and runs the evals again to see whether the changes helped.
Graziano reports that the minimal example improved from 18% to 83% evaluation accuracy in approximately ten iterations. The starting point matters: an agent with no tools leaves obvious capabilities to add, and the example uses the simple evaluator introduced earlier.
He separately reports a +10% improvement on some internal benchmarks for an already human-optimized production agent. The talk does not specify whether this means relative percent or percentage points. The useful observation is that the coding agent found changes the human optimization process had missed.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Give the coding agent feedback and boundaries
The demonstrated coding agent is Claude Code, although the process can use other coding agents. It writes the target agent’s code, then receives feedback from the target’s evals: which cases now pass and which have regressed. It can also inspect full execution traces, including available thinking traces, to investigate a failure instead of relying on an aggregate score.
The optimizer must not be allowed to redefine success merely to pass the tests. Humans provide the initial agent structure, relevant files, domain context, and permitted changes. In particular, they prohibit modifying the Golden dataset or scorers just to make an eval pass. Otherwise, a higher score could reflect a weaker test instead of a better agent.
The optimization job is a Markdown document. It specifies the objective, target repository, metrics, and whatever additional context the coding agent needs to work within those boundaries. This is the practical role of a specification: tell the optimizer what it is trying to improve and where it is allowed to intervene.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Keep successful code and remember unsuccessful experiments
Run the evals once to establish the baseline, then begin a bounded optimization loop. Each iteration creates a hypothesis about one class of failures, modifies the agent, and evaluates the result. A regression calls for rollback; an improvement can become the starting point for the next experiment. The illustrated sequence includes a regression, an improvement, a flat result, and another hypothesis. Past hypotheses remain available, and the operator chooses how many iterations to run.
The baseline report is more than a single score. It records the cases and summarizes what works and what fails, giving the coding agent a concrete starting point for investigation. Without that detail, the agent knows that performance is poor but has little evidence about why.
Each subsequent experiment follows a reviewable procedure:
- Create a new branch and formulate a hypothesis.
- Change the target agent to implement that hypothesis.
- Run the eval suite and write a report of the outcome.
- Update the shared memory of experiments.
- Continue from the candidate branch if the metrics improve; otherwise return to the previous successful branch.
Graziano refers to the per-experiment artifact as report.md. The repository’s current case-sensitive filenames are REPORT.md, MEMORY.md, and JOB.md; the mechanism is the same. The memory file and earlier reports inform the next investigation.
Consider a successful first hypothesis followed by an unsuccessful second one. The third experiment branches from the first hypothesis’s successful code, not from the rejected second change. Yet the record of the second experiment remains useful. Rollback removes a code change without erasing what the optimizer learned.
Across iterations, this produces a changelog of hypotheses, improvements, regressions, and reports. Humans can inspect a failed experiment and distinguish a poor idea from a promising idea implemented incorrectly. A later instruction can then steer the coding agent toward a better implementation rather than blindly repeating or permanently discarding the hypothesis.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Improve the details of an existing agent
In a later example, Graziano reports evaluation accuracy increasing from 67% to 86% in approximately ten iterations for an agent now running in production. He attributes the improvement to finding edge cases, refining the system prompt, improving tool descriptions, and fixing tool logic, rather than changing the evaluation criteria. The talk does not supply the task definition, evaluation split, or scorer for this result.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Use live feedback to discover missing failure cases
An agent can improve against its existing evals and still disappoint real users. The second workflow starts with data from users, beta testers, and subject-matter experts. A simple helpfulness question, a yes-or-no response, and a note give the team feedback that the original dataset may never have anticipated.
The pipeline connects that feedback to execution evidence:
- Users interact with the service, and the system collects traces.
- Users submit feedback, or experts annotate traces after examining inputs, outputs, tool calls, and behavior.
- An analysis workflow examines positive and negative feedback, with particular attention to negative cases.
- It groups recurring problems into failure clusters.
- Subject-matter experts validate those clusters before a coding agent generates and implements a fix proposal.
- The team tests the fix against collected traces, ships it, and observes whether performance improves on real data.
Clustering turns a collection of complaints into a smaller set of candidate explanations. Graziano illustrates this with a handful of failure modes supported by groups of traces: the question is what shared cause explains the behavior, not merely how many users disliked an answer.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Connect a complaint to its trace and source code
The concrete user example asks how to optimize a React component. Alongside the response, the system records the interaction, tool usage, response time, and token consumption. The user can then describe what went well, what failed, and what they expected. The displayed feedback form and trace show the same comment about an overly long answer, making the connection between the complaint and the recorded execution visible.
If a user leaves no feedback, a subject-matter expert can inspect the trace and annotate it instead. The demonstration exports 114 traces with feedback locally for cluster analysis. A coding-agent skill instructs the agent to inspect the JSON, cluster failures, and conduct an adversarial review of the analysis.
Access to both the target agent’s source code and detailed traces lets the coding agent investigate possible root causes. It can follow the execution that produced an answer and relate that behavior to the implementation before proposing changes. The result is a Markdown report with an executive summary, positive and negative feedback, a negative-feedback rate, failure clusters, and possible improvements.
One example cluster concerns Markdown formatting: URLs are not hyperlinked, and formatting is inconsistent. The report connects that cluster to trace IDs and user feedback, then presents possible causes and proposed fixes. Those links make the diagnosis inspectable, but the report is still a set of candidates for review. Generating it does not complete the decision about what should change.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Turn validated failures into regression coverage
Subject-matter experts triage the report and decide what to fix now, fix later, or leave unchanged. For an accepted fix, the coding agent receives the failure mode, relevant context, and supporting traces. A cluster can also be discarded: it may be a false positive or describe intended behavior that a user happened to dislike. Human judgment determines which expectations the system should adopt.
Accepted failure modes then become part of the Golden dataset, with evals and scorers updated to catch their reintroduction. This is a deliberate expansion of the behavior the team expects, following investigation and validation. It complements the earlier restriction against letting an optimizer weaken tests just to improve its score. The next code change can now be checked against a failure that previously existed only in live feedback.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Choose an analysis cadence and a remediation path
Graziano’s teams have found once-per-sprint analysis reasonable, with the cadence adjusted to feedback volume. His volume examples are operating guidance: a batch of roughly 100 traces might justify a report, while 10,000 traces with feedback may be better divided across multiple reports. The goal is to give each analysis a useful body of evidence without allowing the backlog to become unwieldy.
Graziano reports cases where a coding agent fixed an entire suite of issues with one prompt when supplied with sufficient context and regression tests. The tests give the agent a way to check its changes instead of stopping after editing code. For more complex cases, his teams have directed AutoAgent at failure clusters and had it produce draft pull requests for review.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Build the environment that makes improvement possible
Both workflows depend on harness engineering: building the environment around a coding agent so it can change code, validate its own changes, and revise an unsuccessful proposal. The harness supplies tasks, constraints, feedback loops, and governance. Without those, the coding agent can generate changes but has no dependable process for deciding whether they helped.
The environment brings together four complementary controls:
- Spec-driven development. Turn each accepted failure mode into a specification of expected behavior, then implement it.
- Quality gates. Use linting, unit tests, evals, and LLM code review to examine changes from different angles.
- Context engineering. Supply the relevant information the coding agent needs to understand the task and its constraints.
- Observability. Make production behavior visible so failures can be investigated after shipping.
Production observation keeps the process open: a deployed change generates new evidence, and that evidence can reveal the next bug or missing expectation. The coding agent’s ability to improve the system depends on the team making that behavior visible and testable.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Resources
From the talk
Agent optimization orchestrator with hypothesis branches, evaluation reports, persistent memory and rollback, including setup instructions.
Autonomous experiments on single-GPU language-model training, using five-minute runs and validation bits per byte to select improvements.
Current guide to configuring agents, supplying instructions and models, and adding tools.
Further reading
Companion Mastra project linked by AutoAgent as a target for its math-agent optimization workflow.
Full transcript
Loading transcript…