Nov 19, 2026
Let Your Agent Optimize Prompts and Code With GEPA
GEPA is an MIT-licensed optimizer that reads full execution traces instead of collapsing them into one reward, evolves prompts, code, and agent architectures with 100–500 evaluations, and ships as an agent skill your coding agent can drive.
Tuning a prompt by hand means guess, rerun, and squint at outputs. GEPA — short for Genetic-Pareto — turns that loop into a search: it uses LLMs to read full execution traces (error messages, profiling data, reasoning logs), diagnose why a candidate failed, and propose targeted fixes instead of collapsing everything into a single scalar reward.
Why This Skill Matters
The README frames the difference as a cost and speed claim: GEPA needs about 100–500 evaluations where GRPO-style RL needs 5,000–25,000 or more — the README's table calls that "35x faster than RL". Its key results include open-source models plus GEPA beating Claude Opus 4.1 at 90x lower cost (the Databricks write-up), an agent's ARC-AGI accuracy going from 32% to 89% through architecture discovery, and a coding agent's resolve rate on Jinja going from 55% to 82% via auto-learned skills. The README counts 50+ production uses across Shopify, Databricks, Dropbox, OpenAI, Pydantic, MLflow, Comet ML, and more.
Beyond prompts, the same engine optimizes any text parameter you can score. The README's own list: prompts, code, agent architectures, scheduling policies, vector graphics, and more — "If you can measure it, you can optimize it."
The 7k-star repo also ships as an agent skill, gepa-optimize-anything, so your coding agent can drive the optimizer for you.
Installation
GEPA is a Python library first:
pip install gepa
To use it as an agent skill, the README documents two paths. In a clone of the repo, agents that read .claude/skills/ (Claude Code, Cursor, VS Code/Copilot, Codex, Gemini CLI) auto-discover it at .claude/skills/gepa-optimize-anything/. To use it in any other project, install the plugin from the repo's marketplace:
/plugin marketplace add gepa-ai/gepa
/plugin install gepa-optimize-anything@gepa
Real Workflow: Optimize a System Prompt on a Benchmark
The README's quick start optimizes a system prompt for math problems from the AIME benchmark in a few lines:
import gepa
trainset, valset, _ = gepa.examples.aime.init_dataset()
seed_prompt = {
"system_prompt": "You are a helpful assistant. Answer the question. "
"Put your final answer in the format '### <answer>'"
}
result = gepa.optimize(
seed_candidate=seed_prompt,
trainset=trainset,
valset=valset,
task_lm="openai/gpt-4.1-mini",
max_metric_calls=150,
reflection_lm="openai/gpt-5",
)
print("Optimized prompt:", result.best_candidate['system_prompt'])
The README reports the result: GPT-4.1 Mini goes from 46.6% to 56.6% on AIME 2025 (+10 percentage points). The two model roles matter — the task LM runs your candidates, and the reflection LM reads the traces to propose the next candidate.
Real Workflow: Let the Agent Drive optimize_anything
For artifacts beyond prompts, the optimize_anything API takes any text artifact plus an evaluator you write; the system handles the search:
import gepa.optimize_anything as oa
from gepa.optimize_anything import optimize_anything, GEPAConfig, EngineConfig
def evaluate(candidate: str) -> float:
result = run_my_system(candidate)
oa.log(f"Output: {result.output}") # Actionable Side Information
oa.log(f"Error: {result.error}") # feeds back into reflection
return result.score
result = optimize_anything(
seed_candidate="<your initial artifact>",
evaluator=evaluate,
objective="Describe what you want to optimize for.",
config=GEPAConfig(engine=EngineConfig(max_metric_calls=100)),
)
With the skill installed, your agent can drive this for you: describe the artifact and the objective in your agent session, and the skill assembles the run. oa.log calls feed "Actionable Side Information" — output and errors — back into reflection, so the optimizer sees why a candidate failed, not just its score.
Tips
- For AI pipelines, the README calls DSPy integration the most powerful path: GEPA is available there as
dspy.GEPA, with executable notebooks in DSPy's tutorials. - Pick the adapter that matches your task. The README's adapter table includes DefaultAdapter for single-turn system prompts, an MCP Adapter that optimizes tool descriptions and system prompts, a Generic RAG adapter, and a DSPy Full Program adapter that evolves entire programs (67% to 93% on MATH).
- Mind your Python version: the core package supports 3.15 on
main, but the README says to use Python 3.10–3.14 for thegepa[full]andgepa[confidence]extras until their dependencies catch up. - Budget the search:
max_metric_callsbounds how many evaluations a run spends, as the 150-call quick start and the 100-calloptimize_anythingexample show.
When Not to Use This
- You need a measurable score. The README's framing is "If you can measure it, you can optimize it" — with
optimize_anything, you provide the evaluator and the system handles the search, so there is nothing to optimize against until you can score candidates automatically. - Runs spend real API evaluations. The quick start allots 150 metric calls and the
optimize_anythingexample 100, on top of the task and reflection model calls each candidate needs. - If your task is a single prompt with no training examples or metric, hand tuning stays simpler than wiring up a dataset and an evaluator for a search loop.
See the leaderboard for more skills.