Interactive red teaming sessions with pyrit_shell

pyrit_shell gives red teamers a REPL to run PyRIT scenarios repeatedly, attach converters to single techniques and review results. This page covers when to use it, how to set it up and what to confirm before a team relies on it.

On this page

When a red team needs pyrit_shell instead of one-off scans

pyrit_shell is PyRIT's interactive command-line session for running red team scenarios against a registered target again and again without retyping the full command. A security or AI team iterating on a target, changing a converter, adding a technique or checking whether a fix held, spends most of its time on the same few steps. The shell keeps that loop short. Inside one session you list what is available with list-scenarios, list-targets and list-converters, start a scenario with run, and then review what happened with scenario-history and scenario-results. Each of these commands maps to a question a red team asks during an iteration: what can I run, against what, what did I run before, and what did it find.

The main difference from batch pyrit_scan runs is the unit of work. A pyrit_scan invocation is a complete, self-contained run that you start, wait for and read. pyrit_shell is for the stage before that, when the scope is still moving. Converters attach to a single technique with the technique:converter.name syntax, so you can test whether a base64 or other encoding step changes a result for one technique without rebuilding the whole scenario. Use batch scans once the configuration is settled and you need a repeatable record for a change review or pipeline. Use the shell while you are still deciding what the configuration should be.

Before a team relies on the shell for findings, confirm three things in your own environment: which scenarios and converters your installed PyRIT version lists, which targets are registered in the configuration you share with colleagues, and where the memory store records each run so that scenario-history returns the runs you expect. Keep notes on which converter and technique combination produced each result, because a session can accumulate many similar runs quickly. The PyRIT Shell documentation lists the exact command options for the version you install.

How pyrit_shell fits each red teaming workflow

When a team meets a target for the first time, the goal is to learn what the system does and where it is weak, not to produce a score. An operator opens pyrit_shell, runs list-targets to confirm the endpoint is registered, and runs list-converters and list-scenarios to see which techniques are available before choosing a starting point. The run command then executes a scenario, and scenario-results shows what came back. The output is a set of conversations to read, which feeds the team's understanding of the target's behavior.

  • Confirm the target first: list-targets shows whether the registered endpoint is the one you meant to test before any prompts are sent.
  • Start with a narrow scenario: A single scenario with a small objective set gives readable output and keeps the first session short.
  • Attach one converter at a time: Use the technique:converter.name syntax to see how a single transformation changes the target's response.
  • Read conversations, not only totals: Early findings usually come from odd refusals or partial compliance that a summary hides.
  • Record what you changed: Note which techniques and converters you tried so the next session starts from a known point.

Before leaving an exploratory session, check that the target registration, the scenario names and the converter choices are written down so a colleague can reproduce the run.

Shell commands and attachment options compared

This table compares the six pyrit_shell commands and the technique:converter.name attachment syntax, with the situation each one fits and what to confirm in the version you install. Read it as a checklist: pick the command for the step you are on, then verify the exact behavior against the documentation for your release before you rely on it in a session.

Command or syntaxWhen it fitsWhat to confirm in your installed version
list-scenariosBefore a session, to find the exact scenario names available in your installScenario names and whether your scenario set matches the one your team documented
list-targetsConfirming which registered targets the shell can see before running a scenario against oneThat the target you need is registered in your configuration and reachable from this host
list-convertersFinding converter names to attach to a technique before you add them to a runThe converter names exactly as printed, since attachment depends on exact spelling
runRepeating a scenario against a target during an interactive session, after you have tuned the setupWhich scenario, target and option arguments the command accepts in your release
scenario-historyReviewing what ran earlier in the session or in past sessions before you repeat or compare runsWhether history persists across shell restarts and where it is read from in your memory setup
scenario-resultsOpening the outcome of a specific past scenario run to decide what to investigate nextHow results are identified (by run or scenario reference) and which fields are shown
technique:converter.nameAttaching one converter to a single technique so you can test the effect of that transformation aloneThat the technique name and converter name match your release, and that the converter applies to that technique

