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, and evolves the agent's instructions until performance improves.
Think of it as natural selection for AI prompts—the best instructions survive and improve.
Who is this for?
Teams building AI agents with Google's Agent Development Kit (ADK) who want to:
- Improve agent performance without manual prompt tweaking
- Use structured feedback (not just pass/fail) to guide improvements
- Evolve multiple agents working together
- Get 3-5x faster optimization through parallel evaluation
Installation
Prerequisites
Before installing gepa-adk, you need:
- Python 3.12+
- Ollama with the
gpt-oss:20bmodel:# Install Ollama (if not already installed) # Visit https://ollama.ai for installation instructions # Pull the required model ollama pull gpt-oss:20b
- Set environment variable:
export OLLAMA_API_BASE=http://localhost:11434
Why gpt-oss:20b? The evolutionary optimization engine uses this model internally to generate improved agent instructions. Without it, evolution will fail.
Why local models? Evolutionary optimization makes many LLM calls per run (evaluating multiple candidates across iterations). We recommend Ollama with open-source models to avoid API costs and rate limits. However, gepa-adk works with any Google ADK-supported model (including Gemini) - just be aware of potential costs.
Install gepa-adk
pip install gepa-adk
For development or if using uv:
uv add gepa-adk
Quick Start
from pydantic import BaseModel, Field
from google.adk.agents import LlmAgent
from gepa_adk import evolve_sync
class Output(BaseModel):
answer: str
score: float = Field(ge=0.0, le=1.0)
agent = LlmAgent(name="assistant", model="gemini-2.0-flash",
instruction="You are a helpful assistant.", output_schema=Output)
trainset = [{"input": "What is 2+2?", "expected": "4"}]
result = evolve_sync(agent, trainset)
print(f"Evolved: {result.evolved_instruction}")
Examples
Two complete working examples are available in the examples/ directory:
- basic_evolution.py — Simple greeting agent evolution with critic scoring
- critic_agent.py — Story generation with dedicated critic agent for evaluation
Both examples require Ollama with gpt-oss:20b model (see Prerequisites above).
Run an example:
python examples/basic_evolution.py
Documentation
- Getting Started Guide — Step-by-step walkthrough from installation to first evolution
- Use Case Guides — Patterns for single-agent, critic agents, multi-agent, and workflows
- API Reference — Complete documentation for all public functions and classes
Troubleshooting
"Model not found" or "Connection refused" errors
Ensure Ollama is running and the model is pulled:
# Check Ollama is running
curl http://localhost:11434/api/tags
# Pull the model if not present
ollama pull gpt-oss:20b
# Verify the model is available
ollama list | grep gpt-oss
Evolution is slow or uses too many iterations
Adjust the EvolutionConfig parameters:
from gepa_adk import EvolutionConfig
config = EvolutionConfig(
max_iterations=3, # Reduce iterations
patience=2, # Stop early if no improvement
)
result = evolve_sync(agent, trainset, config=config)
Want to use a different model?
For your agents: You can use any model supported by Google ADK (Gemini, Ollama models, etc.). The examples use ollama_chat/gpt-oss:20b but you can change this to gemini-2.0-flash or other ADK-supported models.
For the evolution engine: Currently, the reflection model is hardcoded to ollama_chat/gpt-oss:20b. Future versions will support custom model configuration. For now, ensure this model is available in your Ollama instance.
Cost warning: Using cloud APIs like Gemini for agents during evolution can result in high costs due to the many evaluation calls required.
Status
In Development — Not yet ready for production use.
See docs/proposals/ for technical design and roadmap.
Credits
This project 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.1.1.tar.gz.
File metadata
- Download URL: gepa_adk-0.1.1.tar.gz
- Upload date:
- Size: 96.3 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 |
5f323fceef20ed88e42a3cab3b995aa75a9514536f5d155a94e2765665794ae7
|
|
| MD5 |
7bb883b3c2991d5698a01043d6f37096
|
|
| BLAKE2b-256 |
41410b71a675bcc3d770c30a0861c819122612767e64a8fa8bd59d19e6e6f2a7
|
Provenance
The following attestation bundles were made for gepa_adk-0.1.1.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.1.1.tar.gz -
Subject digest:
5f323fceef20ed88e42a3cab3b995aa75a9514536f5d155a94e2765665794ae7 - Sigstore transparency entry: 833312683
- Sigstore integration time:
-
Permalink:
Alberto-Codes/gepa-adk@fd1a17b87fd29f14c2e5c09daa52339acd8929d3 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/Alberto-Codes
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@fd1a17b87fd29f14c2e5c09daa52339acd8929d3 -
Trigger Event:
release
-
Statement type:
File details
Details for the file gepa_adk-0.1.1-py3-none-any.whl.
File metadata
- Download URL: gepa_adk-0.1.1-py3-none-any.whl
- Upload date:
- Size: 111.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 |
86b817180dbd9d4d3f4cfeac60fe2ba4c64ede56486ae30aac7d04aa25920bb9
|
|
| MD5 |
203e3742bc89125f82ae2457b2f5cea2
|
|
| BLAKE2b-256 |
21f21c8878ecd0777f0fafc53ee8b995ae8a98be16f39916d891d8a2046b9953
|
Provenance
The following attestation bundles were made for gepa_adk-0.1.1-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.1.1-py3-none-any.whl -
Subject digest:
86b817180dbd9d4d3f4cfeac60fe2ba4c64ede56486ae30aac7d04aa25920bb9 - Sigstore transparency entry: 833312681
- Sigstore integration time:
-
Permalink:
Alberto-Codes/gepa-adk@fd1a17b87fd29f14c2e5c09daa52339acd8929d3 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/Alberto-Codes
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@fd1a17b87fd29f14c2e5c09daa52339acd8929d3 -
Trigger Event:
release
-
Statement type: