Red teaming LLM agents with promptfoo

How to plan a promptfoo red team for a tool-using agent: privilege escalation, tool and API manipulation, multi-stage attack chains, and combining end-to-end, component and trace-based tests.

On this page

Why red teaming an LLM agent differs from red teaming a chatbot

An agent that can call tools, read data and act for users is being approved for use, and promptfoo can probe its authorization, tool use and multi-step behavior before rollout, but the test design must match the permissions the agent actually holds. A chatbot that only produces text can leak or say something harmful. An agent with credentials can read records it should not see, call functions above the user's role or take actions in other systems. The risk frame for that is OWASP LLM03 Excessive Agency, which the 2026 edition of the OWASP Top 10 for LLM Applications moved up to the third position, and the OWASP Top 10 for Agentic Applications for 2026, especially ASI02 Tool Misuse and ASI03 Identity and Privilege Abuse. A useful test therefore starts from the agent's tool list, identities and scopes, not from a generic list of attack prompts.

The practical consequence is that a prompt-only probe tells you little. If the agent runs under a service account with broad read access, a refusal in the chat window does not show that the account cannot be used to fetch other users' data through a tool. Before you configure any plugin, confirm which tools the agent exposes, which identity each tool call uses, whether the user's token is passed through or replaced, and which actions need human approval. Those answers decide which tests are meaningful, and they belong to the design of the red team, not to a later review. Ask the team that owns the agent for this inventory in writing.

promptfoo is open source under the MIT license and runs locally, so evaluations execute on your machine and talk directly with the model and application under test. That matters for agent work, where the test traffic carries tool calls, sample records and sometimes credentials. Confirm where the agent's logs and traces will be stored during testing, who can read them, and whether the target environment is a staging copy with synthetic data. The rest of this page covers how to build the tests from that inventory.

Which agent attack classes to test first

Agent risk starts with what the agent can reach, not with the model's wording. The cards below map six OWASP agentic risk classes to the tools, identities and data your agent holds, so you can decide which classes your promptfoo red team must cover. No single scan covers all of them, and each card lists what you must confirm before testing.

Privilege escalation through identity abuse

Under ASI03 (Identity and Privilege Abuse), an agent can act with credentials broader than the requesting user should have. Confirm which identity each tool call uses, whether it is the user's own token or a shared service account, and whether scopes are minimized per tool. Test whether the agent can be steered into reading or changing records above the user's role. Treat a passing scan as evidence for the cases you tested, not for every role boundary.

OWASP agentic Top 10

Tool and API manipulation

ASI02 (Tool Misuse) covers an agent calling a legitimate tool with harmful arguments, such as a broad query filter, an unexpected recipient or a parameter outside the intended range. Inventory every tool, its arguments and the side effects each one triggers. Confirm whether the tool layer validates arguments independently of the model. Your test should attempt out-of-policy parameters, not only forbidden requests phrased in natural language.

Goal hijack through documents and tool output

ASI01 (Agent Goal Hijack) describes instructions arriving through retrieved documents, web pages, emails or tool responses that redirect the agent's task. List every data source the agent reads and mark which ones a third party can write to. Confirm that tool output is treated as data, not as instructions. Plant injected text in each untrusted source and check whether the agent changes its actions.

Memory and context poisoning

ASI06 (Memory and Context Poisoning) concerns instructions stored in long-term memory, summaries or shared context that influence later sessions. Confirm what the agent writes to memory, who can trigger those writes, and how entries expire or get reviewed. Test whether a poisoned entry written in one session changes behavior in a separate session. Ask your vendor or team to document how memory is scoped per user.

Cascading failures across agents

ASI08 (Cascading Failures) describes a fault or malicious output in one agent spreading through orchestration into other agents and tools. Map which agents call which, what each downstream agent trusts from upstream, and where a retry loop or fan-out could amplify an error. Confirm whether there are rate limits and kill switches per agent. Multi-step attack chains like this need end-to-end tests, not single-prompt checks.

Unexpected code execution

ASI05 (Unexpected Code Execution) covers an agent running code or shell commands it was not meant to run, often through a code interpreter, a build step or a generated script. Confirm where execution happens, what file system and network access that environment has, and which secrets it can read. Test whether crafted inputs can reach an interpreter or a command tool. Verify sandbox boundaries directly, since a model refusal is not a sandbox.

End-to-end, component and trace-based tests