Setting up pyrit_shell for a team session

This sequence takes a team from a clean Python environment to a working pyrit_shell session with credentials, settings, a registered target and a first scenario run recorded in history. Each step ends with a check so the team knows the setup is sound before anyone starts testing.

  1. Confirm a supported Python version

    The engineer who owns the red teaming workstation checks that a supported Python interpreter is available before installing anything. The PyPI package supports Python 3.10 up to but not including 3.15, and the PyRIT documentation recommends Python 3.13, so the team should pin that version in its shared setup notes. Done means python --version reports a version inside that range and the team records which interpreter it will use for every session.

  2. Install PyRIT from PyPI

    The engineer creates a dedicated virtual environment and installs the pyrit package from PyPI with pip, so every team member runs the same release. Record the exact installed version in your team runbook, because the shell commands and scenario names depend on it. Done means the package imports cleanly and the pyrit_shell command starts, even if it has no targets configured yet. Confirm the version you install against the PyRIT releases page before you pin it.

  3. Place credentials in the environment file

    The engineer creates ~/.pyrit/.env on the workstation and adds the keys needed for the first target, such as the API key or endpoint values for the model being tested. Keep this file out of shared folders, version control and job logs, and set file permissions so only the operator can read it. Done means the file exists at that path, contains only the credentials for the chosen target, and is not included in any repository or screenshot the team shares.

  4. Set shared settings in the configuration file

    The engineer creates ~/.pyrit/.pyrit_conf to hold settings that should be consistent across sessions, such as default memory location and other options the team agrees on. Settings here are separate from secrets, so the team can review this file without exposing credentials. Done means the file parses without errors when the shell starts and the team has a written note of each setting and why it was chosen.

  5. Register at least one target

    The engineer registers the model or application endpoint that the session will test, using the target configuration the PyRIT documentation describes for that target type. Use a test deployment or a non-production endpoint for the first session, and confirm that the target's credentials in ~/.pyrit/.env are the ones intended. Done means the target is registered and appears when the operator runs list-targets inside pyrit_shell.

  6. Confirm targets and scenarios are listed

    Inside pyrit_shell, the operator runs list-targets and list-scenarios and compares the output with the target and scenario names the team expects. A missing target usually points to a configuration or credential problem, and a missing scenario usually points to a version mismatch. Done means both lists match the team's expected names, and the operator saves the output to the session notes so later sessions can detect drift.

  7. Run a small scenario

    The operator runs one scenario against the registered target with run, using a deliberately small dataset or objective count so the first session is quick to review. Keep the first run narrow so any configuration issue is easy to isolate. Done means the run completes or stops with a readable error, and the operator notes the scenario name, target and dataset size used.

  8. Review scenario history

    The operator runs scenario-history to confirm the completed run is recorded with its target and scenario name, then runs scenario-results on that run to check that results were stored. This closes the setup, because the team can now trust that later runs are saved and can be reviewed. Done means the first run appears in history with a result set, and the team agrees which run identifiers will be used as the baseline for the next session.

How a shell session moves from operator to target and memory

A session starts with the operator typing commands into the pyrit_shell REPL on their own workstation. The shell resolves registered targets and converters, then runs each scenario against the target, with converters attached to a single technique using the technique:converter.name syntax. Every conversation and result is written to PyRIT memory, which uses SQLite or Azure SQL, and scenario-history and scenario-results read back from that same store. When a remote CoPyRIT backend is used, check which side holds the memory and which credentials cross the boundary.

Operator, shell, targets, converters and memory, with an optional remote CoPyRIT backend.

Connecting pyrit_shell to a remote CoPyRIT backend

Before you point pyrit_shell at a remote backend, decide three things: where the backend runs, who can reach it, and whose memory holds the results. CoPyRIT is PyRIT's web GUI for human-led red teaming and team collaboration, and the shell can be connected to a remote CoPyRIT backend so that scenario runs are executed and recorded there rather than only on the laptop or runner that started them. That changes the risk profile. A backend on a shared server holds conversations, objectives and scores from every tester who uses it, so the hosting location, network path and authentication model are part of the assessment design, not an afterthought.

Work through the decisions in order. First, choose the hosting model for the backend: a developer machine, a team server inside your network, or a cloud deployment. Second, decide who may reach it and through what identity, since a shared backend without per-user access control lets one tester read another's attack history. Third, decide which memory store holds the results. PyRIT memory uses SQLite or Azure SQL, and the choice determines retention, backup, access logging and who can export conversations later. Record these decisions in the test plan so that the scenario history a tester sees later can be traced to a known store and a known set of users.

The exact connection steps, including the command or setting that points the shell at the backend, the authentication flow and any required configuration keys, must be confirmed in the PyRIT documentation for the version you install. Commands and options have changed across PyRIT releases, so do not copy them from older posts or from this page. Confirm them against the PyRIT Shell documentation and the CoPyRIT deployment guidance for your version, then test the connection against a non-sensitive objective before running any scenario that carries real harm content.

Security and operational considerations for shell sessions

A shell session can hold credentials, reach live AI targets and write attack transcripts to memory. The cards below cover the decisions a team should settle before pyrit_shell goes beyond one operator's laptop, and the checks to run once it does.

Credential handling on shared machines

PyRIT reads target credentials from ~/.pyrit/.env, so anyone with access to that home directory can use the keys in it. On a shared operator machine, give each operator a separate account, restrict file permissions on the .env file, and confirm that shell history and terminal recordings do not capture keys typed inline. Ask whether your secrets store can supply these values at run time instead of storing them on disk.

PyRIT Shell docs

Who can attack which target

A shell session can run any registered target that the local configuration exposes, including production endpoints. Decide which targets each operator may use and keep non-production and production registrations separate. Review the target list at the start of each session with list-targets, and treat a target that appears unexpectedly as a stop signal for the session.

Retention and access for scenario results

Scenario history and results are stored in PyRIT memory, which uses SQLite or Azure SQL. Repeated runs accumulate prompts and model responses that may contain harmful content, so decide how long that memory is kept, where the database file lives and who can open it. Confirm the retention period with your compliance team before the first shared run.

Audit trail of commands run

Shell commands such as run and scenario-history show who ran what, but only if your team keeps a record of them. Decide whether to log the operator identity, the scenario name, the target and the timestamp for each run, and where that log is stored. Check whether the memory records alone give you enough to reconstruct a session.

Keeping attack content out of shared logs

Attack prompts and model replies are sensitive. Terminal output, CI job logs and chat notifications can copy them far beyond the people who should read them. Set output destinations deliberately, avoid pasting scenario results into team channels, and redact transcripts before they leave the controlled store. Confirm this rule with anyone who receives shell output.

Reporting PyRIT vulnerabilities privately

If you find a flaw in PyRIT itself, such as a way the shell exposes credentials, report it privately through the Microsoft Security Response Center under the project's security policy instead of opening a public issue. Keep reproduction details out of tickets and chat until the report is triaged. Check the project's README for the current reporting route before you need it.

PyRIT on GitHub

Questions teams ask before running pyrit_shell

Can our team run pyrit_shell ourselves without a partner?

Yes, a team with Python experience and access to the AI systems it wants to test can install PyRIT with pip and start pyrit_shell. PyPI supports Python 3.10 up to but not including 3.15, and the documentation recommends Python 3.13. The shell gives you list-scenarios, list-targets, list-converters, run, scenario-history and scenario-results, so the day-to-day loop is learnable quickly. The harder part is deciding what to test, wiring the target correctly and interpreting results, which is where most teams need time or outside help.

What actually drives the effort of a PyRIT shell setup?

Four things dominate the work:

  • Target integration: a hosted model with a supported client is simple, while a custom HTTP, WebSocket or browser-driven chat app needs request mapping and session handling.
  • Scenario choice: each packaged scenario covers different harms and techniques, so the objectives and dataset you pick set the size of the run.
  • Scoring setup: deciding whether an attack worked needs a scorer you trust, whether an LLM judge, Azure AI Content Safety or custom logic.
  • Memory design: PyRIT stores conversations and results in SQLite or Azure SQL, so you need to decide where that database lives and who can read it.
What does our team need to provide before the work starts?

You need access to the target, meaning an endpoint or account the test is allowed to hit, and a named owner who accepts the test scope. Plan for model budgets too, because every converter, adversarial model and scorer call costs tokens or API requests, and repeated scenario runs multiply that spend. Credentials are read from ~/.pyrit/.env and settings from ~/.pyrit/.pyrit_conf, so someone must own how those files are stored. Your team should also own the results, including deciding who reviews findings and where memory records are kept.

How long does a first pyrit_shell session take to set up?

The time depends on the target and on how much of the environment is already in place. A team with a model endpoint, a Python environment and a clear test objective can get a first session running in a short working period, while a custom application target, a scoring design and a shared memory store take longer. No fixed duration applies to every environment, so ask for a written plan that lists each step, its owner and the checkpoint where the first run is reviewed.

When is outside help worth paying for with pyrit_shell?

Outside help makes sense when the target is hard to reach, when results will be used as compliance evidence, or when no one on the team has time to own the test design. DeployOpen plans, implements and hardens self-hosted platforms in infrastructure you control, and runs security testing of AI systems and agents, so a partner can handle target wiring, scenario selection and review of results. Most engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts, and a quote follows from that written scope.

Does pyrit_shell replace CoPyRIT for our red teaming?

No. pyrit_shell is a command-line REPL for running packaged scenarios repeatedly, attaching converters to techniques and reading scenario history and results. CoPyRIT is the web GUI for human-led red teaming and team collaboration. The shell can also connect to a remote CoPyRIT backend, so the two work together. Choose the shell for scripted, repeatable runs by engineers and CoPyRIT when testers need a shared interface to work through attacks by hand.

Who is responsible for PyRIT security issues found during setup?

Vulnerabilities in PyRIT itself are reported privately through the Microsoft Security Response Center under the project's security policy, so do not post them in public issues. Findings about your own AI system are your responsibility to triage and fix. Confirm with your security team how results are stored, since memory may contain harmful prompts and model outputs, and set access controls on the SQLite or Azure SQL store before the first run.

How DeployOpen scopes and supports PyRIT shell sessions

DeployOpen plans and runs pyrit_shell red teaming sessions inside your own environment, so the targets, converters and scenario history stay under your control. The work is agreed as a fixed scope with written deliverables, and ongoing support is available as a retainer for teams that keep testing after handover.

How we scope

  • Confirm which registered targets the shell sessions will reach and where each one runs.
  • List the scenarios and techniques your team will run repeatedly, and which converters may attach to each technique.
  • Agree who operates the shell, who reviews results, and where scenario history and results are stored.

How we build

  • Configure the PyRIT environment and target registrations in your infrastructure, with credentials kept out of shared files.
  • Verify each scenario runs from the shell with a small objective set before the team relies on it.
  • Test the converter-to-technique pairings and confirm scenario history and results can be inspected after each run.

How we hand over

  • Document the shell session workflow, including commands, typical run sequences and how to read scenario results.
  • Record the target connection setup, including how to connect to a remote CoPyRIT backend if your team uses one.
  • Walk your operators through the session workflow and leave a checklist for starting, reviewing and closing sessions.

How we support

  • Keep PyRIT and scenario configuration current as new releases arrive, with changes agreed in writing first.
  • Retest shell workflows after target, converter or environment changes to confirm results stay comparable.
  • Provide ongoing support and continuous testing as a retainer, scoped separately from the initial engagement.

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.