Blog

I benchmarked 4 CLI coding agents on an NP-hard optimization problem I solved by hand 8 years ago.

/ 13 min read
Contents Jump to a section
  1. The problem: fiber network design
  2. Agents and conditions
  3. Results
  4. Best scores
  5. All trials
  6. What each agent did
  7. Claude Code (best: 34,061)
  8. Codex (best: 37,586)
  9. Gemini CLI (best: 41,119)
  10. Mistral (best: 53,616)
  11. The prompt matters
  12. Go: faster language, worse results
  13. One hour: Claude Code pulls ahead
  14. Why solutions fail
  15. GLM-5 follow-up
  16. What I learned
  17. Limitations
  18. Reproducing this

TL;DR: I gave an unpublished fiber network optimization problem to four CLI coding agents. The score is total fiber length, lower is better. My best after days of C++ was 34,123; given one hour, Claude Code (Opus 4.6) reached 34,061. A 7-word target hint improved every agent by 18-30%, and about 15% of all trials produced invalid output. I later ran GLM-5 on the same problem: see the follow-up.

Code and raw results: CLIArena

Eight years ago, as an engineering student in France, I spent several days locked in my room writing C++ to solve KIRO 2018, a fiber optic network optimization challenge from my engineering school. Simulated annealing, neighborhood searches, hours of tweaking parameters. My best score was 34,123 (lower is better). Going below 34,000 would have needed a different approach: at that level, shaving off 1,000 points costs as much effort as the previous 10,000.

I have used this problem as my personal coding agent benchmark ever since. It has never been published online, so it can’t be in any training set. It is NP-hard, so there is no shortcut. And unlike SWE-bench or HumanEval, where tasks are pass/fail, it returns a continuous score. You can see how much better one agent is than another, and whether it keeps improving or plateaus.

Why 30 minutes? That’s roughly how long my C++ solver takes to converge to ~34,000. A first attempt from a human in 6 hours (without AI) lands around 40,000. I also ran a 1-hour variant to see whether more time changes the picture. It does, a lot.

The problem: fiber network design

Imagine you need to connect 532 cell towers across Paris to 11 hubs with fiber optic cable running through underground ducts. You want to minimize total cable length, under these constraints:

  • You must build loops for redundancy. A loop starts at a hub, visits up to 30 towers and returns to the same hub.
  • You can hang chains off any tower on a loop. A chain visits up to 5 additional towers.
  • Every tower must be covered exactly once, either on a loop or on a chain.
  • Distances are asymmetric: going from tower A to tower B does not cost the same as B to A, because the cable follows physical duct paths, not straight lines.

In practice:

         ┌── T1 ── T2 ── T3 ──┐
         │                     │
        Hub ── T7 ── T8 ──────┘       ← loop (circuit back to hub, max 30 towers)
                │
                └── T9 ── T10 ── T11   ← chain off T7 (max 5 towers per chain)

The challenge covers three cities of increasing size:

CityHubsTowersDifficulty
Grenoble211Trivial: almost any approach works
Nice365Moderate: structure starts to matter
Paris11532Hard: this is where agents fail

The final score is the sum over the three cities. A naive nearest-neighbor heuristic scores around 50,000-80,000. Going below 40,000 requires iterative optimization (2-opt, simulated annealing). Below 35,000 requires sophisticated multi-phase solvers.

Each agent gets the problem statement in markdown and the CSV data files, and runs in a Docker container via Harbor, an agent benchmarking framework. Three trials per condition.

Agents and conditions

I ran each agent with its default model: Claude Code with Opus 4.6, Codex with GPT-5.3-Codex (xhigh), Gemini CLI with Gemini-3-Pro-Preview, and Mistral with Devstral-2. From here on I use the agent name for the pair.

Each agent ran under five conditions:

  1. Base (30 min, Python): the raw problem description + “you have 30 minutes, save early and often”.
  2. Keep improving (30 min, Python): adds “this will be released to the public, it is critical for your company’s reputation, keep improving until timeout”.
  3. Target hint (30 min, Python): adds “the best solution is around 32,000, if you’re not close, keep trying”. This feels like cheating, but I don’t know the optimal score. I made up a round number below my best. It still helps a lot.
  4. Go required (30 min, Go): same as #2, but the agent must write Go instead of Python.
  5. One hour (60 min, Python): same as #2, with twice the wall-clock time.

When no language is specified, every agent defaults to Python. I tested Go because a compiled language should iterate faster in simulated annealing: more iterations per second, more chances to escape local minima. I chose Go over C++ because I didn’t want agents wasting time on compilation errors. (They still did.)

Four agents, five conditions, three trials each: 60 trials in total.

Results

Best scores

Best score per agent

AgentBest scoreConditionvs. my C++ (34,123)vs. human 30min (~40k)
Claude Code34,06160min Python-0.2%-15%
Codex37,58660min Python+10%-6%
Gemini CLI41,11960min Python+20%+3%
Mistral53,61630min + target hint+57%+34%

Claude Code’s 34,061 beat my multi-day C++ solution by 62 points. On a problem where the last 1,000 points cost the most effort, 62 points is not nothing. But it was one trial out of three (more in the one-hour section).

All trials

All trial scores

All 60 trials across the 5 conditions. The X markers are invalid solutions: any constraint violation gets an automatic 999,999,999 penalty, and 9 of the 60 trials got it. Purple markers are 1-hour trials and green markers are Go trials. Claude Code’s lowest point on the chart is the single purple dot at 34,061.

What each agent did

I read through the agent trajectories. The approaches differ a lot.

Claude Code (best: 34,061)

Claude Code was the most methodical. In its best run (the 1-hour trial), it rewrote its solver four times (v1 → v2 → v3 → v4). Each time it found a structural bug, it started fresh instead of patching:

“Instead of patching the v2 solver, let me write a cleaner, more robust v3 solver that handles all edge cases properly”

“The problem is the perturbation loop runs forever because budget check is wrong. Let me write a cleaner, faster v4 solver”

It adapted its strategy to each city. For Grenoble (11 terminals), it ran a near-exhaustive search and found that a single loop with chains was optimal, scoring 2,056. For Nice (65 terminals, only 3 hubs), it treated the problem as a partition problem and used simulated annealing, scoring 6,266. For Paris (532 terminals), it spent over 60% of the total time on Iterated Local Search with destroy-and-repair perturbation: it deliberately breaks a good solution to escape a local minimum, then rebuilds it.

Paris kept improving over the hour:

27,630 → 27,378 → 26,447 → 26,306 → 26,290 → 26,183 → 26,036 → 25,958 → 25,739

It also ran parallel optimization processes for different cities, killed stuck processes, and switched approaches when one stalled. At the 30-minute mark it was at ~36,000, competitive but not exceptional. It pulled away in the second half hour.

Claude Code also built a constraint validator early and validated every solution before saving it. That caught bugs during development that the other agents only discovered at evaluation time, or never.

Codex (best: 37,586)

Codex was more direct. It reasoned in French, the language of the problem statement:

“Je vais construire une solution faisable immediatement pour les 3 villes, puis lancer une amelioration iterative en sauvegardant a chaque gain.”

Its solver was simpler, with fewer optimization passes but a cleaner implementation: get a valid solution fast, then run 2-opt.

One trial was painful to read. Under the target hint prompt, Codex was steadily improving Paris (31,307 → 31,277 → 31,217 → 31,181 → 31,091 → 31,061) and was still going down when the timeout hit. It had just noted “meilleur coût candidat descendu à 31091”. The trial scored 999,999,999 because Codex never saved any output file. It had a working, improving solution in memory and lost everything.

With one hour, Codex barely improved on its 30-minute results (-2%). Its simpler solver hit a ceiling that more time couldn’t break.

Gemini CLI (best: 41,119)

Gemini CLI took the most economical approach: k-means-style clustering with a facility location proxy, then greedy chain construction. It took fewer steps than any other agent (~13, against ~80 for Claude Code) and often finished in under 5 minutes of a 30-minute window. It got valid solutions quickly but never invested in the deep optimization passes that brought Claude Code and Codex down. It also hit rate limits in some trials, which limited its iterations further.

