Prompt optimization

Tuning SOC triage with GEPA: when more isn’t better

What happened when we increased the tuning budget and used a stronger reflection model to improve a security triage prompt.

Overview

A security case is a group of related alerts. These alerts can be parts of one incident. Example: failed logins, then a successful login, then a new mailbox rule, all for one user. An LLM reads the evidence for each case. Then it gives a verdict: real attack or false alarm.

The LLM that gives the verdict is the inference model. A prompt tells this model how to make the verdict. GEPA is a method that improves this prompt automatically. GEPA uses a second LLM, the reflection model. The reflection model reads the errors of the inference model and writes a new version of the prompt. We use the reflection model only during tuning. We do not use it in production.

GEPA improved the prompt. We then tested two settings: the tuning budget and the reflection model. The tuning budget sets an approximate limit on the number of scored agent runs during the search. Each run uses one candidate prompt to answer one case and can include several LLM calls and tool calls. The budget includes training and validation runs within GEPA, but excludes reflection model calls and separate evaluations after tuning. A larger budget gives GEPA more opportunities to propose and test prompt versions.

The reflection model uses execution records and feedback to propose prompt changes, so a stronger model may produce better changes. However, larger budgets and stronger reflection models did not produce the gains we expected in our experiments.

Key findings

  • GEPA helps. The start prompt had only two sentences. Our production prompt was written by hand and had already been tuned in an earlier GEPA round for a previous inference model. GEPA found prompts that were 14–20 percentage points more accurate than the production prompt. These prompts found the same percentage of real attacks (true-positive recall).
  • No single prompt is best. Of all cases, 87% are false alarms, and their evidence is often similar to the evidence of real attacks. Thus, a prompt that finds more real attacks also flags many more false alarms, and its accuracy decreases. The best prompt depends on how many false alarms a SOC accepts to find one more real attack. This limit is different for each SOC, and it is usually unknown during tuning. A GEPA search score sets the relative cost of different errors, and each run returns one selected prompt. Thus, we run GEPA with several score weights and keep the set of best trade-offs (a Pareto frontier). The team that owns the trade-off then selects one prompt.
  • More budget did not improve the frontier. When we doubled the GEPA budget, the prompts usually got more accuracy and found fewer real attacks. We ran 27 setups with both budgets and kept all other settings the same. In 19 of the 27 setups, the larger budget found fewer true positives. The prompts from the larger budget were also longer. They also had more rules for the specific cases that we used for tuning.
  • The strongest reflection model was not the best choice. A reflection model with high reasoning made most of the best trade-offs when we compared only accuracy and recall. But each prompt from this model had rules for specific past cases.
  • The cheapest setup gave good results. In this setup, the inference model was also the reflection model. Reflection cost $0.71 for 18 tuning runs. With the strongest reflection model, reflection cost $90. In the middle of the trade-off, some prompts from the cheapest setup were among the best prompts of all setups.
In this article

The problem: case triage

Case triage decides if a person must act on a security case. A detection system makes thousands of alerts each day. Correlation logic puts related alerts into one group, called a case. Example: many failed logins from one IP address, then a successful login and a new inbox rule for the same user. An analyst who opens this case must answer one question: is this a real attack or a false alarm?

We give each case one of these four verdicts:

Verdict Meaning Usual next step
True Positive (TP) Malicious or unauthorized activity occurred Escalate and respond
False Positive (FP) The detection triggered, but no bad activity occurred Close
Benign True Positive (BTP) The activity occurred, but was expected, such as an admin script Close; possibly tune the rule
Inconclusive The evidence is not sufficient for a verdict Send to an analyst

Swipe the table to see all columns.

The verdict step does not read raw logs. Before this step, an alert-triage agent investigates each alert. For each observable in an alert, such as an IP address or a user, the agent does the checks that an analyst does. Examples:

  • Were there suspicious login attempts from this IP address during the past day?
  • Did the user add, change or delete inbox rules?
  • Did the activity come from a managed device?

Each check gives a finding: the observable, the question, a short text summary of the result, and the reasoning of the agent. The input to case triage is all the findings for all the alerts in the case, plus the case name and severity. This is a short example that we invented:

Invented example case with two alerts and three findings that together point to an account takeover, leading to a true-positive verdict.
Invented example case with two alerts and three findings that together point to an account takeover, leading to a true-positive verdict. View full-size image

The verdict step reads all three findings together. It gives JSON with the verdict and the reasoning.

