Retry Strategy
The retry strategy automatically incorporates previously failed test cases into your test suite, creating a regression testing system for target LLM systems. Each red team scan learns from past failures, making promptfoo increasingly effective at finding vulnerabilities in your target. The retry strategy runs first in your pipeline, allowing other strategies to build upon these historical test cases.
The retry strategy is target-specific - it only retries test cases that previously failed against the same target system (identified by target label). This ensures that the retried test cases are relevant to the specific target's known vulnerabilities.
Implementation
To include the retry strategy in your red teaming setup:
redteam:
strategies:
- id: 'retry'
config:
numTests: 10 # Number of historical test cases to include per plugin
plugins:
- harmful:hate # Only retry failed tests from these plugins
- harmful:illegal
You can configure:
numTests
: Maximum number of historical test cases to include per plugin (default: matches each plugin's numTests setting)plugins
: List of specific plugins to apply retry strategy to (default: all plugins)
For example, with the above configuration and two plugins specified, the retry strategy would include up to 10 historical test cases for harmful:hate
and another 10 for harmful:illegal
, all specific to your current target system.
For basic usage without configuration:
redteam:
strategies:
- id: retry
How It Works
The retry strategy works by:
- Identifying previously failed test cases for the target system
- Selecting the most relevant failed test cases by plugin
- Incorporating these cases into the current test suite
- Allowing subsequent strategies to build upon this historical knowledge
Example Scenarios
If you have a test suite with:
redteam:
plugins:
- id: harmful:hate
numTests: 5
strategies:
- id: retry
- id: multilingual
And previously some hate speech tests failed against your target, the retry strategy will:
- Generate 5 new hate speech test cases
- Find previously failed hate speech test cases for this target
- Combine and deduplicate them
- Select the top 5 most relevant test cases
- Pass these to subsequent strategies (like multilingual)
Best Practices
- Review and grade your most recent red team scan before generating new test cases
- Use it in combination with other strategies for maximum coverage
Currently, the retry strategy uses only your local database. Cloud sharing of retry test cases across teams is coming soon.
Related Concepts
- Strategies Overview - See how retry fits with other strategies
- Types of LLM Vulnerabilities - Understand what vulnerabilities to test for
- Best-of-N Strategy - Another approach to improving attack success rate