Evolutionary optimization for Google ADK agents
Project description
gepa-adk
Evolutionary optimization for Google ADK agents.
What is this?
gepa-adk makes your AI agents better automatically. It takes an agent, runs it against examples, gets feedback from a critic, and evolves the agent's instructions until performance improves.
Think of it as natural selection for AI prompts—the best instructions survive and improve.
Installation
pip install gepa-adk
Requirements: Python 3.12+, a Gemini API key (or other ADK-supported model)
export GOOGLE_API_KEY=your-api-key
Quick Start
The simplest way to evolve an agent: provide a critic to score outputs.
import asyncio
from google.adk.agents import LlmAgent
from pydantic import BaseModel, Field
from gepa_adk import evolve, CriticOutput
# Your agent to evolve
agent = LlmAgent(
name="assistant",
model="gemini-2.0-flash",
instruction="You are a helpful assistant.",
)
# A critic that scores the agent's output (0.0-1.0)
critic = LlmAgent(
name="critic",
model="gemini-2.0-flash",
instruction="Score the response for helpfulness and accuracy.",
output_schema=CriticOutput, # Has score: float and feedback: str
)
# Training examples
trainset = [
{"input": "What is 2+2?"},
{"input": "Explain photosynthesis briefly."},
]
# Evolve!
result = asyncio.run(evolve(agent, trainset, critic=critic))
print(f"Score: {result.original_score:.2f} -> {result.final_score:.2f}")
print(f"Evolved instruction:\n{result.evolved_instruction}")
That's it. The critic provides feedback, a reflection agent proposes improvements, and evolution finds better instructions.
Key Concepts
- Agent: The ADK agent whose instruction you want to improve
- Critic: Scores the agent's output (0.0-1.0) and provides feedback
- Trainset: Examples to evaluate against
- Evolution: Iterative improvement using reflection and selection
Examples
See examples/ for complete working code:
- basic_evolution.py — Single agent with critic scoring
- critic_agent.py — Custom critic for story generation
- multi_agent.py — Evolving multiple agents together
Configuration
from gepa_adk import evolve, EvolutionConfig
config = EvolutionConfig(
max_iterations=5, # Maximum evolution iterations
patience=2, # Stop early if no improvement
)
result = await evolve(agent, trainset, critic=critic, config=config)
Documentation
Status
In Development — API may change.
Credits
Implements concepts from GEPA (Genetic-Pareto optimization) and integrates with Google ADK.
License
Apache License 2.0 - see LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gepa_adk-0.3.0.tar.gz.
File metadata
- Download URL: gepa_adk-0.3.0.tar.gz
- Upload date:
- Size: 137.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ab2a2c7f6d644f6ba37050bf2621e39b356850b41aa2e1d8c973ab537f22787d
|
|
| MD5 |
56f09e12edab3ca96b554826942f7398
|
|
| BLAKE2b-256 |
0ec5afc157a961622908cb04b472254656379bb0f795e48488ba4f22331139e2
|
Provenance
The following attestation bundles were made for gepa_adk-0.3.0.tar.gz:
Publisher:
publish.yml on Alberto-Codes/gepa-adk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gepa_adk-0.3.0.tar.gz -
Subject digest:
ab2a2c7f6d644f6ba37050bf2621e39b356850b41aa2e1d8c973ab537f22787d - Sigstore transparency entry: 844214466
- Sigstore integration time:
-
Permalink:
Alberto-Codes/gepa-adk@5fb443a52c8b49441f4fcf710698b60951d80906 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/Alberto-Codes
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5fb443a52c8b49441f4fcf710698b60951d80906 -
Trigger Event:
release
-
Statement type:
File details
Details for the file gepa_adk-0.3.0-py3-none-any.whl.
File metadata
- Download URL: gepa_adk-0.3.0-py3-none-any.whl
- Upload date:
- Size: 159.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8afff2e7ac7cc2e73a4e564daa9f5ad736122c91ded0925d73d83649699b3954
|
|
| MD5 |
2815b6a36489632c37af852c9a7afa40
|
|
| BLAKE2b-256 |
88e95ee3d9afb8f174d3deb2861f5db84426273a301b297ee41609d4b86cb181
|
Provenance
The following attestation bundles were made for gepa_adk-0.3.0-py3-none-any.whl:
Publisher:
publish.yml on Alberto-Codes/gepa-adk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gepa_adk-0.3.0-py3-none-any.whl -
Subject digest:
8afff2e7ac7cc2e73a4e564daa9f5ad736122c91ded0925d73d83649699b3954 - Sigstore transparency entry: 844214469
- Sigstore integration time:
-
Permalink:
Alberto-Codes/gepa-adk@5fb443a52c8b49441f4fcf710698b60951d80906 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/Alberto-Codes
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5fb443a52c8b49441f4fcf710698b60951d80906 -
Trigger Event:
release
-
Statement type: