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.0.tar.gz (137.5 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.0-py3-none-any.whl (159.8 kB view details)

Uploaded Python 3

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

Hashes for gepa_adk-0.3.0.tar.gz
Algorithm Hash digest
SHA256 ab2a2c7f6d644f6ba37050bf2621e39b356850b41aa2e1d8c973ab537f22787d
MD5 56f09e12edab3ca96b554826942f7398
BLAKE2b-256 0ec5afc157a961622908cb04b472254656379bb0f795e48488ba4f22331139e2

See more details on using hashes here.

Provenance

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

Hashes for gepa_adk-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8afff2e7ac7cc2e73a4e564daa9f5ad736122c91ded0925d73d83649699b3954
MD5 2815b6a36489632c37af852c9a7afa40
BLAKE2b-256 88e95ee3d9afb8f174d3deb2861f5db84426273a301b297ee41609d4b86cb181

See more details on using hashes here.

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

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