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.5-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.5-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.2.tar.gz (153.6 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.2-py3-none-any.whl (181.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: gepa_adk-0.3.2.tar.gz
  • Upload date:
  • Size: 153.6 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.2.tar.gz
Algorithm Hash digest
SHA256 3228bb4c9c3d7477d121ba2198130401a94ab6235395ae88785be5819917baa0
MD5 1cbc9e40b5e609fe845df2fe9d7aae49
BLAKE2b-256 d5b9c1d0314e07019fd014bbef720942a67e701929b13d9d79a6ef826b8af456

See more details on using hashes here.

Provenance

The following attestation bundles were made for gepa_adk-0.3.2.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.2-py3-none-any.whl.

File metadata

  • Download URL: gepa_adk-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 181.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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7e7c55a29ce0338fa6c0fafc9c4b493615a5df05190a9a54d918ba3aa1629709
MD5 c744970aed5733e36c89a921c4844b29
BLAKE2b-256 437cb65d7f1abf41fe4439bb623553e5f171782ff78a15653cbd04606673d2c5

See more details on using hashes here.

Provenance

The following attestation bundles were made for gepa_adk-0.3.2-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