Real cases are larger. In our dataset, a case has 1 to 135 alerts (median 2). The median case has 14 findings and approximately 18,000 characters of evidence text.

Why an LLM and not a classifier?

We use an LLM, not a conventional classifier, for the four reasons that follow.

The input is text, not a feature vector. The findings are text summaries from an upstream agent. The checks change with the alert type and its observables. A case can have 1 alert or 135 alerts. A classifier, for example gradient-boosted trees or logistic regression, needs a fixed set of columns. Thus, you must first convert all of this text into columns.

Each new detection, data source or check changes this conversion. Thus, the maintenance of the feature pipeline becomes most of the work.

The signal is in the combination, and this is where LLM reasoning is most useful. Many failed logins from one IP address are normal by themselves. In the example above, the same IP then logs in as j.doe from an unmanaged device. Four minutes later, a new rule forwards mail to an external address. Together, these findings show an account takeover.

To find this, the model must link findings that share an IP address or a user across alerts. It must put the events in time order. It must also read qualifiers such as "the connection was blocked" or "no suspicious traffic observed". Bag-of-words models and classifiers on text embeddings lose most of this structure. An LLM can do these steps and write them in its reasoning, where an analyst can check them.

Environments differ, and pre-training knowledge carries over. Each deployment has its own tools, naming conventions, normal behavior and alert mix. A classifier trained on the features of one environment knows only what its labels show. Thus, it transfers poorly, and a new environment does not yet have labels for retraining.

An LLM learned a large amount of security knowledge during pre-training: common products and log formats, normal admin activity, and known attack techniques (for example, MITRE ATT&CK). This knowledge is not specific to one environment, so it applies to a new environment immediately. The prompt only has to add general evidence rules. The parts that do not carry over are text that you can read and edit.

Analysts must check the reasoning. If a verdict closes a case, an analyst must compare the reason with the findings. The LLM gives this reason with the verdict. The policy itself, the prompt, is also text that people can read. Because of this, we can examine the tuned prompts for overfitting later in this post. For example, a rule such as "if the host name matches X, return FP" is easy to see.

But an LLM also has disadvantages. Each decision costs more than with a tree model. The output can change between runs. By default, the LLM does not give a calibrated score.

GEPA in brief

GEPA improves a prompt by editing its text. It does not change model weights. It was introduced in GEPA: Reflective Prompt Evolution Can Outperform Reinforcement Learning and is available as an optimizer in DSPy. GEPA first scores the start prompt on the validation set. Then it repeats these steps:

  1. Select a prompt from the candidate pool. Run it on a small batch of training cases (five in our runs).
  2. Score each output against its label. In our setup, the metric gives a number and a short text that explains the error.
  3. A reflection model reads the prompt, the cases, the outputs and the feedback. It finds possible causes of the errors and writes a revised prompt.
  4. Run the revised prompt on the same five cases. If its average score is better, score it on the full validation set and add it to the candidate pool.
  5. Select the next prompt to edit by looking for different strengths. By default, GEPA tracks which prompts get the best score on each validation case, including ties. It removes candidates whose winning cases are already covered by other candidates, then samples from the remaining candidates. A prompt with a lower average score can still be useful if it handles cases that the overall leader misses. Candidates that are best on more cases have a higher chance of selection. In our runs, GEPA used three measures instead of individual cases for this selection: the weighted score, TP recall and FP accuracy.
  6. Stop when the search reaches its approximate metric-call budget. One budget unit is one scored execution of the agent on one case. GEPA can finish an iteration after the count passes the budget. Return the prompt with the best average validation score.

This process uses two model roles. The inference model runs the triage prompt during tuning and in production. The reflection model runs only during tuning. Its only effect on production is through the final prompt. The two roles can use the same LLM or different LLMs, and this post compares both options.

Diagram: in production the inference model runs the triage prompt; during tuning, GEPA picks a parent prompt, runs it on 5 training cases, has the reflection model write a revision, and keeps it if it is better.
Diagram: in production the inference model runs the triage prompt; during tuning, GEPA picks a parent prompt, runs it on 5 training cases, has the reflection model write a revision, and keeps it if it is better. View full-size image

The inference model appears twice: once in production and once inside the loop. The reflection model appears only in the loop.

GEPA fits case triage well. The policy is in the prompt. The score is computed directly from analyst labels, so no LLM judge is needed. In this experiment, we used a few hundred labeled cases for training. And the result is a prompt that a person can read and review before it ships.

