Optimize With Environments
Goal
Use GEPA to optimize system prompts in a controlled, reproducible loop.
Scope
Current GEPA path is for system prompt optimization. If user asks for unsupported optimization targets, stop and clarify before proceeding.
Endpoint And Model Selection Nudge
- Encourage users to define reusable aliases in
configs/endpoints.toml. - Ask whether optimization should be validated on instruct or reasoning models.
- Instruct go-tos:
gpt-4.1series,qwen3instruct series. - Reasoning go-tos:
gpt-5series,qwen3thinking series,glmseries. - For benchmark reporting, keep model family fixed between baseline and optimized comparisons unless the user requests a cross-family study.
- Endpoint entries support optional
headers(orextra_headers) for custom HTTP headers. GEPA inherits these from the registry for both the main model and the reflection model:
[[endpoint]]
endpoint_id = "my-proxy"
model = "gpt-4.1-mini"
url = "https://api.example/v1"
key = "OPENAI_API_KEY"
headers = { "X-Custom-Header" = "value" }
Core Workflow
- Verify baseline first with
prime eval run. Keep the default save behavior and do not add--skip-uploadunless the user explicitly requests that deviation:
prime eval run my-env -m openai/gpt-4.1-mini -n 50 -r 3 -s
- For v1 Taskset + Harness environments, confirm prompt-like fields are exposed in the saved state or task info before GEPA reflection; BYO Harness implementations may render richer trajectories than classic
MultiTurnEnvexamples. - Run GEPA:
prime gepa run my-env -m openai/gpt-4.1-mini -M openai/gpt-4.1-mini -B 500 -n 100 -N 50
- Keep v1 environment settings under
tasksetandharnessconfig sections:
[[env]]
id = "my-env"
[env.taskset]
split = "train"
[env.harness]
max_turns = 8
- Or run from config:
prime gepa run configs/gepa/qwen-3-5.toml
- Re-evaluate with optimized prompt and compare against baseline.
High-Value Settings
-B/--max-calls: total optimization budget.-n/--num-trainand-N/--num-val: train/validation split sizes.--minibatch-size: reflection granularity.--perfect-score: skip already-solved minibatches when max score is known.--state-columns: include environment-specific context in reflection data.
Output Artifacts
Expect and inspect:
system_prompt.txtpareto_frontier.jsonlmetadata.jsonLoad optimized prompts withvf.SystemMessage.from_path("/path/to/system_prompt.txt")so the saved prompt is used verbatim.
Quality Rules
- Do not optimize on top of broken reward logic.
- For weak deterministic checks, fix rubric quality before GEPA tuning.
- Keep model, sampling, and dataset conditions stable during baseline-vs-GEPA comparison.
- Report limitations directly when feature gaps block requested optimization.
Deliverable
Return:
- Baseline metrics.
- Optimized metrics.
- Prompt diff summary.
- Recommendation to adopt, iterate, or stop.
Source: PrimeIntellect-ai/verifiers — distributed by TomeVault.