Skip to main content

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:

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gepa_adk-0.3.1.tar.gz (147.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gepa_adk-0.3.1-py3-none-any.whl (175.2 kB view details)

Uploaded Python 3

File details

Details for the file gepa_adk-0.3.1.tar.gz.

File metadata

  • Download URL: gepa_adk-0.3.1.tar.gz
  • Upload date:
  • Size: 147.8 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

Hashes for gepa_adk-0.3.1.tar.gz
Algorithm Hash digest
SHA256 f2df0fc80f73ae08dc1bf2a92fe24a6efac5f9c4c031df74c33c442583bf4fd7
MD5 da9c64cca15b49f41de570ff31037fb9
BLAKE2b-256 54f4b58f29777ffd381f789b6044e890eaa349aa3dce21fc322861e72034fcd4

See more details on using hashes here.

Provenance

The following attestation bundles were made for gepa_adk-0.3.1.tar.gz:

Publisher: publish.yml on Alberto-Codes/gepa-adk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gepa_adk-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: gepa_adk-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 175.2 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

Hashes for gepa_adk-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d62313befbde6f3b0ad5bcd67f3efdf7b8a6575d48b7c496073ce87642393961
MD5 f278e806f776603848c7dcb667cc5b7c
BLAKE2b-256 17c9c18625f82827738b59def3807407237bd231428ba66558bc497ce94970a5

See more details on using hashes here.

Provenance

The following attestation bundles were made for gepa_adk-0.3.1-py3-none-any.whl:

Publisher: publish.yml on Alberto-Codes/gepa-adk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page