darwinian-evolver

Evolve prompts, regex, SQL, and code snippets using an LLM-driven evolutionary search loop.

Updated Jun 5, 2026
One-click install
npx skills add https://github.com/xu1713/openhorse --skill darwinian-evolver-xu1713
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: darwinian-evolver
Source: https://github.com/xu1713/openhorse/tree/main/openhorse/openhorse/optional-skills/research/darwinian-evolver
Command: npx skills add https://github.com/xu1713/openhorse --skill darwinian-evolver-xu1713

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires openai, jinja2, darwinian_evolver, and includes scripts (resource) components.

What problem does it solve? Manually iterating on prompts, regex patterns, SQL queries, or code snippets to improve their performance is slow and unsystematic. This Skill automates that search by running Imbue's darwinian_evolver loop, which mutates candidates with an LLM, scores them against a fitness function, and selects the best performers over multiple iterations. ## Core Features & Use Cases - LLM-Driven Evolution Loop: Define an Organism (the artifact), an Evaluator (fitness scorer with trainable and holdout failure cases), and a Mutator (LLM-based improver), then let the loop optimize the artifact automatically. - OpenRouter Driver: Ships a parrot example driver that routes LLM calls through OpenRouter, so any provider model works without an Anthropic API key. - Snapshot Inspection: Includes a script to unpickle population snapshots and rank evolved organisms by score, plus a lineage visualizer from the upstream repo. - Use Case: You have a prompt template that only scores 0.0 on exact-match parroting tasks. Run the evolution loop for a few iterations and get back ranked prompt variants scoring 0.6-0.8, with holdout cases guarding against overfitting. ## Quick Start Ask the agent to install the darwinian_evolver repo, then run the OpenRouter parrot example with your OPENROUTER_API_KEY to evolve a prompt template over three iterations.

Frequently Asked Questions about darwinian-evolver

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I optimize a prompt with an evolutionary algorithm?

Define an Organism holding your prompt template, an Evaluator that scores outputs against expected results, and an LLM-based Mutator that proposes fixes from failure cases. Then run the EvolveProblemLoop for several iterations and inspect the ranked population snapshots.

How do I run darwinian_evolver without an Anthropic API key?

The upstream CLI is hardcoded to Anthropic, but the skill ships a parrot_openrouter.py driver that routes LLM calls through OpenRouter using the OpenAI SDK. Set OPENROUTER_API_KEY and EVOLVER_MODEL to use any provider model.

Can I use darwinian_evolver to evolve regex or SQL queries?

Yes, the Organism can hold any artifact string such as a regex_pattern or sql_query, as long as you implement a run method and an Evaluator that scores its behavior. The custom problem template shows the three required pieces: Organism, Evaluator, and Mutator.

When should I not use evolutionary prompt optimization?

Avoid it when the optimization target is differentiable (use gradient descent or DSPy instead), when you only need two or three hand-written variants, or when the fitness signal is purely subjective with no measurable criterion.

Why does my evolution run fail with HTTP 400 errors?

Azure-backed OpenRouter models reject prompts containing phrases like 'ignore previous instructions' due to content filters. Wrap the LLM call in try/except and return an error marker string so the evolver scores that organism zero and continues.

How do I read darwinian_evolver snapshot pickle files?

Snapshots are nested pickles containing a dict with a population_snapshot key, and the Organism class must be importable under its original dotted path. Use the shipped show_snapshot.py script to rank organisms by score and print their artifact fields.