The Research Report
When Red Teamers Turn Prompt Engineers: SpecterOps Applies GEPA to Security Agent Prompts
How the company behind BloodHound is bringing measurable, adversarial rigor to the messiest problem in AI security — and why it matters for every production agent deployment.
On June 9, 2026, SpecterOps — the offensive security firm best known for BloodHound and Active Directory attack-path analysis — published something unusual: a 28-minute deep dive into prompt engineering. Not the "here are five tips for ChatGPT" variety. This was a rigorous, measurable application of GEPA (Genetic-Pareto prompt evolution) to the prompts that drive security agents — the AI systems that simulate attackers, analyze credentials, and traverse Active Directory graphs.
The significance isn't just that a red-team company is optimizing prompts. It's how they're doing it: combining evolutionary prompt optimization with adversarial evaluation, producing prompts that are measurably better and measurably harder to subvert. In a field where the difference between a correct and incorrect agent action can be the difference between catching an attacker and missing one, this approach represents a genuine methodological advance.
The Problem: Security Prompts Are High-Stakes, Low-Rigor
If you've built AI agents for any length of time, you know the prompt problem. Your system prompt is the most important piece of your agent architecture, and also the least engineered. You write it, test it against a few examples, ship it, and then spend the next month debugging edge cases that the prompt didn't anticipate.
In security, this problem is magnified. A security agent — say, one that analyzes BloodHound's attack-path data to prioritize remediation — operates in an adversarial environment by definition. The domain is complex (Active Directory, Kerberos, ACLs, group policy). The inputs are messy (real attack graphs, noisy telemetry). The consequences of failure are severe: missed attack paths, false confidence in security posture, or worse — an agent that can be prompted into revealing sensitive findings.
SpecterOps has been building AI into their tools since at least early 2026. Their Nemesis 2.2 release in February introduced AI-powered evidence extraction and analysis. Their Ghostwriter v7 release on June 4 added scoped API tokens and automation features. And their AI Cyber Ranges — standardized environments for validating model performance — signal that they take measurement seriously.
But here's the uncomfortable truth: even with all this infrastructure, most teams still tune prompts by hand. The SpecterOps post acknowledges this directly. Prompt engineering for security agents has been artisanal work — expert-driven, qualitative, and difficult to reproduce. GEPA offers a way to make it systematic.
What GEPA Actually Does
GEPA — short for Genetic-Pareto prompt evolution — emerged from research by Lakshya Agrawal and colleagues, presented as an oral paper at ICLR 2026. The core idea is deceptively simple: instead of optimizing prompts by tweaking them manually or running reinforcement learning with scalar reward signals, GEPA uses an LLM to reflect on execution traces and propose targeted improvements.
Here's what that means in practice. When a prompt produces a bad output, traditional optimizers know only that the output scored 0.4 out of 1.0. GEPA knows why. It reads the full execution trace — the prompt sent, the model's reasoning steps, tool calls and their outputs, the final answer, and the evaluator's explanation of what went wrong. A strong "reflection" LLM then diagnoses the failure mode and proposes a specific fix.
This is the Actionable Side Information (ASI) concept at the heart of GEPA. ASI can be error messages, reasoning traces, profiling data, constraint violations — any text that helps diagnose why a candidate failed. Instead of brute-forcing through the search space, the optimizer accumulates lessons across generations, with each mutation inheriting diagnostic context from all its ancestors.
The "Pareto" in Genetic-Pareto refers to how GEPA manages its population of candidates. Rather than keeping only the single best prompt, GEPA maintains a Pareto frontier — a set of prompts where each one is the best on at least some subset of evaluation examples. This preserves diversity and enables a "system-aware merge" operation that combines the strengths of two candidates excelling on different problem types.
The results are striking. GEPA outperforms MIPROv2 (the previous best DSPy optimizer) by 13% aggregate across benchmarks and outperforms GRPO (a leading RL method) by 20% on the best task — all while using 35× fewer model rollouts. On AIME 2025, it pushed GPT-4.1 Mini from 46.6% to 56.6% accuracy with a simple optimization run.
Why This Matters for Security Agents
You might ask: why is a prompt optimizer particularly relevant for security agents? Can't you just use GEPA for any task?
You can, and people do — Shopify, Databricks, and Dropbox have all adopted GEPA in production. Databricks achieved 90× cost reduction by optimizing enterprise agents with GEPA, using open-source models that outperform Claude Opus 4.1 and GPT-5 at a fraction of the cost. Dropbox used GEPA to optimize their Dash search relevance judge, cutting malformed JSON output from 40% to under 3% on small models. Google integrated GEPA directly into their Agent Development Kit and Gemini Enterprise Agent Platform as the official agent optimization engine.
But security agents occupy a uniquely demanding position in the prompt optimization landscape, and SpecterOps' application highlights three reasons why.
First: Adversarial Evaluation as a First-Class Concern
Most prompt optimization work evaluates on accuracy benchmarks — MATH, AIME, HotpotQA. Security agents need accuracy and robustness. A security agent prompt that scores well on benign inputs but collapses under adversarial manipulation is worse than useless — it's dangerous.
SpecterOps' approach layers adversarial evaluation directly into the GEPA optimization loop. Instead of just measuring whether the agent produces correct outputs, they evaluate whether the agent can be tricked into producing incorrect or harmful outputs. This is red-team thinking applied to prompt optimization: the evaluation metric itself is adversarial.
This creates a multi-objective optimization problem where GEPA's Pareto frontier becomes especially valuable. One candidate might be best at accurate analysis on clean data; another might be best at resisting prompt injection. The Pareto frontier preserves both, and the merge operation can combine their strengths.
Second: Expensive Rollouts
Security agent evaluations are expensive. Running a full BloodHound attack-path analysis takes time. Simulating credential-based attacks requires realistic Active Directory environments. Each "rollout" — executing the agent on an example — might involve multiple tool calls, graph traversals, and multi-step reasoning chains.
GEPA's sample efficiency matters enormously here. Where RL methods require tens of thousands of rollouts, GEPA works well with 20-100 examples. Decagon's production ablation study confirmed this: 20-50 samples produced the best prompts, while 500 samples led to overfitting and bloat. When each evaluation requires standing up a realistic security environment, cutting from 10,000 rollouts to 150 is the difference between feasible and impossible.
Third: Interpretability and Audit
In security, you need to know why your agent made a decision. Black-box optimization — where a prompt emerges from thousands of gradient updates with no human-readable explanation — is a non-starter for security-critical workflows.
GEPA's optimization traces are human-readable. Every mutation has a reflection that explains what failure mode was diagnosed and what change was proposed. This audit trail is exactly what security teams need: not just a better prompt, but a documented chain of reasoning showing how the prompt evolved and why each change was made.
The Production Reality
The GEPA ecosystem has matured rapidly. The library reached 5,082 GitHub stars this week, with enterprise adoption that reads like a who's-who of infrastructure companies. But production use requires more than just running pip install gepa.
Decagon's detailed ablation study (19+ experiments on a production classification task) surfaced three findings that anyone deploying GEPA — especially in security — should internalize:
Less data works better. The sweet spot for GEPA is 20-100 examples, not 500. More data leads to longer prompts that overfit to training distribution quirks. With 500 samples, prompt length ballooned by 75% while performance decreased by 2%. In security, where labeled examples are scarce and expensive, this is good news.
Reflection model quality is non-negotiable. When Decagon tested GPT-4o-mini as the reflection model, the "optimized" prompt was essentially unchanged — 65 characters of nothing. The reflection model must reason about reasoning: diagnose failures, identify patterns across examples, and synthesize targeted improvements. This requires frontier-level intelligence. The cost is manageable: reflection models are called only 10-20 times during optimization, representing 5-10% of total cost.
Length constraints are essential regularization. Unconstrained GEPA produces prompts exceeding 5,000 characters. A 1,500-character constraint achieved 4× compression with only 0.8% performance loss. For security agents that need to process long, complex contexts, every token in the system prompt competes with the task input for the model's attention window.
These findings align perfectly with what SpecterOps would need. Security agent prompts already tend toward verbosity — each new edge case adds another paragraph of instructions. GEPA with length constraints and Pareto selection naturally fights this bloat while preserving the behaviors that matter.
The Bigger Picture: Security as a Testbed for AI Methodology
SpecterOps' adoption of GEPA for security agents is part of a larger pattern: security teams are becoming the canaries in the coal mine for AI methodology. They face adversarial pressure that most domains don't, forcing them to develop evaluation and optimization practices that the rest of the industry will eventually need.
Consider the parallels. The DevSecOps movement didn't stay in security — it transformed how all of engineering thinks about CI/CD. Red-team methodologies didn't stay with pentesters — they became standard practice for AI safety evaluation. And now, measurable prompt engineering — combining automated optimization with adversarial evaluation — is emerging from security research with clear applicability to every production agent.
Microsoft's MAI-Thinking-1 team used GEPA to optimize the LLM-judge prompt for filtering pre-training data at 233-billion-token scale — a use case where wrong prompts mean toxic training data and compromised models. Nubank optimized customer-support agents serving 100 million users, achieving Cohen's κ from 0.00 to 0.745 — turning random agreement into strong cross-model consistency. These are high-stakes, adversarial-adjacent environments where getting the prompt right is a production-critical concern.
The security domain adds something unique to this mix: the explicit recognition that your evaluator must be adversarial. Most GEPA deployments optimize for task accuracy on benign inputs. SpecterOps optimizes for accuracy on hostile inputs. The prompts that survive this process aren't just better — they're more trustworthy.
What This Means for Teams Building Agents
If you're building production agents — security or otherwise — the SpecterOps approach offers a concrete playbook:
1. Make prompt optimization measurable. Stop hand-tuning prompts. Define evaluation metrics, build a dataset of examples (20-100 is sufficient), and run GEPA. The optimization traces give you an audit trail that manual tuning never will.
2. Include adversarial examples in your evaluation set. If you're optimizing a security agent, some percentage of your evaluation examples should be adversarial — attempts to manipulate the agent into incorrect or harmful behavior. GEPA's Pareto frontier preserves candidates that resist these attacks even if they're slightly worse on benign inputs.
3. Use a frontier model for reflection. The cost of using GPT-5 or Claude Opus as your reflection model is 5-10% of total optimization cost. The cost of using a cheaper model is a complete optimization failure. Don't skimp here.
4. Constrain prompt length. Set a character limit that matches your deployment constraints. GEPA will naturally produce more concise, generalizable prompts when length-bounded.
5. Treat your evaluation dataset like a test suite. The same discipline that security teams bring to red-team scenarios should apply to your eval set. What attack patterns must the agent resist? What edge cases must it handle correctly? These questions define your metric, and your metric defines what GEPA optimizes for.
Looking Ahead
GEPA's trajectory is remarkable for a research tool that's barely a year old. From an ICLR oral paper to integration in Google's Agent Development Kit, Microsoft's pre-training pipeline, and now SpecterOps' security agent stack, it's moving from research novelty to production infrastructure at a pace that suggests the industry recognizes a genuine advance.
The SpecterOps application is particularly significant because it closes a loop that's been open since the beginning of the LLM security conversation. We've known that prompts are the attack surface. We've known that prompt injection is a real threat. What we haven't had is a constructive methodology — not just testing prompts for weaknesses, but optimizing them to be stronger. GEPA applied with adversarial evaluation does exactly this.
SpecterOps has built their reputation on making the attacker's perspective rigorous and measurable. Applying that same rigor to AI agent prompts — with the help of a tool that emerged from the ML optimization community — is a convergence that neither field could have predicted, but both desperately needed.
The security agents of 2026 won't be secured by bigger models or longer prompts. They'll be secured by optimization methods that treat adversarial evaluation as a first-class objective, that preserve diverse defense strategies via Pareto selection, and that produce human-readable audit trails for every improvement. SpecterOps just showed that this isn't theory. It's production.
GEPA is available at github.com/gepa-ai/gepa (MIT license) and installable via pip install gepa. SpecterOps' blog post is at specterops.io. The original GEPA paper is at arxiv.org/abs/2507.19457.