<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Gal B</title>
    <description>The latest articles on DEV Community by Gal B (@galb).</description>
    <link>https://dev.to/galb</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4127795%2F5f3923e9-3ec7-4a25-b677-2945e1352172.png</url>
      <title>DEV Community: Gal B</title>
      <link>https://dev.to/galb</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/galb"/>
    <language>en</language>
    <item>
      <title>I Built an AI Agent That Optimizes Code — But Benchmarks Decide What Survives</title>
      <dc:creator>Gal B</dc:creator>
      <pubDate>Wed, 16 Sep 2026 10:03:01 +0000</pubDate>
      <link>https://dev.to/galb/i-built-an-ai-agent-that-optimizes-code-but-benchmarks-decide-what-survives-kbp</link>
      <guid>https://dev.to/galb/i-built-an-ai-agent-that-optimizes-code-but-benchmarks-decide-what-survives-kbp</guid>
      <description>&lt;h1&gt;
  
  
  I Built an AI Agent That Optimizes Code — But Benchmarks Decide What Survives
&lt;/h1&gt;

&lt;p&gt;AI coding agents are getting very good at proposing changes.&lt;/p&gt;

&lt;p&gt;The problem is that they are also very good at making changes that &lt;em&gt;look&lt;/em&gt; like optimizations.&lt;/p&gt;

&lt;p&gt;A refactor can appear cleaner.&lt;br&gt;
A loop can look more efficient.&lt;br&gt;
A data structure can seem like a better choice.&lt;/p&gt;

&lt;p&gt;But there is only one question that really matters:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Did it actually make the code faster?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That is the idea behind &lt;strong&gt;autor3search&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;GitHub:&lt;br&gt;
&lt;a href="https://github.com/autor3search" rel="noopener noreferrer"&gt;https://github.com/autor3search&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  The core idea
&lt;/h2&gt;

&lt;p&gt;autor3search lets an AI coding agent repeatedly experiment with performance optimizations.&lt;/p&gt;

&lt;p&gt;But there is an important constraint:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The agent does not decide whether its own change is good.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Instead, every experiment is evaluated by a frozen benchmark and test harness.&lt;/p&gt;

&lt;p&gt;The loop looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Agent proposes an optimization
        ↓
Agent changes the implementation
        ↓
Tests run
        ↓
Benchmarks run
        ↓
Measure the result
        ↓
KEEP or DISCARD
        ↓
Try another experiment
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the change improves the measured result and still passes the required checks, it can survive.&lt;/p&gt;

&lt;p&gt;If it does not, it gets discarded.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why freeze the benchmark?
&lt;/h2&gt;

&lt;p&gt;This is probably the most important part of the design.&lt;/p&gt;

&lt;p&gt;If an autonomous agent is allowed to modify both the implementation and the evaluation criteria, you can easily end up with something that appears faster without actually solving the original problem better.&lt;/p&gt;

&lt;p&gt;For example, an agent could unintentionally:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reduce the amount of work performed&lt;/li&gt;
&lt;li&gt;Change the benchmark input&lt;/li&gt;
&lt;li&gt;Remove validation&lt;/li&gt;
&lt;li&gt;Optimize specifically for the benchmark&lt;/li&gt;
&lt;li&gt;Modify test behavior&lt;/li&gt;
&lt;li&gt;Exploit measurement noise&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So the benchmark harness has to act as an external judge.&lt;/p&gt;

&lt;p&gt;The agent can modify the implementation.&lt;/p&gt;

&lt;p&gt;It cannot modify the rules of the game.&lt;/p&gt;

&lt;h2&gt;
  
  
  Inspired by autoresearch
&lt;/h2&gt;

&lt;p&gt;The project is inspired by the idea behind Karpathy's &lt;strong&gt;autoresearch&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Instead of a human manually trying one experiment after another, an agent can continuously:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Form a hypothesis&lt;/li&gt;
&lt;li&gt;Make a change&lt;/li&gt;
&lt;li&gt;Run an experiment&lt;/li&gt;
&lt;li&gt;Measure the result&lt;/li&gt;
&lt;li&gt;Keep or reject the change&lt;/li&gt;
&lt;li&gt;Continue searching&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I wanted to explore what happens when you apply that same idea to ordinary software optimization.&lt;/p&gt;

&lt;p&gt;Instead of optimizing a model-training experiment, autor3search searches for faster software implementations.&lt;/p&gt;

&lt;h2&gt;
  
  
  Example
&lt;/h2&gt;

&lt;p&gt;Imagine the baseline benchmark is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Baseline: 125 ms
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The agent tries an optimization.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Experiment 1: 117 ms
Tests: PASS
Result: KEEP
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then another:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Experiment 2: 131 ms
Tests: PASS
Result: DISCARD
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then another:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Experiment 3: 108 ms
Tests: PASS
Result: KEEP
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The important part is that the agent can keep searching without needing a human to manually evaluate every attempt.&lt;/p&gt;

