superred-optimizer-gepa-agentic
An agent-target variant of GEPA reflective prompt evolution for the superred red-teaming framework.
This keeps GEPA's core reflective-mutation loop — one evolving textual
candidate, refined between runs by a reflection LM call on the best-scoring
rollout so far — but adds an agentic delivery policy on top: at
initialize() it inspects the in-scope controllables, classifies which ones
look like agent content surfaces (tool returns, retrieved context, memory
records, web/document content — AgentDojo-style read__..., inspect-agent
tool:<name>, skill aliases, and generic memory/RAG/web hints all count as
weak signals), builds a deterministic per-run injection plan across whichever
surfaces actually fire (capped per run), and falls back to the plain prompt
channel only when no content surface is available. Reflection also gets
richer scoped context than the base optimizer: which surfaces were selected
and observed, preserved tool returns, static observables, and a bounded slice
of the agent trace.
This is a separate package from superred-optimizer-gepa — the chatbot
GEPA implementation there is intentionally left unchanged; see its
ASSUMPTIONS.md for the base algorithm and
this package's ASSUMPTIONS.md for the agentic delivery
layer and what is deliberately deferred (full Pareto-frontier maintenance,
full tool catalog register/replace).
Reference: Agrawal et al., "GEPA: Reflective Prompt Evolution Can Outperform
Reinforcement Learning," arXiv:2507.19457
(ICLR 2026); official reference implementation
gepa-ai/gepa (MIT License).
Install
pip install superred-optimizer-gepa-agentic
Usage
from gepa_agentic_optimizer import GEPAAgenticOptimizer
optimizer = GEPAAgenticOptimizer(
max_attempts=20,
max_content_injections_per_run=3,
)
Wire it into a Controller against an agent target (e.g. agentdojo_target,
inspect_agent_target) — see the framework's
architecture overview for a full
Controller.run() example.
Behaviour notes
- Surface naming is a weak signal, not a contract. Detection also uses PostCall metadata, value type, and runtime content shape, so it degrades gracefully against agent targets that don't follow the AgentDojo/inspect-agent naming conventions.
- GEPA-style strict-improvement acceptance: a reflected candidate only
stays in the pool if it succeeded or scored strictly better than its
parent, closer to the paper's acceptance test than the base
gepapackage's single-instance collapse (still not a full replay-based acceptance test, since superred has no fixed minibatch to replay). tool_catalog_rewrite_docgives a minimal text-rewrite capability when a visible tool catalog identifies a content/read/search-like tool; full register/replace of tool definitions is a documented follow-up, not implemented, because it needs a stricter JSON contract than this optimizer currently assumes.
License
MIT for this port's code. The reflective meta-prompt text is its own copy of
the same template superred-optimizer-gepa reproduces (both packages copy it
independently rather than one importing the other's), verbatim from
gepa-ai/gepa (MIT License, Copyright (c) 2025 Lakshya A Agrawal and the GEPA
contributors) — see the attribution comment in
src/gepa_agentic_optimizer/prompts.py.
Metadata
Release files for superred-optimizer-gepa-agentic 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| superred_optimizer_gepa_agentic-0.1.0.tar.gz | 20.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| superred_optimizer_gepa_agentic-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 35.1 kB
Release files / superred_optimizer_gepa_agentic-0.1.0.tar.gz
| Download URL | superred_optimizer_gepa_agentic-0.1.0.tar.gz |
|---|---|
| Size | 20.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
407c246c63f7622562f1cac9401d8d8c91b84be4b9900373148317b740595efe
|
|
BLAKE2b-256 checksum How to use checksums |
3e6a0f66f9562d36a17d32e429df5fbd5769e35cd413095e035b3f2f037ca51c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 21, 2026.
Transparency logRelease files / superred_optimizer_gepa_agentic-0.1.0-py3-none-any.whl
| Download URL | superred_optimizer_gepa_agentic-0.1.0-py3-none-any.whl |
|---|---|
| Size | 15.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9f6e599b4f3c5410dcf2d6469119d2586f9db9f0e9b2c9f43c861e487517e5c8
|
|
BLAKE2b-256 checksum How to use checksums |
796e0d05a0570a651ac3da45aaf32a98ebfd04873f1bdf046073b6484d7cbcd0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 21, 2026.
Transparency log