A prompt population can contain two useful candidates that fail in different ways. Crossover combines two parents into one child intended to retain what each gets right. For text artifacts, the merge is a semantic edit: a model receives both system prompts and is asked to keep their correct rules while removing overlap. section 4.2.4 section 4.6
Combine two revenue rules
Suppose one revenue prompt handles the refund rule correctly and another handles the quarter correctly. A crossover proposal merges their instructions so the child can satisfy both checks. That is a candidate, not a guaranteed improvement: the child still needs to be measured. section 4.2.4
In a population search round, crossover fits into the same select–vary–remember loop as mutation:
- Select the highest-scoring parents from the current population. section 4.2.4
- Vary the population with reflected mutations and a crossover of the top two parents. section 4.2.4
- Measure each proposed child, create an immutable artifact, and record its score and parent lineage in the archive. section 4.2.4
Listing 4.5 Population, crossover (03_revenue_gepa_loop.py)
# each population entry: (artifact, content, score, trajectory)
for r in range(rounds):
# SELECT: the top parents this round, by score
parents = sorted(population, key=lambda x: x[2],
reverse=True)[: max(2, pop // 2)]
# VARY: reflect-then-mutate each parent, cross the top two
jobs = [make_child(p) for p in parents]
if len(parents) >= 2:
jobs.append(make_cross())
proposed = await asyncio.gather(*jobs)
async def eval_child(parent_art, content):
score, _, traj = await measure_full(content)
child = parent_art.mutate(new_content=content, #A
created_by="gepa")
await archive.record( #B
Variant(artifact=child, parent=parent_art,
search_method="gepa"),
GapMeasurement(score=score),
)
return child, content, score, traj
new = [eval_child(pa, c) for pa, c in proposed]
population.extend(await asyncio.gather(*new))
# REMEMBER: keep the best few
population = sorted(population, key=lambda x: x[2],
reverse=True)[:pop]The loop makes crossover one proposed child among several variations; evaluation and archive recording follow proposal generation. section 4.2.4
Lineage makes the operation recognizable: mutation splits a branch, while crossover is an edge where two parent branches merge into one child. That record lets a reviewer distinguish a combined proposal from another rewrite of a single incumbent. section 4.4.3 section 4.6
Crossover does not prevent convergence. As a small population settles on the same near-best rules, crossing its survivors has less distinct material to combine. Differently worded children may also keep failing the same check; more merges alone cannot reveal a rule absent from the feedback. Keeping older branches available changes which candidates can be revisited, but carries an archive and search cost. section 4.2.4 section 4.4.3 section 4.3.1
Figure 4.7 The population fans out, then converges. Across several generations the population spreads as reflection and crossover explore, climbs, then narrows as every survivor settles on the same near-best idea. That convergence is the win and the wall at once, and it is why the climb flattens short of the top.

The population’s spread and later narrowing show both crossover’s opportunity to combine distinct candidates and its limit once survivors converge. section 4.2.4