End-to-end tests send prompts to the agent through the same interface a user or integration would use, such as its chat endpoint, web front end or API. The agent runs its real prompt, tools, permissions and integrations, so a pass or fail reflects the whole system as deployed. The trade-off is that a failure rarely tells you which layer caused it, and each run depends on live downstream services, which can make results slower and less repeatable.

  • What it needs: an HTTP, WebSocket or Python provider that wraps the deployed agent and returns its final response in a form promptfoo can grade.
  • Test identities: dedicated test users with the roles you want to probe, so authorization results match production behavior.
  • Side effects: write actions may reach real systems, so decide whether to use a staging tenant or sandboxed tool backends.
  • Strength: it catches failures that only appear when prompts, memory, permissions and tools interact.
  • Limit: it shows that an attack succeeded or failed, but not the path the agent took to get there.

Before running, confirm which tool actions the test environment can reach and who approves any test that changes data.

Configuration options and when each fits

This table compares the promptfoo configuration choices for a red team against a tool-using agent: how the target is connected, which plugins and strategies to enable, how test identities are set up and how large the scan should be. Read each row for the condition that makes an option fit and the item to confirm before you commit to it.

DecisionOption and when it fitsWhat to confirm
Target typeHTTP endpoint: the agent already runs as a service and its tool calls happen server-side, so the test exercises the same path users reach.The endpoint returns tool calls and identifiers in a form promptfoo can grade, not only final text.
Target typePython provider: you need to call the agent code directly, inject a test identity per call or read intermediate state without running a server.Your Python runtime matches the version promptfoo supports on your Node.js and Python setup, and test credentials stay out of shared config.
Target typeFramework wrapper (for example, a LangGraph, CrewAI or OpenAI Agents SDK wrapper): your agent is built on one of these and you want graph or trace detail in the results.The wrapper keeps tool and handoff traces that assertions can read, and the framework version is pinned in your test environment.
Plugins for agency and authorizationExcessive agency and tool discovery plugins: fit when the main question is whether the agent claims or takes actions beyond its role.The agent's tool list is documented so you know which actions a pass or fail should be judged against.
Plugins for agency and authorizationAuthorization plugins for object-level and function-level access: fit when the agent reads records or calls functions on behalf of a user.Your test identities map to real roles in the target system, and the access model you expect is written down before the scan.
Plugins for agency and authorizationTool and API misuse checks: fit when the agent passes model-generated parameters into APIs without a second check.Which APIs can cause writes, payments or deletions, so you can restrict the test to a sandbox or read-only account.
Strategy for multi-turn attacksSingle-turn strategies only: fit for a first scan of a stateless agent where each request stands alone.Whether the agent keeps any state between requests. If it does, single-turn results will miss persistence and chaining.
Strategy for multi-turn attacksMulti-stage or stateful strategies: fit when the agent holds a session, memory or prior tool results that a later step can misuse.Session handling in the target, so each attack chain runs in a session the team can reset and reproduce.
Test identities and rolesSeparate low-privilege and high-privilege test accounts: fit whenever authorization is part of the question, because a single admin identity hides the failures.Who issues the test accounts, what data they can reach and that tokens are scoped to the target, not reused from other services.
Scan size against the Community editionSmall scans with a fixed plugin list: fit for early runs, debugging a provider connection or checking a single change in CI.The monthly probe budget in the Community edition (10k probes per month, per the promptfoo pricing page) and how many probes a run uses.
Scan size against the Community editionLarger scans across all agency and authorization plugins: fit before a release or a security review, when coverage matters more than speed.Whether the planned run fits the remaining monthly probes, and whether you need Enterprise features for team sharing or access control.

Setting up the agent red team in sequence

The sequence turns an agent into a repeatable promptfoo test target, so each run checks what the agent may do, what it actually did, and whether a fix held. Each step produces an artifact the next step depends on, and the order keeps a failed check from being hidden by a later one.

  1. Define the agent's purpose and permitted tools

    The product owner and the engineer who built the agent write down its job, the tools it may call, the data each tool can read or change, and the actions that need human approval. This list is the policy the red team tests against, so a finding can be judged as a breach of intent rather than a matter of opinion. The step is done when every tool has a named owner, an allowed action set, and a stated reason for any write access. Check: each tool in the agent's configuration appears on the list, and any tool missing from the list is flagged for review before testing starts.

  2. Create least-privilege test identities

    The platform team creates two or more test users in the system the agent calls, with the smallest roles the permitted-tools list allows, plus one account with elevated rights for comparison. Tokens for these accounts are issued through the normal identity flow and kept out of prompts and repositories. Authorization tests need a second user whose records the first user must not reach. The step is done when each identity can perform its intended actions and fails the actions it should not have. Check: a direct call with each test token returns the expected allow or deny result before the agent is involved.

  3. Wrap the agent as a promptfoo target

    The engineer exposes the agent behind an endpoint or Python provider that promptfoo can call, and maps each test identity to a session the agent uses. The wrapper should return the final answer together with the tool calls and arguments, since trace-based checks need them. Confirm the provider configuration in the promptfoo documentation for the agent's framework and language. The step is done when a single prompt returns a response and a record of tool calls. Check: the target returns tool calls in the expected format, with tool name, arguments and result for each call, and the identity used for the request matches the test identity.

  4. Write end-to-end and component tests

    The engineer writes ordinary promptfoo tests in YAML in two layers. End-to-end tests send a user request through the full agent and check the outcome, such as whether a refund was refused for a user without rights. Component tests call one tool or one prompt in isolation with fixed inputs, which isolates whether a failure comes from the model's choice or from the tool's own permission check. The step is done when both layers pass on the unmodified agent for the permitted behavior. Check: the baseline suite passes with the expected results recorded, so later failures can be read as regressions rather than gaps in the test design.

  5. Add trace assertions

    The engineer adds assertions over the recorded trace so that tests check the path the agent took, not only its final text. Typical checks confirm that a write tool was never called for a read-only identity, that a privileged tool was preceded by an approval step, and that arguments contained no identifiers from another user. Trace data must be captured by the wrapper from step three. The step is done when each trace assertion fails on a deliberately broken test case and passes on the intended behavior. Check: a seeded violation, such as a call with another user's ID, is caught by the trace assertion and reported with the tool call that caused it.

  6. Run the red team scan

    The security team configures the promptfoo red team with the agent's purpose from step one, the target from step three and the plugins and strategies that match the agent's risks, such as authorization, tool misuse, memory and indirect injection. They run the scan against the test identities and review every failure with the owners of the affected tools. The OWASP Top 10 for Agentic Applications, which lists agent goal hijack, tool misuse and identity and privilege abuse, is a useful reference for choosing categories. The step is done when each finding has a severity, a reproducing trace and an owner. Check: each failing probe links to a stored trace that shows the tool call or output that violated policy.

  7. Retest after fixes and keep the suite

    After the owners change tool permissions, prompts or guardrails, the engineer reruns the component tests, trace assertions and red team scan against the same identities, then adds a regression test for every confirmed finding. Fixes are only accepted when the original failing trace now passes, and the scan results are kept with the version of the agent that produced them. The step is done when the agreed findings are closed, the regression tests run in the normal pipeline, and the previous run is compared with the new one. Check: the retest shows the original reproducing trace now produces a denied or safe result, and no previously passing test has started to fail.

How the test layers and trust boundaries fit together

The run starts at the promptfoo CLI, which sends attack probes to a wrapper around the agent under test. The agent then calls tools and APIs across a trust boundary, where identity and permission checks decide what the test identity can reach. Traces and tool-call logs come back to promptfoo for grading. Check that the test identity cannot touch production data, and that the logs capture every tool call the grader needs.

Test traffic, permission checks and trace return paths for a tool-using agent.

Testing multi-stage attack chains

A single-turn probe asks whether one malicious input gets a bad response. It does not show whether an attack can cross several steps. The chain that matters for a tool-using agent often starts with an injected instruction inside a document the agent reads, which leads the agent to call a tool with elevated rights, which then moves data out through another tool or an outbound request. Each step may look acceptable on its own, so a probe that only checks the first message will pass while the chain succeeds. Plan the red team around the chain itself, not only around individual payloads.

To reproduce the chain, combine multi-turn strategies with sequenced test cases. Multi-turn strategies in the promptfoo red teaming documentation send follow-up messages that adapt to the agent's replies, so the test can push toward a privileged action after the agent has accepted earlier steps. Sequenced test cases give you a fixed order when you want repeatable evidence, for example a document that is planted in a test knowledge base, a user request that triggers reading it, and a check on whether a later tool call happens. Confirm which strategies and multi-turn options your promptfoo version supports and how they are configured before you write the plan, since availability changes between releases. Check the current version details in the promptfoo red teaming documentation.

Grading depends on what the agent exposes. The grader needs the sequence of tool calls, with tool names, arguments and results, and enough session state to show which identity and permissions were active at each step. If the agent returns only a final answer, a chain that ends in a silent exfiltration will look like a refusal. Ask the agent team to confirm that tool call logs and session identifiers are returned to the test target or written to a trace you can read, and that the trace records the user identity used for each call. Decide before the first run which step counts as the failure point, and record that choice in the test plan so results can be compared after fixes.

Security and operational considerations for the test environment

A red team sends adversarial inputs at a system that can take real actions, so the test environment itself carries risk. The cards below cover the data, credentials and tools the agent can reach, where prompts and responses travel, how the self-hosted server is limited, and how findings should be reviewed.

Use sandboxed test data

Point the red team at a copy of the agent's data stores, such as a staging mailbox, a seeded ticket queue or a sample document corpus, rather than production records. Attack payloads often ask the agent to reveal or export whatever it can read, so the reachable data should be fake or de-identified. Confirm that the test dataset contains no customer, employee or regulated records before the first scan.

Use non-production credentials

Give the agent test identities and API keys scoped to the staging environment, and keep production secrets out of its configuration and environment variables. Tool calls made under a real service account can change live systems, and a successful injection then runs with that account's rights. Ask the team that owns each credential to confirm the scope in writing.

Stop destructive tool calls

Deploy the agent's tools against stub or read-only backends, or put a dry-run layer in front of anything that sends, deletes, transfers or deploys. Red team payloads are designed to make the agent call tools it should not, so a sandbox that only hides production data is not enough. Keep a log of every tool call the test triggers so that any unexpected side effect can be traced.

Confirm where prompts go

promptfoo runs on your machine and talks directly with the LLM, so test prompts and the model's responses go to whichever provider the configuration names. For a hosted model, that means the test corpus, including any sample sensitive data, leaves your network. Check the provider's data handling terms, and if the data must stay inside your boundary, point the configuration at a self-hosted model instead.

promptfoo introduction

Limit the self-hosted server

The self-hosted promptfoo app stores data in a local SQLite database that cannot be shared across replicas, and it has no RBAC, horizontal scaling, built-in authentication or SSO. The project does not recommend it for production use. Run it for a single team on a restricted network, place it behind your own access control, and plan for Enterprise or On-Premise if several teams need shared, access-controlled results.

Self-hosting docs

Review findings with least privilege

The MCP security guidance asks clients to show the exact command before a local server runs, to require explicit user approval, and to run servers sandboxed with minimal default privileges. Apply the same rules to the test harness: approve each MCP server the red team connects to, run it with the fewest permissions it needs, and limit who can read the traces and transcripts. Those records can contain the attack payloads and any sensitive data the agent returned.

MCP security best practices

Questions teams ask before running an agent red team

What drives the effort of an agent red team?

The main drivers are the number of tools the agent can call, the number of identities it acts under, the agent framework it is built on, and whether the application exposes traces that show each tool call. Every tool adds argument variations, permission boundaries and failure modes to test. Every identity or role adds a second or third authorization matrix to check. Framework choice affects how much wrapping is needed before promptfoo can call the agent, and trace support decides whether a test can assert on which tools ran, not just on the final text. Ask for a written count of tools, roles, integrations and environments before you compare quotes.

Can our internal team run an agent red team without a partner?

Yes, if the team has engineers who can run promptfoo, wrap the agent behind a provider, and read tool-call traces, and if someone owns the security judgment on what a failure means. The open-source CLI runs locally and talks directly with the model under test, so the work is mostly planning and configuration. The harder parts are building realistic test identities, deciding which privilege escalation paths matter for your business, and reproducing and fixing findings across several teams. Many organizations split the work: their own team runs routine scans, and an outside team handles the initial scope, the deeper chains and the retest.

What does the work need from our side?

Plan to provide test accounts at each privilege level the agent supports, documentation for every tool and API it can call, and a staging environment that connects to non-production data and sandboxed downstream systems. Test accounts let the assessment check whether a low-privilege user can reach records or functions above their role. Tool documentation lists the parameters, permissions and side effects of each call, which shortens the time needed to design attack chains. A staging environment protects production data and lets tests change state without consequences. Also name a technical contact who can answer questions about the agent's configuration and traces during the work.

Does promptfoo cost money for an agent red team?

The promptfoo software is MIT licensed, and the Community edition is free. It includes red teaming with 10k probes per month and community support, which is enough for many agent assessments. The Enterprise edition, which adds team sharing, SSO, custom roles, continuous monitoring and priority support with SLAs, is sold at custom pricing, and On-Premise runs that functionality in your infrastructure with a dedicated deployment engineer. Separate from licensing, you pay for model inference during test runs, for the time of the people who plan and read results, and for any outside services you engage. Ask any provider to separate tool costs from labor costs in the quote.

