Concurrency, retries and resuming long PyRIT scans

Thousand-prompt PyRIT runs fail in predictable places: rate limits, malformed scorer output and interrupted scenarios. This page explains the controls PyRIT provides and how to set them for a stable run.

On this page

Why long PyRIT scans need concurrency and retry planning

This page covers how to keep a large PyRIT scenario finishing reliably: setting maximum concurrency, configuring the three retry levels, resuming a scenario where it stopped, and reading partial results when some objectives fail. If your team is running a thousand-prompt assessment against a model or application and needs the run to complete, these are the settings and operating decisions that determine whether it does.

The need shows up in three situations. The first is a large objective set, where the number of attack attempts multiplies across objectives, techniques and converters, so a run that works for ten prompts can stall or fail at scale. The second is a rate-limited target, such as a hosted model endpoint or an application with a request quota, where too much parallel traffic produces transient errors that the run must absorb. The third is a scheduled run, such as a nightly or per-release job, where nobody is watching when a failure happens and the run has to recover or report clearly on its own.

None of this requires a separate product. It is configuration and operations work on the PyRIT scanner you already run through pyrit_scan or pyrit_shell, combined with decisions about where results are stored and who reviews them. Before you commit to a concurrency level, confirm with your target owner what request limits apply to your deployment, and confirm how your PyRIT version handles retries as described in the PyRIT documentation on resiliency and retry.

The three retry levels PyRIT uses in a scan

PyRIT handles failures at three different points in a scan, and each one fixes a different kind of problem. Target-level retries absorb transient API errors, JSON retries handle malformed scorer output, and scenario-level retries let a stopped run continue. Knowing which level applies tells you whether a failure will recover on its own or needs your attention.

Target-level retries for transient errors

Target-level retries apply when the endpoint under test returns a transient API error such as a rate limit, so the same request is sent again after a wait. The defaults are 10 attempts, with waits between 5 and 220 seconds, set through RETRY_MAX_NUM_ATTEMPTS, RETRY_WAIT_MIN_SECONDS and RETRY_WAIT_MAX_SECONDS. These retries do not fix a wrong endpoint, an expired credential or a quota that is exhausted for the day, so check those separately when every request fails.

Resiliency docs

JSON retries for malformed scorer output

JSON retries apply when a scorer asks an LLM judge for structured output and the response cannot be parsed. PyRIT sends the request again rather than recording a failed score for that response. These retries do not correct a scorer prompt that the judge model consistently misreads, so a high rate of retries on one scorer suggests the scoring prompt or judge model needs review before you trust the results.

Scenario-level resume after a stop

Scenario-level retries resume a scenario from where it stopped, instead of rerunning objectives that already finished. This matters for thousand-prompt runs that stop partway through because of a network outage, a host restart or an interrupted pipeline job. Confirm in your own environment that the memory database used for the run is persistent and reachable on restart, because resume depends on the recorded state, and this does not repair objectives that failed for content reasons.

What retries cannot repair

Retries at every level repeat the same request under the same configuration, so they cannot change the outcome of a bad setup. A misconfigured target, a rejected payload, or a scorer that disagrees with the expected verdict will fail the same way on each attempt. Before increasing attempts or wait times, read the error type in the logs and fix the cause, since longer waits also extend total scan duration.

Target retry settings and when to change them

This table compares the target-level retry settings, the JSON retry choice and the concurrency setting that together decide how a long PyRIT scan behaves under rate limits and malformed output. Read each row as a dial: the default is a starting point, and the right value depends on your provider's rate limits, which you must confirm with the provider and your own quota.

SettingWhat it controlsDefault and when to change it
RETRY_MAX_NUM_ATTEMPTSHow many times PyRIT retries a target call after a transient API error such as a rate limitDefault 10. Raise it if runs fail after brief throttling bursts; lower it if a persistent outage should fail fast and surface sooner.
RETRY_WAIT_MIN_SECONDSThe shortest wait before a retry, the floor of the backoff windowDefault 5. Raise it if the provider's limits reset slowly and short waits only add to throttling; lower it only if errors clear quickly.
RETRY_WAIT_MAX_SECONDSThe longest wait between retries, the ceiling of the backoff windowDefault 220. Lower it if a scan stalls for long periods on a dead endpoint; raise it only after confirming the provider's recovery window.
Max concurrencyHow many prompts or objectives PyRIT sends to a target at the same timeSet it from your confirmed requests-per-minute and token limits. Lower it when rate-limit errors cluster; raise it only when the target shows spare capacity and retries are rare.
JSON retriesHow often PyRIT retries when a scorer receives malformed output it cannot parseRaise it when a scorer model often returns invalid structure; keep it low if repeated malformed output points to a prompt or scorer problem worth fixing first.

How to set max concurrency without triggering rate limits

Concurrency is the setting that trades completion time against throttling. Run more prompts in parallel and a thousand-prompt scan finishes sooner, but the target and the scorer both receive more requests per minute, and the provider may answer with rate-limit errors or slow responses. Run fewer and the scan is gentler on quotas but takes longer. The right value is the highest one your providers sustain without repeated throttling, and you find it by measuring on your own deployment rather than by copying a number from another team.

Concurrency applies to every model that PyRIT calls, not only the system under test. The target, any LLM scorer, and any adversarial model that drives multi-turn attacks each make their own requests, and each consumes its own quota on its own deployment or account. A scan that is comfortable against the target can still exhaust the scorer's tokens-per-minute allowance, because the scorer reads every response. Map each model to its provider, deployment and quota before you raise the parallelism, and budget the calls each one receives per prompt.

Start low on a first run, using a small dataset and a modest concurrency value, and watch the provider's usage pages and PyRIT's logs for throttling responses. Confirm the quota limits, quota units and any per-deployment ceilings with each provider, because these vary by account, region and model, and this page does not state them. Once the run is stable, raise the value in steps. Target-level retries, covered in the next section, absorb occasional rate-limit errors, but heavy throttling multiplies the number of retried calls, so a value that causes constant retries is too high even if the scan eventually completes.

Resuming a stopped scenario and reading partial results

This sequence lets a team stop or lose a long PyRIT scenario partway through, rerun it under the same label so scenario-level retry continues from where it stopped, and then review what completed and what failed in memory. Each step ends with a check so the team knows the resume worked before trusting the results.

  1. Choose a stable memory label before the first run

    Before starting the scenario, the engineer running it picks a memory label that identifies this assessment, such as the target name, the scenario name and a release identifier, and records it in the run notes. The label is what links the first attempt and any rerun to the same stored results. Reuse of a label that already holds unrelated runs should be avoided, so the team can tell the attempts apart later. The step is done when the label is written down and the team has confirmed that no earlier run uses it.

  2. Run the scenario and capture the interruption

    Start the scenario from pyrit_scan with the chosen label and the target registered for the test. Let it run until it stops, either because the process was interrupted, a host restarted, or objectives began failing after target-level retries were exhausted. Save the console output or the last lines of the log so the team can see where the run ended and which error appeared. The step is done when the stop is recorded with its time and the last error message, and the label is still visible in the output.

  3. Confirm the stopped run in memory

    Before rerunning, the engineer checks the stored results for the label and counts the objectives recorded as completed and as failed or unfinished. The aim is to know the state the resume must pick up from. Use the memory query tooling your team has confirmed for this PyRIT version, and verify on a test run how it reports scenario state. The step is done when the team has a written count of completed and unfinished objectives tied to the label.

  4. Rerun under the same label

    Rerun the same scenario, against the same target and with the same dataset and technique selection, using the exact label from the first attempt. Scenario-level retry is documented to pick up where a scenario left off, so the configuration must match the original run for the resume to be meaningful. Changing the dataset size or techniques between attempts can make the two sets of results hard to compare. The step is done when the rerun starts and the console or log shows that it is continuing the existing scenario rather than starting a new one.

  5. Check that completed objectives were not sent again

    After the rerun finishes, compare the request counts or conversation records for the label with the counts from the earlier check. Completed objectives should not show new target requests for the same objective IDs. If they do, stop trusting the resume for this run, note the mismatch and test the behavior on a small dataset before relying on it. The step is done when the team has confirmed, from stored records, that completed objectives were not re-sent, or has documented the exception.

  6. Review failed and unfinished objectives

    Pull the list of objectives still marked as failed or unfinished after the rerun. For each one, read the recorded error, such as a persistent rate limit, a malformed scorer output that exhausted JSON retries, or a target that rejected the request. Decide whether to retry it, fix the target configuration or remove the objective from the scope, and record that decision with the reason. The step is done when every remaining failure has a documented disposition.

  7. Report partial results with their status

    Assemble the findings from the completed objectives and label the report with the run status, the number of objectives completed, the number unfinished and the number excluded. Partial results are only useful when readers know what was not tested, so the report should state the gaps plainly. Keep the label, scenario history and the rerun timestamps with the report so an auditor or reviewer can trace it back to memory. The step is done when the report states its coverage and the team has agreed that it is complete for the scope it claims.

How a request moves through target, scorer and scenario retries

An objective starts in the attack, which sends a prompt to the target. Transient API errors such as rate limits are retried at the target level, using the RETRY_MAX_NUM_ATTEMPTS, RETRY_WAIT_MIN_SECONDS and RETRY_WAIT_MAX_SECONDS settings. The response then goes to the scorer, where malformed scorer output triggers a JSON retry. Each outcome is written to memory, so a scenario-level retry can resume from the last recorded objective. Check memory after an interrupted run to confirm which objectives are complete.

Retry paths at the target and scorer, with results written to memory for scenario resume.

Security and operational risks of long-running red teaming

A long PyRIT run touches live credentials, paid model APIs and stored attack content, and each of these risks grows with run length and concurrency. The cards below cover the controls to set before a thousand-prompt scan starts, so that retries and resumes do not turn into extra spend, exposed keys or leaked prompts.

Keep credentials out of run output

PyRIT reads provider credentials from ~/.pyrit/.env and settings from ~/.pyrit/.pyrit_conf. On a workstation that file is a reasonable starting point, but on shared runners or long-lived hosts, confirm who can read the home directory and whether a managed secret store can supply the values at run time. Check that keys are not echoed in configuration dumps, debug output or error messages that a resumed scan writes again.

Resiliency and Retry docs

Count retries as paid requests

Every retry is another request to the target and often to the scorer. Target-level retries repeat calls after transient API errors, JSON retries repeat scorer calls, and scenario-level retries resume work, so a failing run can cost more than the planned prompt count. Before a long run, ask the provider about rate limits and billing, set a spending ceiling where the provider offers one, and estimate worst-case volume from the retry settings instead of the happy path.

Limit attempts and wait times

The target retry settings RETRY_MAX_NUM_ATTEMPTS, RETRY_WAIT_MIN_SECONDS and RETRY_WAIT_MAX_SECONDS decide how long a stalled provider can hold a run open and how many attempts each prompt receives. Set them deliberately for each endpoint, then record the values in the run notes so a later reviewer can explain why one scan took longer or sent more traffic than another.

Default attempts
10

Control access to memory

PyRIT memory stores conversations, prompts, responses and scores in SQLite or Azure SQL. Those records contain harmful attack content by design, so the database file or the Azure SQL database needs the same access control as the most sensitive test data your team holds. Confirm who can query memory, where backups go, how long records are kept, and how resumed scenarios locate prior records without granting wider access.

Keep attack prompts out of job logs

Shared CI logs, console scrollback and chat notifications often reach people who should not read attack content. Before a resumed or retried scan writes output, review what the console, pipeline logs and artifacts print, and limit output to scenario names, counts and labels. Store full transcripts in restricted memory, and check that retry messages do not repeat the prompt text in plain form.

Review partial results before sharing

When some objectives fail mid-run, the partial output is still attack data and may be incomplete in ways that mislead a reader. Mark partial runs clearly, decide who may receive them, and confirm that a resumed scenario does not mix results from different target versions or configurations. Treat partial results with the same handling rules as completed runs before they reach a ticket, report or auditor.

Questions teams ask before running long PyRIT scans

Can our team tune concurrency and retries without outside help?

Yes, in most environments. The retry behavior is set through configuration, and the main settings for target-level retries are RETRY_MAX_NUM_ATTEMPTS, RETRY_WAIT_MIN_SECONDS and RETRY_WAIT_MAX_SECONDS, which default to 10 attempts, 5 seconds and 220 seconds. The harder part is choosing values that match your provider's rate limits and your target's capacity, which requires a few trial runs against your own endpoints. Engineers who already run API-heavy batch jobs usually find the tuning familiar. A partner adds value mainly when the target is custom, the rate limits are shared across teams, or the scans must be repeatable for an audit.

What drives the cost of a long PyRIT scan?

Most of the cost is metered usage and people time, not the framework itself. The main components are:

  • Target calls: every objective and conversation turn is a request to the system under test, which may be billed or rate limited by its provider.
  • Scorer calls: LLM-based scorers and content safety classifiers add requests for each response they evaluate.
  • Adversarial model usage: multi-turn strategies call a second model to generate attack turns, so technique choice changes the request count.
  • Operator time: configuring the target, reviewing results and rerunning failed sections.

Ask any quote to estimate each of these from the number of objectives, the techniques chosen and the scorers used.

How long does setup and tuning take for a thousand-prompt run?

The duration depends on the target, the provider quotas and how many runs you need before the settings are stable. No general figure applies, so confirm it with your team against your own environment. A useful first step is a small run limited by dataset size to measure request rates, error types and retry behavior. Then increase concurrency in steps and watch for rate limit errors. Ask any partner to state the setup and tuning steps as a written plan with the checkpoints where they will stop and review before scaling up.

What does the work need from our team?

Plan for four things before the first full run:

  • Environment access: credentials for the target and scorers, stored in the configuration files PyRIT reads, such as ~/.pyrit/.env.
  • Provider quotas: confirmed request and token limits for each model or endpoint in the scan, including any shared with other applications.
  • Memory storage: a database that PyRIT uses to save conversations and results, either SQLite or Azure SQL, with enough space and backups for long runs.
  • A named reviewer: someone who can judge whether failed or partial objectives are real gaps or infrastructure problems.

Confirm each item with the owner of the target and the platform team before work starts.

How should we review partial results when some objectives fail?

Treat a partial run as a set of separate outcomes, not a pass or fail score. Separate objectives that were never sent because of a stopped scenario from objectives that were sent but returned an error, and from objectives where the scorer could not parse the output. Only the last group says something about the target's behavior, and even that needs a human check. Keep the memory records for each attempt so a reviewer can see the exact prompts, responses and retries. Agree before the run how you will rerun or resume the missing objectives, and record that decision next to the results.

Does a larger concurrency setting always make a scan faster?

No. Higher concurrency sends more requests at once, which often triggers rate limits and retries, and those retries can slow the scan overall. The right setting depends on the target's capacity and the provider's limits. Start with a conservative value, measure the error rate and throughput, and raise it only while errors stay low. Document the value you chose so the same run can be repeated later.

Can we resume a scan from where it stopped?

PyRIT's scenario-level retries are designed to pick up where a scenario left off, so an interrupted run does not have to restart from the first objective. Confirm the exact behavior for your PyRIT version and scenario type before relying on it, and check that the memory database survived the interruption. Record which scenario, target and dataset the run used so the resumed run can be matched to the original.

How DeployOpen scopes and supports PyRIT scan operations

DeployOpen deploys, configures and tests PyRIT inside your own infrastructure, so the scan runners, the ~/.pyrit/.env credentials, the ~/.pyrit/.pyrit_conf settings and the SQLite or Azure SQL memory that holds attack history all stay under your control. Before any work starts, the scope is agreed in writing. For a long-scan engagement, that document should name the target systems, the scenarios to run, the expected request volume against each target's rate limits, the retry and concurrency values to be set, where resumable state is stored, and who receives partial results when an objective fails. Most engagements are fixed-scope, so deliverables and timelines are fixed in that same document and a quote follows from it. Ask for these items to be listed explicitly, because they are the inputs that determine how much tuning and testing the work requires.

The concurrency and retry settings are only trustworthy after they have been tested against your real endpoints. DeployOpen can verify target-level retry behavior, JSON retry behavior for scorers, scenario resumption after an interruption, and the handling of partial results, then document the chosen values and the reasoning behind them. Confirm with your team which retry values you are willing to accept for each target and whether any of your endpoints apply quotas that a higher concurrency setting would exhaust. Those answers belong in the scope, not in a later surprise.

DeployOpen also runs AI security testing with PyRIT and against the target applications in scope, and can plan the testing around the risks your organization must address. Where your AI systems are part of a compliance assessment, DeployOpen prepares the systems, controls and evidence that the assessment will ask for, including scan records and the memory data behind them. DeployOpen does not issue audit reports, attestations or certifications. Independent auditors and certification bodies make those determinations, so confirm early which evidence your assessor expects and in what format.

Ongoing operations are available as a retainer. A retainer can cover maintenance of the PyRIT installation, reviewing scan failures and retry logs, re-running long scenarios after target changes, upgrades to new PyRIT releases, and retesting when endpoints or limits change. Ask for the retainer terms in writing, including what is covered, how requests are handled and how the operating schedule works. Your internal team keeps ownership of the target endpoints and the decision about which objectives matter, while the retainer keeps the scan machinery reliable between those decisions.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.