gepa-adk
Evolutionary optimization for Google ADK agents.
What is this?
gepa-adk evolves AI agent instructions automatically. Give it an agent and training examples, and it finds better prompts through iterative improvement using genetic algorithms and Pareto frontier selection.
Supports single-agent evolution, multi-agent co-evolution, workflow optimization (Sequential, Loop, Parallel agents), output schema evolution, generation config tuning, and multimodal inputs including video.
Requirements
- Python 3.12+
- Ollama with a local model (recommended for development), or any model supported by LiteLLM
Installation
pip install gepa-adk
# For local models (recommended)
export OLLAMA_API_BASE=http://localhost:11434
Quick Start
Evolve a greeting agent to produce formal, Dickens-style greetings:
from google.adk.agents import LlmAgent
from google.adk.models.lite_llm import LiteLlm
from gepa_adk import evolve, run_sync, EvolutionConfig, SimpleCriticOutput
model = LiteLlm(model="ollama_chat/llama3.2:latest")
agent = LlmAgent(
name="greeter",
model=model,
instruction="Greet the user appropriately.",
)
critic = LlmAgent(
name="critic",
model=model,
instruction="Score for formal, Dickens-style greetings. 0.0-1.0.",
output_schema=SimpleCriticOutput,
)
trainset = [
{"input": "I am His Majesty, the King."},
{"input": "I am your mother."},
{"input": "I am a close friend."},
]
config = EvolutionConfig(
max_iterations=5,
patience=1,
reflection_model="ollama_chat/llama3.2:latest",
)
result = run_sync(evolve(agent, trainset, critic=critic, config=config))
print(f"Score: {result.original_score:.2f} -> {result.final_score:.2f}")
print(result.evolved_components["instruction"])
When you have labelled examples, score with plain code instead of a critic
agent. LabelAgreementScorer scores 1.0 when the output (or one JSON field
of it) equals the row's expected label after stripping whitespace, else
0.0. Any object with score and async_score methods (the
Scorer protocol, from gepa_adk import Scorer) also works as scorer=. critic= and
scorer= are mutually exclusive:
from gepa_adk import LabelAgreementScorer
trainset = [{"input": "I am your mother.", "expected": "Dearest Mother, how fare you?"}]
# For JSON output, LabelAgreementScorer(field="label") compares that one field
# instead of the whole output.
result = run_sync(evolve(agent, trainset, scorer=LabelAgreementScorer(), config=config))
Examples
Getting started:
- basic_evolution.py — Single agent with critic
- critic_agent.py — Story generation with dedicated critic
- custom_reflection_prompt.py — Custom reflection prompts
Multi-agent & workflows:
- multi_agent.py — Multi-agent co-evolution
- loop_agent_evolution.py — LoopAgent workflow evolution
- parallel_agent_evolution.py — ParallelAgent workflow evolution
- nested_workflow_evolution.py — Nested workflow evolution
Advanced:
- schema_evolution_example.py — Output schema evolution
- config_evolution_demo.py — Generation config evolution
- video_transcription_evolution.py — Video input evolution
- app_runner_integration.py — ADK App/Runner integration
Documentation
Getting Started · Guides · API Reference
Credits
Based on GEPA (source). Built on Google ADK (source).
License
Release files for gepa-adk 2.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| gepa_adk-2.6.0.tar.gz | 244.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gepa_adk-2.6.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 527.7 kB
Release files / gepa_adk-2.6.0.tar.gz
| Download URL | gepa_adk-2.6.0.tar.gz |
|---|---|
| Size | 244.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2e1dbddeac20b64484b21ee2012cb09b23447fe55909fe12b1cda26134d611cc
|
|
BLAKE2b-256 checksum How to use checksums |
099c720a8b597102b0a7088cbcf735a146770a9e53f62c1289cd71bc3b1fa42f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / gepa_adk-2.6.0-py3-none-any.whl
| Download URL | gepa_adk-2.6.0-py3-none-any.whl |
|---|---|
| Size | 283.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ebb72a584b3b0ade5588f2422be0868ff798b4d8a6064ae0ddbe07db917ea77c
|
|
BLAKE2b-256 checksum How to use checksums |
3d7edbe59c26f3346dc97acb583d3c08142284152b742269c9399866e3977e5d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|