GEMINI LABJP
SHEETS — Fill with Gemini expands to 28 more languages, so you can build spreadsheets in your own language with natural promptsALPHAEVOLVE — Gemini Enterprise makes AlphaEvolve generally available, autonomously discovering optimized code solutionsSPARK — Gemini Spark, a personal AI agent for macOS, organizes folders and runs workflows across WorkspaceOMNI — Gemini Omni blends text, photos, and video for high-quality creation, plus custom AI avatars of youGEMINI35 — Gemini 3.5 Pro slips to July 17 for a full rebuild, introducing a 2M-token context and Deep ThinkDEEPTHINK — The 3.5 Pro rebuild targets better math reasoning, SVG scene generation, and image qualitySHEETS — Fill with Gemini expands to 28 more languages, so you can build spreadsheets in your own language with natural promptsALPHAEVOLVE — Gemini Enterprise makes AlphaEvolve generally available, autonomously discovering optimized code solutionsSPARK — Gemini Spark, a personal AI agent for macOS, organizes folders and runs workflows across WorkspaceOMNI — Gemini Omni blends text, photos, and video for high-quality creation, plus custom AI avatars of youGEMINI35 — Gemini 3.5 Pro slips to July 17 for a full rebuild, introducing a 2M-token context and Deep ThinkDEEPTHINK — The 3.5 Pro rebuild targets better math reasoning, SVG scene generation, and image quality
Articles/Advanced
Advanced/2026-07-12Advanced

A minimal evolutionary search loop with Gemini: propose, evaluate, select — prompted by AlphaEvolve's GA

With AlphaEvolve reaching GA, I built the smallest possible evolutionary search loop on the Gemini API: generate candidates, score them with a fitness function, and select the best. Sandboxed evaluation, diversity, and budget control — from real solo-dev use.

AlphaEvolveevolutionary searchGemini API180code optimizationfitness function

Premium Article

I was rewriting one more number in a spreadsheet of weights. They were the coefficients of a tiny scoring function that decides which Google Play reviews I should reply to first — star rating, body length, whether a crash-related word appears, days since posting. I tuned the four weights by hand until the ranking matched my gut. The more I aligned one case, the more another slid out of place. That night I poured half a day into the back-and-forth.

The same week, I read that AlphaEvolve had reached general availability in Gemini Enterprise. The model searches for candidate solutions on the server side, executes code in a safely isolated client environment to score them, and repeats — inching toward an optimum. My hands stopped mid-edit. What I had just been doing by hand was exactly this: the manual version of propose, evaluate, and select.

This article is the record of turning that realization into a tool for solo development. Rather than reproducing AlphaEvolve itself, I extract only its core and build the smallest evolutionary search loop that runs on the Gemini API. I'll leave the working code and the traps I actually stepped in.

What AlphaEvolve really demonstrates is automating the search itself

The heart of AlphaEvolve is not asking the model to write "the answer" once. It is running a loop: have the model produce candidate answers, score them mechanically, then use the good ones as seeds for the next batch. In the vocabulary of evolutionary computation, it has all four pieces — individuals (candidates), fitness (scores), selection, and mutation (next-generation creation).

If I strip it down to what a solo developer can reuse, the transferable core maps out like this.

Evolutionary elementIts counterpart in this loopWho handles it
IndividualA Python code string for the scoring functionGenerated by Gemini
FitnessRanking agreement on my data (Kendall's τ)My own evaluator
SelectionKeep the top kMy own loop
Mutation / crossoverShow the elites, ask for improved variantsGenerated by Gemini

Obviously I can't hold the large-scale distributed search or the Google-managed isolated runtime that the Enterprise AlphaEvolve provides. But the skeleton — propose, evaluate, select — is something one person can assemble in an evening. And for small optimization problems (coefficient tuning, discovering a heuristic, exploring prompt structure), that skeleton alone proved to be enough.

Where hand-tuning quietly ran out of road

Turning weights by hand has three silent limits.

First, the search space is exponential. Even linear weights over four features form an infinite space of continuous values, and once you reach for nonlinear terms — logs, thresholds, products — you quickly leave what intuition can track.

Second, evaluation stays vague. If you keep nudging on "it feels a little better," you overfit to the handful of cases you happened to be looking at. Without a number, you can't tell when you've regressed.

Third, no tacit knowledge survives. Only the final coefficients remain in the code, and why those values fade even from my own memory. Touch it six months later and the reasons are gone.

Evolutionary search inverts all three. The machine does the searching, the function turns evaluation into a number, and good candidates persist as code. All the human decides is what counts as good — the definition of fitness.

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
A restricted-exec sandbox for safely evaluating model-written code (blocked builtins, timeouts, isolated exceptions)
Why LLM-guided mutation beats random mutation per generation, and how to fight premature convergence
A token budget and generation cap per run, plus when to prefer hand-tuning or DSPy instead
Secure payment via Stripe · Cancel anytime

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Gemini Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • Copy-paste ready implementation code
  • New advanced guides published daily
  • $5/mo or $10 for lifetime access
View Membership →

Related Articles

Advanced2026-07-10
The Day We Went From 30 Categories to 34 — Reclassifying 1,180 Assets Instead of 8,142
Adding categories to a taxonomy does not require reclassifying everything. Here is how embeddings and confidence margins narrowed a backfill from 8,142 assets to 1,180, with the numbers.
Advanced2026-07-10
Images Made With a Retiring Model Can Never Be Made Again — Tracking Regenerability in a Ledger
When Gemini's image generation models shut down on August 17, the assets you made with them can no longer be reproduced the same way. Here is the ledger design and code I use to decide, before the deadline, which assets are regenerable and which must be frozen.
Advanced2026-07-08
When Your Knowledge Base Shifts Mid-Run: Pinning File Search to an Execution Epoch for Consistent Agent Grounding
When a File Search store is updated while a Managed Agent is running, a single execution can mix old and new grounding. Borrowing MVCC ideas, pinning an execution epoch keeps one agent run's evidence consistent. Here is the design and implementation.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →