Measuring guardrail false positives and missed attacks before you trust a filter
Turning on a guardrail is not the same as knowing it works. A team can switch on a filter in front of its LLM application and still be unable to say how many attacks get through or how many legitimate users it blocks. The answer to both questions comes from measuring each error type on its own labeled dataset: an adversarial set of attack prompts, where every request should be blocked, and a benign set of ordinary requests, where none should be. With promptfoo, you run both sets through the guardrail, record each block as a guardrail flag, and then choose a threshold from the trade-off those numbers show. Missed attacks and wrongly blocked requests move in opposite directions as you tighten or loosen a filter, so you need both counts before you pick a setting.
Promptfoo runs locally. Evals execute on your machine and talk directly to the guardrail or the application wrapped around it, so the datasets and responses stay in your environment. Point a provider at the guardrail, whether that is a cloud service, a self-hosted filter or your own function, and promptfoo records which requests were flagged. Measure before go-live so you have a baseline. Measure again after a provider updates its model or rules, since a filter can change behavior without any change on your side. Measure before replacing a filter, so the new product is compared on the same sets as the old one.
Before you pick a threshold, confirm three things with your guardrail vendor or in your own environment: which score or severity level triggers a block, whether that setting is adjustable, and whether a blocked request returns the same signal across the API you call. Then review the benign failures by hand, because a low false positive rate on a small or unrepresentative benign set proves little. Record the threshold, both error counts and the datasets used, so the decision can be reviewed later.
Test set and threshold options and when each fits
This table compares the main choices for building a guardrail test: how results are aggregated, where the test is applied, how the decision threshold is set, and where benign traffic comes from. Read each row as a decision with its trade-off, and use the last column to match the option to your release stage and team capacity.
| Option | What it measures | Effort to build | When it fits |
|---|---|---|---|
| Single pooled score | One missed-attack rate and one false-positive rate across all test cases | Low, one dataset and one report | Early baselines and quick comparisons between two guardrail configurations |
| Per-category results | Miss and block rates for each attack class, such as prompt injection, jailbreak or data leakage | Medium, needs labeled categories in both attack and benign sets | Release gates where one weak category would be a blocking finding |
| Application-level tests | Whether your full application blocks or allows a request, including prompt templates and tool calls | Higher, needs a provider or endpoint wired to your app | Deciding whether the deployed system is acceptable to the team that owns it |
| Service-level tests | Whether the guardrail service flags an input or output on its own, outside your application | Lower, calls the guardrail API directly | Comparing services or checking a vendor configuration in isolation |
| Fixed threshold | Results at one configured sensitivity setting | Low, a single run per configuration | When the threshold is already set by policy or vendor default and you only need evidence for it |
| Threshold sweep | Miss and false-positive rates across a range of threshold values, shown as a trade-off curve | Medium to high, many runs and a chosen operating point to justify | Choosing a threshold for the first time or when the business accepts a specific number of wrongly blocked users |
| Production-like benign set | Benign requests drawn from anonymized logs or real workflows, reflecting actual phrasing and language mix | High, needs data access, privacy review and labeling | Estimating real user impact before enforcement, where wrong blocks have a business cost |
| Synthetic benign set | Generated legitimate prompts covering planned use cases and edge wording | Medium, generation and spot checks by a reviewer | Early testing before production data exists, or when logs contain sensitive content |
| Domain-specific benign set | Legitimate requests from your sector that look like attacks, such as clinical terms or financial instructions | Medium to high, needs domain experts to write and review cases | Regulated or specialized applications where generic benign sets miss the false positives that matter most |
Building the attack and benign sets and running the comparison
This sequence turns a guardrail into two measurable numbers: how many attacks it misses and how many legitimate requests it wrongly blocks. The output is a repeatable comparison across threshold settings that you can rerun after any change.
Label adversarial and benign prompts separately
Build two files, one with adversarial prompts (injections, jailbreaks, policy-violating requests, document-borne attacks) and one with benign requests that resemble your real traffic, including edge cases such as security questions, medical or financial terms and short ambiguous messages. Keep the sets in separate files so that a row can never be counted in both. Store each row with a category and a source note so that you can later explain any result. The step is done when each set has a documented purpose and no prompt appears in both files.
Confirm the labels were reviewed
Have a second person read every row and confirm that the adversarial label is correct (the prompt really is an attack for your application) and that the benign label is correct (a reasonable user of your service would send it). Record reviewer, date and any rows removed or relabeled. Mislabeled rows distort both rates, so this check comes before any metric is calculated. The step is done when a review log exists and every disagreement has been resolved.
Write a provider that returns the guardrail decision
Write a promptfoo provider, as a Python or HTTP provider, that sends each prompt to the guardrail or to the application in front of it and returns the decision as a flag, for example
blocked: trueorblocked: false, along with the raw score or category where the service exposes one. Map each vendor's response into the same shape so that the assertions do not change between guardrails. Return an explicit error field when the call fails, rather than a default value. The step is done when a single test row returns a blocked flag and an error field that is empty on success.Assert on blocked versus passed for each set
Configure the adversarial set to expect a block and the benign set to expect a pass. Use promptfoo assertions that check the flag directly, so a row passes only when the guardrail decision matches its label. From the results, count missed attacks (adversarial rows that passed) and wrongly blocked requests (benign rows that were blocked) for each set. The step is done when a run produces both counts for the same guardrail configuration.
Record errors separately from passes
Make sure timeouts, rate-limit responses, authentication failures and malformed responses are reported as errors, not as passes or blocks. An error on an adversarial row is not a caught attack, and an error on a benign row is not a correct allow. Report error counts next to the two rates, and rerun any row with errors before drawing conclusions. The check is that the error count is shown in the summary and that the attack and benign rates use only rows with a valid decision.
Compare results across threshold settings
Run the same two sets against each threshold or configuration you are considering, keeping the prompts, provider and assertions identical. Put the missed-attack rate and the wrongly-blocked rate side by side for each setting, and note which rows change status between runs. Choose a threshold from this trade-off using the risk your application carries, and record the chosen value with the reasons for accepting the remaining misses and false positives. The step is done when a comparison table exists for every candidate setting.
Rerun the full comparison after any change
Treat the attack set, benign set, provider and assertions as a versioned test suite. Rerun the complete comparison after any change to the guardrail, its policy, its threshold, the model behind it or the application prompt that sits in front of it, and after any vendor update you can detect. Keep each run's output with the configuration that produced it so that results can be compared over time. The step is done when a rerun reproduces the earlier results for an unchanged configuration, and any difference is explained.
Security risks in building the test sets
Guardrail test sets contain attack prompts, and benign sets can pick up real user content from production logs. Each card below covers one place where that data can leak, persist or reach a third party while you measure false positives and missed attacks.
Attack prompts as sensitive material
A well-built attack set is a map of how your application can be abused, including jailbreaks and injected instructions tuned to your system prompt. Store it like other security test assets, with restricted access and a named owner. Confirm who can read the dataset files, the promptfoo output and any exported reports before the set is shared with a vendor or an outside tester.
Red teaming docsReal user data in benign sets
Benign sets are most realistic when built from production traffic, but that traffic holds names, account numbers, health details and other personal data. Remove or replace personal data before a prompt enters a test file, and record what transformation was applied. Ask your privacy team whether the test use is covered by the purpose under which the data was collected.
Datasets leaking into shared logs
CI logs, eval reports and web UI history can each store the full prompt and model response for every test case. A single failing run can therefore copy attack text or user data into a log that many people can read. Check what your pipeline prints, how long artifacts are kept and who can open them, and mask fields where the tool allows it.
Provider endpoints receiving test content
Every test prompt sent to a model or guardrail service leaves your network if that endpoint is hosted by a third party. promptfoo runs on your machine and talks directly to the LLM, so the data path is set by each provider configuration. For every provider in your suite, confirm the endpoint region, the vendor's data retention and training terms, and whether the service is covered by your contract.
promptfoo introductionShared self-hosted results storage
The self-hosted promptfoo app stores data in a local SQLite database, and the project does not recommend it for production use. Results therefore sit in a single file on one host, with no role-based access control or built-in authentication. Before a team shares results through it, decide where that file lives, who can reach the host, and how the file is backed up and deleted.
Self-hosting docsRetention and deletion of test sets
Test sets outlive the project that created them, and copies accumulate in laptops, CI caches and object storage. Set a retention rule for raw prompts and responses, separate from the aggregate scores you keep for trend tracking. Ask the team to document where each copy lives so that a deletion request or a dataset retirement can reach every location.
Choosing a threshold from the trade-off
Read the results as a curve, not as a single score. Run the same attack set and benign set at each candidate setting of the guardrail, whether that is a severity threshold, a confidence score, a policy strictness level or a block and flag mode, and record the missed attack rate and the wrongly blocked benign rate at every point. Plot or tabulate the pairs. As the setting tightens, missed attacks fall and false positives rise, and the shape of that curve tells you how much blocking you buy for each legitimate user you lose. A threshold chosen from one run without this sweep is a guess, and it will not hold once the guardrail or the traffic changes.
Decide which error the business can tolerate before you pick a point on the curve. A customer-facing assistant that blocks ordinary requests breaks the product and generates support load, so the owners of that product may accept more missed attacks in exchange for fewer false positives, relying on other controls for the residue. An internal coding or document tool used by trained staff may justify a stricter setting, because a wrongly blocked request costs a few minutes and the exposure is confined to employees. Ask the product owner, the security owner and, where personal or regulated data is involved, the compliance owner to state the tolerable rate for each use case in writing. The decision belongs to the owners of the risk, not only to the test team, which can show the trade-off but cannot accept it on the business's behalf.
Document the chosen point with its evidence so that the next reviewer can reproduce the decision. Record the guardrail name and version, the exact setting, the attack and benign dataset versions, the run date, the missed attack and false positive figures with their counts, and any errors that were kept separate from passes and blocks. Note the points you rejected and why, and state which residual risks are accepted and which compensating controls cover them. Confirm with your vendor or your own environment how a setting change propagates to production, because a threshold that was tested in one configuration is not proven in another. Schedule a retest whenever the guardrail, its settings, the model behind the application or the user population changes.
Limits of guardrail measurements to confirm
A guardrail score is only as good as the data and definitions behind it. The cards below cover the assumptions to confirm before you trust a false positive or missed-attack rate, and the point where measurement stops and assurance has to take over.
Attack set matches your threat model
Check whether the adversarial prompts reflect the attacks your application can actually receive: direct injection from users, indirect injection through documents and retrieved pages, and jailbreaks that match your product's persona and tools. A set built from generic public prompts can show a high catch rate while missing the paths your users and data sources expose. Write down the threat model first, then map each category of the attack set to it.
Red teaming docsBenign set reflects real traffic
A false positive rate is only meaningful on requests that look like your production traffic. Benign sets built from short, clean questions will understate blocks on long pastes, code, multilingual text, security-related questions from legitimate staff, and medical or financial terms that resemble attacks. Sample from logs where you have permission to use them, and record how each benign case was chosen so the rate can be explained to reviewers.
How the vendor defines a block
Guardrail services differ in what they count as a block. Some return a single action, others return a score or category per filter, and some flag a request while still letting it through in a monitoring mode. Before comparing numbers, confirm whether your test counts a flag, a block, a redaction or a timeout as a refusal, and map each vendor's response fields to one rule. Otherwise two guardrails may be scored on different events.
Results across provider versions
Guardrail models and their thresholds can change without a change to your code. Record the service name, model or API version, and configuration (including thresholds and enabled categories) with every run, then rerun the same sets after any vendor update. Compare runs only when the configuration matches. Ask each vendor how it announces changes to detection behavior and whether older versions remain available for a period.
A dataset cannot prove absence
A test set shows how a guardrail behaved on the cases you wrote, not that no attack exists. A zero miss count on a finite set says nothing about novel encodings, multi-turn escalation or attacks built against your specific prompts. Report results as measured rates on named sets, keep the sets growing from incidents and red team findings, and pair guardrail tests with application-level testing and security reviews rather than treating a passing score as assurance.
- Community monthly probes
- 10k probes
Sample size and repeatability
Small sets produce rates that swing widely between runs, and LLM-based classifiers can vary between calls. Before choosing a threshold, confirm how many cases each category contains, whether the run was repeated, and how much the rate moved between repeats. Keep the same seed or sampling settings where the tool allows them, and report the count alongside every percentage so a reader can judge how much weight the number carries.
Questions teams ask before measuring guardrail errors
How much effort does building a labeled attack and benign set take?
Effort depends mostly on how many distinct attack types and legitimate use cases your application has, and on how carefully each example is labeled. A set that covers only one attack family and a handful of benign requests is quick to assemble. A set that reflects your real traffic, including domain terms, languages, long documents and edge cases that look like attacks, takes far longer, because someone must decide the correct label for each item and record why. Ask any partner to show how they source examples, who reviews labels, and how disagreements are resolved. Labeling is usually the largest share of the work, and it recurs whenever the application or guardrail changes.
Is promptfoo Community enough to measure guardrail false positives and missed attacks?
For many teams, yes. The Community edition is free and includes all LLM evaluation features, all model providers and integrations, and red teaming with 10k probes per month, with community support. Measuring missed attacks and wrongly blocked requests needs the evaluation features, not the paid tiers. Enterprise adds team sharing, SSO, role-based access, continuous monitoring and a centralized guardrail dashboard, which matter when several teams must review the same results. Confirm the current limits on the pricing page before you plan a large attack run, because the probe allowance is monthly.
How long does a guardrail test run take?
Run time scales with the number of test cases, the number of guardrail calls each case makes, and the rate limits on the guardrail service and any model used for grading. A benign set of a few hundred requests and an attack set of similar size can finish in one session if the endpoint allows the request rate. Larger sets, multiple guardrail configurations and retries lengthen the run. Ask your provider for their documented request limits and quotas before you size the test, and measure one small batch first to extrapolate. promptfoo caching and retry settings also change timing, so note which options you used when comparing runs.
What do we need to provide for guardrail testing?
Expect to provide four things:
- Labeled data: attack examples and legitimate requests that reflect your application, with a reason for each label.
- Endpoint access: a test or staging route to the guardrail, with credentials that can be rotated and logged calls.
- Application context: the system prompts, tools and languages your users actually use, so benign tests are realistic.
- Owners: a named person who decides acceptable false positive and missed attack rates and signs off on threshold changes.
Without the last item, test results rarely turn into a decision.
Who should decide the threshold for blocking?
The threshold is a business and risk decision, so it should have a named owner, usually a product or security lead who accepts both kinds of error. Engineers can show the trade-off: raising sensitivity catches more attacks but blocks more legitimate users. The owner should review the cost of each error type for their product, such as a blocked customer support request versus a successful injection into a tool. Record the decision, the data behind it and the date, so future guardrail changes can be compared against the same baseline.
Can our own team run this measurement without a partner?
Yes, if you have engineers who can write provider configurations, maintain labeled datasets and read evaluation output, and if someone owns the threshold decision. promptfoo is MIT licensed and can run locally on your machine, which keeps test data inside your environment. A partner helps when the labeling effort is large, when several guardrails must be compared, or when results must be prepared for a compliance review. DeployOpen plans and runs these tests as fixed-scope work, with the scope, deliverables and timeline agreed in writing before the work starts.
Where does the test data go when we run promptfoo?
promptfoo documentation states that the software runs completely locally: evaluations run on your machine and talk directly with the LLM. Prompts, responses and guardrail results therefore flow between your machine and the providers you configure, not through a promptfoo-hosted service. Check which provider endpoints receive the attack and benign sets, because a cloud guardrail service will process them under its own terms. If you deploy the self-hosted promptfoo app for a team, confirm its storage and access controls first, since it uses a local SQLite database and has no built-in authentication or SSO.
How the attack set, benign set and guardrail decisions fit together
The run starts with two labeled datasets: an attack set of prompts that should be blocked and a benign set of legitimate requests that should pass. promptfoo sends each prompt to the guardrail under test and records its block or pass flag. Each flag is then scored against its label, producing a missed-attack count and a false-positive count. Check that the labels are correct and that errors are kept apart from passes, because a failed call is not a successful block. Those two counts are what you weigh when you choose a threshold.
Labeled datasets flow through promptfoo into guardrail counts that inform the threshold.
How DeployOpen scopes and delivers guardrail measurement
DeployOpen measures guardrails in the client's own environment with promptfoo, producing separate numbers for missed attacks and wrongly blocked benign requests. The work ends in a written threshold recommendation that the client's security and product teams can review and rerun.
How we scope
- The written scope names the guardrails, applications and endpoints under test before any dataset is built.
- Scope states which attack categories and benign traffic types the adversarial and benign sets must cover.
- Engagements are fixed-scope, with deliverables and timelines agreed in writing before work starts.
How we build
- We build the attack and benign datasets and the promptfoo configuration inside your infrastructure.
- Blocked, allowed and errored results are recorded separately so provider failures never count as passes.
- Threshold sweeps show missed attacks against wrongly blocked benign requests at each candidate setting.
How we hand over
- You receive the test suite, datasets, configuration files and a runbook for rerunning the measurements.
- The report lists false positive and missed attack rates per category, with the threshold trade-off explained.
- Your team walks through the results and the recommended thresholds before the engagement closes.
How we support
- Ongoing support is available as a retainer for rerunning measurements after guardrail or model changes.
- Retainers can cover scheduled regression runs, dataset updates and review of new guardrail versions.
- Ask any provider to confirm the retainer scope, response expectations and access to your environment in writing.