With one hour, it improved by 10% to 41,119, so it was time-starved at 30 minutes.

Mistral (best: 53,616)

Mistral struggled. Its base prompt runs averaged 87,099, more than double the leaders. The trajectory shows why: it implemented a nearest-neighbor heuristic with a hardcoded distance threshold of 3,000, produced a first feasible solution in about 8 minutes, and stopped. No improvement loop, no local search, one shot.

With the keep improving prompt, it got worse: 2 of 3 trials produced invalid solutions. The extra pressure seemed to push it toward more ambitious algorithms it couldn’t implement correctly, and without a validator the broken solutions went straight to disk.

With one hour, it improved to 54,321 (-41% relative to its base average) but stayed far behind, and 1 of its 3 one-hour trials was still invalid.

The prompt matters

Effect of prompt engineering

Adding the target hint (“best solution is around 32,000”) helped every agent:

AgentBase mean+ target hint meanImprovement
Claude Code48,15339,127-19%
Codex47,24038,724*-18%
Gemini CLI58,13245,337*-22%
Mistral87,09961,062-30%

*Codex and Gemini CLI each had 1 invalid trial (999,999,999) in the target hint condition; means are over valid trials only.

Telling the agent what good looks like makes a big difference. Without a target, an agent can’t tell whether its first valid solution is great or terrible, so it is more likely to stop early.

The keep improving prompt, without a target score, gave mixed results. For Mistral it was harmful: vague urgency without a concrete benchmark pushed a weaker agent toward overengineering and constraint violations.

Go: faster language, worse results

I told the agents they must write Go. Go compiles to native code, so the solver should run faster and fit more optimization iterations into the same 30 minutes.

Best score by condition

AgentBest (Python 30min)Best (Go 30min)Invalid trials (Go)
Claude Code39,54037,9741/3
Codex38,35840,8130/3
Gemini CLI45,67964,0672/3
Mistral92,41969,8011/3

Claude Code scored better in Go (37,974 vs 39,540): the raw speed let its solver run more iterations. It also produced 1 invalid trial. The others did worse. Codex regressed, Gemini CLI failed 2 of 3 trials, and Mistral produced one trial at 282,951, valid but terrible, because it spent its time getting Go to compile instead of optimizing. Overall, 4 of 12 Go trials were invalid, against 2 of 12 for the same prompt in Python.

The cause is specific to Go. The agents spent so much time fighting the compiler that they skipped constraint validation. Claude Code timed out while its Go solver was still running, so it never got to self-verify. Gemini CLI finished both invalid trials in under 4 minutes (out of 30), reporting “all constraints are strictly followed” while the verifier found 60+ chain violations. In Python, these agents built validators into their iteration loops. In Go, the compile-run-fix cycle was slow enough that validation was the first thing they cut.

One hour: Claude Code pulls ahead

AgentBest (30min)Best (60min)Mean (60min)
Claude Code39,54034,06139,125
Codex38,35837,58642,114
Gemini CLI45,67941,11944,667
Mistral92,41954,32162,167*

*Mistral mean over 2 valid trials; 1 of 3 was invalid.

Claude Code’s 34,061 is 62 points better than my C++ solution. But its three 1-hour trials averaged 39,125: the other two scored 41,714 and 41,601, well above my baseline. The 34,061 was the exception, not the rule.

More time only helped agents whose solver could use it. Claude Code’s iterative loops kept finding improvements for the whole hour, while Codex plateaued.

Why solutions fail

Across all 60 trials, 9 produced invalid solutions, for three reasons:

  1. Chain-to-loop violations (7 of 9). The agent builds chains attached to nodes that are not on any loop. Optimization passes like 2-opt reorder or remove nodes from loops without updating the chain anchors, so a chain still points to a node that used to be on the loop.
  2. No output file (1 of 9). The Codex trial that was still optimizing at the timeout. A time management failure, not a logic bug.
  3. Malformed output (1 of 9). A Gemini CLI trial wrote chain definitions before any loop definition, and the parser rejected the file.