This post looks at two settings:

  • Budget: how many metric calls GEPA may spend. A metric call is one scored output on one case.
  • Reflection model: which LLM writes the revisions, and with how much reasoning.

Experimental setup

We ran 54 GEPA searches on the same 983 labeled cases. We then scored all 63 prompts (54 tuned prompts plus 9 runs of the production prompt) on every case.

The comparisons below use all 983 cases, including the training and validation cases. They describe the trade-offs within this dataset. They are not an independent estimate of performance on new cases.

Data

The dataset is 983 closed cases from one production environment. Each case carries the verdict of the analyst who closed it: 858 FP, 69 TP, 46 Inconclusive and 10 BTP. We used a fixed split. 491 training cases guide the edits, 295 validation cases choose the final prompt, and 197 were held back.

A rule that always answers FP gets 87.28% accuracy and catches no true positives. Accuracy alone therefore rewards ignoring attacks, so we report two measures:

  • Accuracy: the share of all 983 cases that get the correct verdict. Because 87% of cases are FP, this mostly measures how many false positives are closed correctly, which means analyst workload.
  • TP recall: the share of the 69 true positives labeled TP, which means real incidents escalated.

Experiment settings

Setting Values tested
Inference model GPT-6-luna; reasoning: none, low, medium
Reflection models GPT-6-astra: high reasoning; GPT-5.4: no reasoning; GPT-6-luna: reasoning matched to inference
Budget Light: 1,560 metric calls; heavy: 3,100
Search score Original, TP2, TP4
Seed prompt The same 159 characters for every search

We ran every combination of these settings: 3 reflection settings × 3 reasoning levels × 2 budgets × 3 search scores, which gives 54 searches. Each search starts from the seed: "Classify a security case based on alert triage findings…". A heavy search does not continue a light one. It starts again from the seed with about twice the budget.

What GEPA optimizes

For every case, the metric returns a number and a sentence of feedback. Both come from the analyst's label; no LLM judge is used.

The number comes from a fixed matrix that gives partial credit for some mistakes. Rows are the analyst's label, and columns are the model's verdict:

Analyst label / Model verdict TP BTP FP Inconclusive
TP 1.0 0.1 0.0 0.1
BTP 0.7 1.0 0.6 0.3
FP 0.4 0.6 1.0 0.3
Inconclusive 0.5 0.4 0.2 1.0

Swipe the table to see all columns.

Output that fails schema validation scores 0. The TP2 and TP4 variants make two changes. First, a TP case earns credit only when the model answers TP, so BTP or Inconclusive no longer get 0.1. Second, every other mistake keeps only half or a quarter of its penalty. For example, an FP case called TP scores 0.7 under TP2 and 0.85 under TP4, instead of 0.4. These changes make missed attacks more costly relative to mistakes on non-TP cases. We varied the score this way on purpose, to move prompts along the accuracy–recall trade-off.

The reflection model reads the feedback, along with the case evidence and the model's answer. The feedback gives the expected and predicted labels, the scores, and a fixed note for that type of mistake. Here is the feedback for a missed true positive in a TP4 run:

Diagram of the feedback for a missed attack: the metric compares the verdict with the label and sends labels, scores and a fixed note to the reflection model, but not the analyst's reason.
Diagram of the feedback for a missed attack: the metric compares the verdict with the label and sends labels, scores and a fixed note to the reflection model, but not the analyst's reason. View full-size image

The feedback never includes the analyst's reason for the verdict, so the reflection model learns what went wrong but not why.

On the 295 validation cases, the candidate pool tracks three objectives: the weighted score, TP recall (on TP cases only) and FP accuracy (on FP cases only). These measures guide which candidates GEPA selects for further editing. At the end, though, the run returns the prompt with the best average weighted score. Because the validation set is 87% FP, FP cases dominate that average. This matters for the budget result below.

Baseline

Our production prompt is about 13,000 characters. It was written by hand and then tuned in an earlier GEPA round for a previous inference model. We ran it at every reasoning level in every batch.

Overfitting review

A tuned prompt can learn rules that fit only the cases it was tuned on, for example "if the host name is X, the verdict is FP". Such a rule can increase accuracy on our 983 cases, but it does not help on new cases. Accuracy cannot show this problem, so we examined the prompt text directly. Claude Opus 5.5 read each tuned prompt and gave it a rating from 0 to 5. The reviewer did not see the settings or the scores of the prompt. A rating of 0 means that the prompt has only general evidence rules. A rating of 5 means that the prompt mostly uses a long list of case patterns with fixed verdicts. In this post, we consider ratings of 4 and 5 as high risk.

