Skip to main content

GEPA reflective prompt evolution optimizer for superred agent targets

Project description

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 gepa package's single-instance collapse (still not a full replay-based acceptance test, since superred has no fixed minibatch to replay).
  • tool_catalog_rewrite_doc gives 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.

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

superred_optimizer_gepa_agentic-0.1.0.tar.gz (20.0 kB view details)

Uploaded Source

Built Distribution

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

superred_optimizer_gepa_agentic-0.1.0-py3-none-any.whl (15.1 kB view details)

Uploaded Python 3

File details

Details for the file superred_optimizer_gepa_agentic-0.1.0.tar.gz.

File metadata

File hashes

Hashes for superred_optimizer_gepa_agentic-0.1.0.tar.gz
Algorithm Hash digest
SHA256 407c246c63f7622562f1cac9401d8d8c91b84be4b9900373148317b740595efe
MD5 10a2d6ac06d92cb92ba02e37750c6e41
BLAKE2b-256 3e6a0f66f9562d36a17d32e429df5fbd5769e35cd413095e035b3f2f037ca51c

See more details on using hashes here.

Provenance

The following attestation bundles were made for superred_optimizer_gepa_agentic-0.1.0.tar.gz:

Publisher: release.yml on RoldSI/superred-modules

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

File details

Details for the file superred_optimizer_gepa_agentic-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for superred_optimizer_gepa_agentic-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9f6e599b4f3c5410dcf2d6469119d2586f9db9f0e9b2c9f43c861e487517e5c8
MD5 81a4a3e5723824f64f7609ab69ed668b
BLAKE2b-256 796e0d05a0570a651ac3da45aaf32a98ebfd04873f1bdf046073b6484d7cbcd0

See more details on using hashes here.

Provenance

The following attestation bundles were made for superred_optimizer_gepa_agentic-0.1.0-py3-none-any.whl:

Publisher: release.yml on RoldSI/superred-modules

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