How long does an agent red team take?

No duration has been fixed for this page, so confirm the timeline against the written scope rather than a generic figure. The schedule depends mainly on the number of tools and identities, how much wrapping the agent needs to run under promptfoo, how many multi-stage attack chains are in scope, and how quickly the staging environment and test accounts are ready. Fixes also add time, because the team that owns each tool has to change code or policy before a retest can confirm the result. Ask for milestones covering setup, test execution, findings review and retest, and check which of those depend on your team's availability.

How are findings retested after fixes?

Each finding should be recorded with the exact prompt or sequence, the identity used, the tools called, the trace evidence and the expected secure behavior. After a fix, the same test cases are rerun against the changed agent, and new variants are added to check that the fix did not only block one phrasing. Retests should also cover adjacent paths, such as the same tool reached through a different identity or a different document source. Confirm in the scope how many retest rounds are included, who runs them, and whether the results are delivered as an updated findings report. Keep the passing tests in CI so regressions show up when the agent changes.

Which frameworks and standards should the test plan reference?

Plan the test categories against the OWASP Top 10 for Agentic Applications for 2026, which lists risks such as ASI02 Tool Misuse and ASI03 Identity and Privilege Abuse, and against LLM03 Excessive Agency in the OWASP Top 10 for LLM Applications 2026. Map multi-stage chains to MITRE ATLAS techniques where they fit. These references give the test plan a shared vocabulary for reporting. They do not certify the agent. Ask the provider to show which categories the scope covers and which are excluded, so the final report is clear about what was tested.

How the work is scoped and delivered

DeployOpen agrees the scope, deliverables and timeline for a promptfoo red team of a tool-using agent in writing before any testing starts. For an agent, the scope has to name the things that define its attack surface: the model and system prompt under test, each tool and API it can call, the identities it runs as, the memory or session store it writes to, and any MCP servers it connects to. A scope that lists only the chat endpoint will miss most of the authorization risk. Ask for the list of tools with their permission levels, the test identities that will be used for user and admin roles, and the attack categories in scope, such as privilege escalation, tool manipulation and multi-stage chains.

Testing runs in a staging environment or a client-controlled environment that mirrors production tool permissions. Tests that call real business systems, send messages or change records need sandbox accounts, synthetic data and a clear rule for what the agent may write. Confirm with your own team which credentials the promptfoo target will hold, where the promptfoo run and its results are stored, and whether hosted model calls send prompts outside your boundary. Because the community edition runs locally, the main data flows to check are the target's own tool calls and the model provider's API.

Findings are delivered as a written report with severity, reproduction steps, the relevant traces, the fix recommended for each issue and a retest of the fixed behavior. DeployOpen performs security testing for AI agents and delivers that evidence, but it does not issue audit reports, attestations or certifications. If a compliance assessor needs an independent opinion on the agent's controls, that work belongs to an independent auditor or certification body, and the test report is one of the inputs they may review.

How DeployOpen runs agent red teams

DeployOpen plans and runs promptfoo red teams for tool-using agents inside the infrastructure you control, so the agent, its tools and its test identities stay in your environment. Each engagement is fixed-scope, with the agents, tools, identities and attack categories agreed in writing before testing starts.

How we scope

  • Written scope names the agent, its tools, MCP servers and the identities each test role may use
  • Attack categories are agreed up front, covering privilege escalation, tool misuse and multi-stage chains
  • Scope states which tests run end to end, which target components directly, and which rely on trace assertions
  • Test data handling, hosted model use and the authorization model under test are confirmed before work starts

How we build

  • Promptfoo configuration is built against the agent's real endpoint, with test identities set up at each privilege level
  • Tool and API manipulation cases are written against your tool schemas and permission boundaries
  • Trace-based assertions are wired so each finding shows which tool calls and arguments the agent made
  • Runs are reproducible, with fixed configuration files and recorded results for each scan

How we hand over

  • Findings report lists each authorization failure, injected tool call and attack chain with its evidence
  • Each finding includes a recommended fix, such as tighter tool scopes, token handling or approval steps
  • Configuration files, test identities and run instructions are delivered for your team to rerun
  • Retest of fixed findings is included in the agreed scope and documented against the original result

How we support

  • Ongoing support, upgrades and continuous testing are available as a retainer after handover
  • Retainers can cover re-running scans when agent tools, prompts or MCP servers change
  • Promptfoo upgrades and configuration changes are handled under the agreed support terms
  • Your team can confirm current promptfoo release requirements with the project before each upgrade

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.