Evolutionary optimization for Google ADK agents
Project description
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"])
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
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-2.0.0.tar.gz.
File metadata
- Download URL: gepa_adk-2.0.0.tar.gz
- Upload date:
- Size: 177.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b78f09993e2d7b2601b952881b4fdc21d6234c3c3dea0cb0fe5ce0a268287a4
|
|
| MD5 |
9de742a168a8f8232019d1834847144a
|
|
| BLAKE2b-256 |
a4b159bdb641615de93aee180ec2b16588affa24efa49512f02a7066e2740110
|
File details
Details for the file gepa_adk-2.0.0-py3-none-any.whl.
File metadata
- Download URL: gepa_adk-2.0.0-py3-none-any.whl
- Upload date:
- Size: 213.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fe13d2d62e0b857bc143479f731cf599ba8102410744d3fec78c3ea43f095790
|
|
| MD5 |
0fb9b5d23f7ad6883725d53ec2bfd278
|
|
| BLAKE2b-256 |
357a1b7e17d0749a52d1848725dd0c38067a1c78923b0d6f0c0e61aae76f6608
|