Paris, with 532 towers and 11 hubs, is where constraint satisfaction gets hard. The per-trial breakdown:

Failed trialGrenoble (13 nodes)Nice (68 nodes)Paris (543 nodes)
Mistral (Python)Valid (2,640)14 chain errors77 chain errors
Mistral (Python)Valid (2,324)Valid (11,616)86 chain errors
Gemini (Python)Valid (2,458)4 chain errorsMalformed file
Codex (Python)No fileNo fileNo file
Claude (Go)1 chain error12 chain errors35 chain errors
Gemini (Go)Valid (2,221)Valid (10,576)60 chain errors
Gemini (Go)Valid (2,221)Valid (12,628)11 chain errors
Mistral (Go)Valid (2,689)Valid (31,808)3 chain errors

Grenoble almost never fails: with 13 nodes, it is hard to create a violation by accident. Nice fails occasionally. Paris is where every agent’s chain logic breaks. Some failures were close. Mistral’s Go trial had only 3 chain errors in Paris, and two Gemini CLI trials had valid Grenoble and Nice scores that would have added up to competitive totals, until a handful of Paris errors invalidated everything.

The valid 282,951 Mistral Go trial breaks down as Grenoble 3,132, Nice 36,038 and Paris 243,781: a valid but unoptimized solution that was never improved.

GLM-5 follow-up

After this benchmark, I ran Zhipu AI’s GLM-5 through two agents, Claude Code and my fork of Mistral Vibe, under the same five conditions. Its best score lands next to Gemini CLI, but 8 of its 27 completed trials were invalid and every trial hit the timeout. The full analysis, including Terminal-Bench, is in GLM-5 with coding agents.

All agents comparison

AgentBest scorevs. my C++
Claude Code + Opus 4.634,061-0.2%
Codex + GPT-5.337,586+10%
Claude Code + GLM-540,943+20%
Gemini CLI + Gemini-3-Pro41,119+20%
Mistral Vibe + GLM-546,764+37%
Mistral + Devstral-253,616+57%

What I learned

  1. Save early, improve forever. All four agents know what 2-opt is. The gap between Claude Code or Codex and Mistral comes from whether the agent sets up a solver that keeps improving and saves valid solutions along the way, or writes a one-shot heuristic and stops.
  2. Tell agents what good looks like. A 7-word hint improved every agent by 18-30%, and I made up the number. Vague urgency (“this is critical for your company”) gave mixed results and hurt Mistral. A concrete target, even an approximate one, changes behavior more than motivational framing.
  3. Python is the AI language. Go was supposed to give faster iterations. Instead, agents fought the compiler and skipped validation: 4 of 12 Go trials failed, against 2 of 12 in Python.
  4. The agent is more than a wrapper. The GLM-5 follow-up ran the same model through two agents, and which one won depended on the task.
  5. Best score and reliability are different things. GLM-5’s best KIRO score is competitive, but 30% of its trials were invalid. Benchmarks rarely report that number, and it is the one that matters for real work.

Limitations

I think it’s healthy to run your own benchmarks instead of trusting the ones published by the companies selling you the product. This is mine.

It is one task in one problem domain. The sample is small: 3 trials per condition per agent, 60 in total. The agents ran in Docker containers with subscription-tier access, so rate limits may have affected some runs. The problem statement is in French, which may disadvantage some agents. The Go and one-hour experiments used only the keep improving prompt.

Take this as a data point, not a leaderboard.

Reproducing this

The task definition, verifier and all raw results are in CLIArena. The benchmark runs on Harbor. Total compute cost was roughly the price of 4 monthly subscriptions for a few hours of use.

If you have run similar benchmarks on non-standard tasks, I’d love to compare notes. SWE-bench and HumanEval are binary pass/fail on well-known problem patterns. Continuous optimization on a novel NP-hard problem seems to me a better test of what an agent can actually do.