Why compare frontiers

As we explained at the start, no single prompt is best for every SOC. Thus, we compare settings by their frontiers, not by their best single prompt. Prompt A dominates prompt B if A is at least as good on accuracy and TP recall, and better on one of them. The Pareto frontier is the set of prompts that no other prompt dominates. For each recall target, the frontier shows the best accuracy that we can get. There is also a second reason. The search score moves prompts along the trade-off. If we compared only the most accurate prompt of each setting, we could not tell if a setting tunes better or only selected a different trade-off. Note: this frontier is different from the Pareto front that GEPA uses inside its loop to select the next prompt to edit.

Does GEPA help at all? Yes

With the same inference model and the same TP recall, the best GEPA prompts were 14–20 points more accurate than the production prompt. At low reasoning: 68.06% versus 54.22% accuracy, both at 47.83% recall. With no reasoning: 70.50% versus 50.15%, both at 49.28% recall. Part of this gain probably comes from fitting the prompt to the new inference model.

Question 1: How much budget?

Doubling the budget did not consistently push the frontier outward. Instead, it usually moved prompts toward accuracy and produced longer prompts with higher overfitting-risk ratings. Across the three reflection settings, the heavy budget did not consistently improve the accuracy–recall trade-off.

Three scatter plots of accuracy against true-positive recall, one per reflection model, showing that the heavy-budget frontier does not lie outside the light-budget frontier.
Three scatter plots of accuracy against true-positive recall, one per reflection model, showing that the heavy-budget frontier does not lie outside the light-budget frontier. View full-size image

The solid blue line is the light-budget frontier, and the dashed grey line is the heavy one. Crosses mark the production prompt. Under each panel, we put all 18 prompts of that setting together, find one frontier, and count how many of its prompts came from each budget.

We compared each heavy search with the light search that used the same reflection model, reasoning level and search score. That gives 27 matched pairs:

Measure Heavy better Light better Tie
Accuracy 18 9 0
TP recall 8 19 0
Overfitting risk (lower is better) 2 12 13

Swipe the table to see all columns.

The heavy search usually gained accuracy and lost recall. That is a move along the frontier, not beyond it. These are 27 single runs, so read this as a consistent tilt, not proof: a two-sided sign test on 19 of 27 gives p ≈ 0.05.

The frontiers show the same thing from another angle:

  • GPT-6-astra reflection: The combined frontier has 4 light and 4 heavy prompts. Heavy prompts fill the middle; light prompts hold both ends.
  • GPT-5.4 reflection: The combined frontier has 2 light and 3 heavy prompts. Heavy holds the high-accuracy end (81.18%). Light holds the high-recall end (71.01%, the highest recall in the study).
  • Matched Luna reflection: A light prompt dominates every heavy frontier prompt, so the combined frontier is all light.

Heavier searches also produced longer prompts. From light to heavy, the median tuned-prompt length grew from 38K to 45K characters with GPT-6-astra reflection. It grew from 11.2K to 12.7K with GPT-5.4, and from 7.4K to 10.1K with matched Luna. More iterations give the search more chances to add a rule that fixes one training case, and the overfitting ratings rose to match.

Our explanation for why the extra budget goes to accuracy: GEPA keeps the candidate with the best average validation score. With 87% FP cases, FP cases dominate that average, even when the search score weights missed TPs more heavily. A longer search finds more edits that win FP cases, and selection on the average keeps them.

What we would do: start with a light budget. If you have more to spend, spend it on breadth: more search scores, reasoning levels or random seeds. One heavy run costs about as much as two light runs. Two light runs with different search scores give you two frontier points, not one.

Question 2: Which reflection model?

No reflection setting's frontier dominates the others; the frontiers cross. Once overfitting risk and cost are counted, though, the strong high-reasoning reflector drops out. The inference model reflecting on its own errors is competitive at less than 1% of that reflector's cost.

Two scatter plots comparing the three reflection models' frontiers, for all prompts and for prompts rated 3 or lower for overfitting; the strongest reflector has no prompts left after the cap.
Two scatter plots comparing the three reflection models' frontiers, for all prompts and for prompts rated 3 or lower for overfitting; the strongest reflector has no prompts left after the cap. View full-size image

The right panel removes the high-risk prompts: those with an overfitting rating of 4 or 5 (see the overfitting review in the setup). It keeps only the prompts rated 3 or lower. None of the GPT-6-astra prompts qualifies, so that setting has no prompts left on the frontier. Under each panel, we put all the prompts of that panel together, find one frontier, and count how many of its prompts came from each reflection model.