&lt;p&gt;The measurement system becomes the feedback loop.&lt;/p&gt;

&lt;h2&gt;
  
  
  The difficult part isn't generating optimizations
&lt;/h2&gt;

&lt;p&gt;Modern coding models can generate plenty of optimization ideas.&lt;/p&gt;

&lt;p&gt;The harder problem is creating a trustworthy evaluation loop.&lt;/p&gt;

&lt;p&gt;Some of the questions I am currently exploring are:&lt;/p&gt;

&lt;h3&gt;
  
  
  Benchmark variance
&lt;/h3&gt;

&lt;p&gt;A benchmark rarely produces exactly the same result twice.&lt;/p&gt;

&lt;p&gt;If one run is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;100 ms
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and the next is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;98 ms
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;is that a real improvement?&lt;/p&gt;

&lt;p&gt;Or just noise?&lt;/p&gt;

&lt;p&gt;A production-quality system probably needs multiple benchmark runs, statistical comparison, warm-up handling, outlier detection, and configurable acceptance thresholds.&lt;/p&gt;

&lt;h3&gt;
  
  
  Correctness
&lt;/h3&gt;

&lt;p&gt;Performance cannot come at the expense of correctness.&lt;/p&gt;

&lt;p&gt;An optimization that makes the program 30% faster but changes the output is obviously not an optimization we want to keep.&lt;/p&gt;

&lt;p&gt;So tests need to remain part of the acceptance criteria.&lt;/p&gt;

&lt;h3&gt;
  
  
  Benchmark gaming
&lt;/h3&gt;

&lt;p&gt;Autonomous agents are extremely good at optimizing toward whatever signal you provide.&lt;/p&gt;

&lt;p&gt;That is useful, but it also means the evaluation system has to be carefully designed.&lt;/p&gt;

&lt;p&gt;If there is a shortcut in the benchmark, eventually the agent may find it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Stopping criteria
&lt;/h3&gt;

&lt;p&gt;When should the search stop?&lt;/p&gt;

&lt;p&gt;After:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A fixed number of experiments?&lt;/li&gt;
&lt;li&gt;A certain amount of time?&lt;/li&gt;
&lt;li&gt;No improvement for N experiments?&lt;/li&gt;
&lt;li&gt;A performance target is reached?&lt;/li&gt;
&lt;li&gt;The expected improvement becomes too small?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This becomes an interesting search problem by itself.&lt;/p&gt;

&lt;h2&gt;
  
  
  Multi-language support
&lt;/h2&gt;

&lt;p&gt;I currently have implementations targeting:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Go&lt;/li&gt;
&lt;li&gt;Rust&lt;/li&gt;
&lt;li&gt;Python&lt;/li&gt;
&lt;li&gt;TypeScript / JavaScript&lt;/li&gt;
&lt;li&gt;Java&lt;/li&gt;
&lt;li&gt;C#&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One of the things I want to explore is how differently agents optimize across languages.&lt;/p&gt;

&lt;p&gt;For example, optimization strategies in Python may be completely different from what works in Rust or Go.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why I think this is interesting
&lt;/h2&gt;

&lt;p&gt;Most AI coding tools currently operate like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Human asks for optimization
        ↓
AI writes code
        ↓
Human reviews it
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I am interested in a slightly different model:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Human defines the goal and evaluation
        ↓
Agent performs many experiments
        ↓
Benchmarks provide feedback
        ↓
Agent searches autonomously
        ↓
Human reviews the best result
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The human moves from manually directing every optimization to defining the objective and the constraints.&lt;/p&gt;

&lt;p&gt;That feels like a much more interesting use of coding agents.&lt;/p&gt;

&lt;h2&gt;
  
  
  Open source
&lt;/h2&gt;

&lt;p&gt;autor3search is open source and still early.&lt;/p&gt;

&lt;p&gt;You can find it here:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/autor3search" rel="noopener noreferrer"&gt;https://github.com/autor3search&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I would especially appreciate feedback around:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Benchmark methodology&lt;/li&gt;
&lt;li&gt;Preventing agents from gaming evaluations&lt;/li&gt;
&lt;li&gt;Statistical confidence&lt;/li&gt;
&lt;li&gt;Experiment isolation&lt;/li&gt;
&lt;li&gt;Search strategies&lt;/li&gt;
&lt;li&gt;Real-world repositories that would make good test cases&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you've worked on performance engineering, coding agents, compilers, benchmarking, or autonomous development workflows, I'd be very interested to hear how you would design this system.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>opensource</category>
      <category>performance</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