Without constraints, the frontiers cross. Across all 63 prompts, the combined frontier has 11 prompts: 7 from GPT-6-astra, 2 from GPT-5.4 and 2 from matched Luna. GPT-6-astra reaches the highest accuracy (81.69%) and GPT-5.4 the highest recall (71.01%). Matched Luna has two frontier points in the middle. No other setting beats more than 2 of the points on any setting's frontier.

The strong reflector writes a different kind of prompt

Cost across the three reflection settings

Reflection setting Reflection spend Total spend Inference cost per case
GPT-6-astra · high $90.00 $177.24 $0.0015
GPT-5.4 · none $14.34 $64.56 $0.0008
GPT-6-luna · matched $0.71 $46.94 $0.0007

Swipe the table to see all columns.

Prompt length and overfitting ratings

Ratings show the rating followed by the number of prompts. Each setting produced 18 prompts.

Reflection setting Median prompt length Overfitting ratings
GPT-6-astra · high 40K characters 4 × 14; 5 × 4
GPT-5.4 · none 12K characters 1 × 1; 2 × 10; 3 × 7
GPT-6-luna · matched 9K characters 2 × 11; 3 × 6; 4 × 1

Swipe the table to see all columns.

Prompts on the combined frontier

Reflection setting All prompts Risk rating ≤ 3
GPT-6-astra · high 7 0
GPT-5.4 · none 2 4
GPT-6-luna · matched 2 3

Swipe the table to see all columns.

Total spend covers the 18 searches plus scoring all 21 variants on all 983 cases. Inference cost per case is the mean recorded cost across the 18 tuned prompts. The production prompt costs about $0.0007–$0.0008 per case.

GPT-6-astra's prompts are 3–4× longer than the others and 3× longer than our hand-written production prompt. As a result, every production verdict would cost about twice as much. All 18 of its prompts were rated 4 or 5, because their verdict logic depends on lists of specific case patterns. A strong reasoning reflector is very good at writing a rule for each training failure it sees. Those rules score well on the 983 cases we already have, but we trust them least on new cases.

With a risk cap, the strong reflector has no prompts on the frontier. If you only allow prompts rated 3 or lower, no GPT-6-astra prompt qualifies. GPT-5.4 then holds both ends (81.18% accuracy; 71.01% recall), and matched Luna holds much of the middle. With a cap of 2, the frontier has three GPT-5.4 prompts and three matched-Luna prompts.

Matched reflection is a sensible cheap default. We let the inference model reflect on its own errors, at its own reasoning level. Reflection cost $0.71 across 18 searches, about 1/127 of the GPT-6-astra cost. It wrote the shortest prompts, and most were rated 2. It did not reach either extreme: its best accuracy was 77.21% and its best recall 63.77%. It was also the setting where the heavy budget hurt most. GPT-5.4 without reasoning reached both extremes, with ratings from 1 to 3.

So, should the reflection model be the inference model? It is a good place to start: cheap, low-risk, and competitive where most operating points will sit. If you need either end of the trade-off, try one other inexpensive reflector. Do not assume the strongest reflection model is the right choice.

What this does not show. Each setting changed both the model and the reasoning effort, and each search ran once. So we cannot tell whether GPT-6-astra's behavior comes from the model or from high reasoning. What we can say is that the most capable and most expensive reflection setup was not the best choice for a prompt we intend to ship.

What we would tell another team

  1. Report a frontier, not a single winner. Vary the search score, meaning how much a missed true positive costs, to trace the trade-off. Before you look at the results, decide the minimum TP recall you need. Then choose the most accurate prompt that meets it.
  2. Start with a light budget, and spend any extra on breadth. Two light searches with different settings taught us more than one heavy search.
  3. Try the inference model as its own reflector first. It is cheap and kept prompts short and general. If you need either end of the trade-off, add one other inexpensive reflector.
  4. Gate on overfitting as well as scores. A blind LLM review of the prompt text against a short rubric is cheap, and it caught a problem that accuracy did not show. Prompt length is a useful early warning sign.
  5. Count inference cost. The reflection model writes your production prompt. Long prompts made every verdict cost about twice as much.
  6. Do not judge on accuracy alone when false positives dominate. In our data, always answering FP gives 87.28% accuracy and catches no attacks.
  7. Make the final decision on new cases. Results on cases you have already used are good for choosing candidates. They are not a measure of production performance.

Back to the blog