Evaluating OpenAI Agents SDK applications with promptfoo: what it covers and when you need it
If your team runs a Python application built on the openai-agents SDK and needs repeatable evaluation and red teaming before each release, promptfoo is one tool to consider for that job. promptfoo documents evaluating the Python SDK with tracing, SandboxAgent workflows, trace assertions and agent red teams, so the testing can cover both what the agent answers and how it got there, including the tool calls and handoffs it made along the way. The question for your team is whether those checks should run on every change, which parts of the agent need coverage first, and who owns the results.
promptfoo is an open-source tool licensed under the MIT license. It runs on your machine, where evals talk directly with the model provider you configure, and it can be used as a CLI, as a library or inside CI/CD pipelines. That means the test harness can sit next to the agent code in your repository and run the same way on a developer laptop and in a build job. Before you adopt it for an agent, confirm which model provider, sandbox settings and tracing setup your application uses, because those determine what the test run sends out and what evidence it can collect.
This section describes scope and fit only. It does not cover how to build or improve the agent itself, which is agent engineering and sits outside this page. It also does not claim that promptfoo results satisfy any audit or regulatory requirement. Testing supplies evidence about the agent's behavior, and your security, compliance and engineering leads decide what that evidence is enough for. The sections that follow walk through setup, trace assertions and red team sessions in order.
Which testing mode fits which agent question
This table compares the four ways to test an OpenAI Agents SDK application with promptfoo: functional evals, trace assertions, SandboxAgent workflow tests and agent red teams. Read each row as the question a mode answers and what your team must provide before it can run. Most teams start with functional evals and add the other modes as the agent gains tools, state and sandboxed execution.
| Testing mode | Question it answers | What the team needs |
|---|---|---|
| Functional eval with output assertions | Does the final answer meet the expected behavior for known inputs? | Representative test cases, expected outputs or graded criteria, and a provider wrapping the agent entry point |
| Trace assertions | Did the agent take the expected path, such as calling the right tool with the right arguments? | Tracing enabled in the openai-agents run, and agreed names for the tools and handoffs the assertions check |
| SandboxAgent workflow tests | Does a sandboxed multi-step workflow complete and stay inside its intended file and command boundaries? | A sandbox configuration that matches production, test fixtures in the workspace, and a clear definition of allowed actions |
| Agent red team | Can an adversary steer the agent into unauthorized tool use, data exposure or harmful actions? | Scope of tools and data the agent can reach, test identities with known permissions, and an owner to review findings |
| Stateful red team sessions | Does a manipulation in one turn persist and change behavior in later turns or sessions? | A way to keep conversation or memory state between attempts, and an agent that exposes what it has stored |
| Cost and run time | How expensive and slow does each mode become as cases and probes grow? | Model access budget, a decision on which runs happen on every change and which run on a schedule |
| Evidence for review | What artifacts can the team show to security or compliance reviewers? | Stored eval results, trace records and red team reports, kept under the team's own retention rules |
What sandboxed agent workflows change in testing
A SandboxAgent workflow runs tools against files, processes and services that persist between calls, so a test that passes once can leak state into the next. The cards below cover what to reset, where side effects land and what to confirm about the sandbox boundary before trusting results from an agent red team.
Reset state between test cases
Sandbox files, working directories, environment variables and cached tool results can carry over from one promptfoo test into the next. A later case may pass because an earlier one left a file behind, or fail for the same reason. Define a reset step for each test, such as recreating the workspace from a clean snapshot, and confirm that each run starts from the same known state.
Use disposable test data
Seed the sandbox with synthetic customer records, tokens and documents that look like production data but are not. Keep fixtures in version control so every run uses the same inputs. If an injection attempt can read or change this data, the result still tells you what the agent would do, without exposing anything real.
Contain tool side effects
Tools that write files, send messages, call APIs or run shell commands need a boundary that stops changes from reaching shared systems. Point outbound calls at mock services or sandbox accounts, and record each side effect as trace evidence. Review which tools are exposed to red team runs, since a tool left connected to a live system turns a test into a real action.
Confirm the sandbox boundary
Before relying on results, confirm what the sandbox can reach: network egress, mounted volumes, credentials injected into the environment and the host user it runs as. The OpenAI Agents SDK documentation and your own container or VM configuration decide these limits, not the test config alone. Write the answers down and retest after any change to the runtime.
Separate runs from one another
Run each red team session in its own sandbox instance rather than sharing one across attacks. Parallel runs that share a workspace can interfere with each other, and a memory or file change from one attack can look like a result of another. Ask your team how instances are created, named and destroyed, and check that teardown runs even when a test fails.
How to set up promptfoo for an openai-agents Python app
This sequence takes a Python openai-agents application from a installed promptfoo CLI to a reviewed set of functional, trace-based and red team results. Each step ends with a check so the next step builds on verified output.
Install promptfoo and confirm the Node.js version
The engineer installing promptfoo checks that the machine runs Node.js 22.22.0 or newer, the minimum version for the npm release 0.124.1 described in the pillar facts. They then install the promptfoo CLI from npm and run the version command. The step is done when the CLI reports a version and runs without errors on the machine or CI runner that will execute the evaluations. Confirm the current package version on the npm registry before you pin it in your project.
Write a Python provider that wraps the agent entry point
The team writes a small Python provider file that imports the openai-agents application and exposes its entry point to promptfoo. The provider receives the prompt from promptfoo, runs the agent, and returns the final output as a string. Keep the provider thin so tests exercise the same code path as production. Check the wrapper by calling it directly from a shell with one sample prompt and confirming it returns the agent's answer without needing the promptfoo runner.
Define functional tests in a promptfoo config
Next, the team writes a promptfoo configuration file that points to the Python provider and lists a first set of functional test cases. Each case gives an input and a few assertions on the expected behavior, such as required content, refusal of out-of-scope requests, or correct tool use described in plain language. Start with a handful of cases that cover core workflows. The step is done when the evaluation runs end to end and produces a pass or fail result for every case.
Enable tracing and confirm a trace is captured
The team turns on tracing for the openai-agents run so promptfoo can see the agent's steps, tool calls and handoffs, following the tracing setup in the promptfoo guide for the Python SDK. Run one test case and open the result to confirm a trace is attached. Do this before writing any trace assertions. If no trace appears, fix the instrumentation first, because trace assertions will otherwise pass or fail on missing data and give misleading results.
Add trace assertions for tool and step behavior
With a confirmed trace, the team adds trace assertions that check the agent's behavior beyond its final text. Examples include confirming that a required tool was called, that a restricted tool was not called, or that the agent stopped after a set number of steps. Write each assertion against a trace from a known case first, so you can see the trace structure before you rely on it. The step is done when the assertions pass on the cases you expect to succeed and fail on a deliberately broken variant.
Add an agent red team configuration
The security or engineering team adds a red team section to the same configuration, selecting the purpose of the agent, the plugins and strategies that match its tools and data, and the target identity or sandbox setup for sandboxed workflows. Stateful red team sessions need the agent to keep its state between turns, so confirm that with the provider before enabling them. Review the generated attack prompts once by hand to confirm they fit the agent's scope. Confirm the configuration with a dry run before a full scan.
Run the evaluations and review the results
The team runs the functional tests and the red team scan, then reviews the output in the promptfoo report or web view. For each failure, they open the linked trace and the prompt to decide whether the agent, the assertion or the test case is wrong. Record which findings need a fix and which need a clarified test. The step is done when every failure has a recorded decision and the same run can be repeated with the same result on an unchanged build.
Running stateful red team sessions against agent memory and history
A stateful agent can be attacked over several turns, so a single-prompt test misses the risks that matter most. Agents built with the OpenAI Agents SDK may carry conversation history, tool results and remembered facts from one turn to the next, and sometimes from one session to a later one. An attacker can plant an instruction early, let it sit in that state, and trigger it several turns later. Plan your promptfoo red team around multi-turn sessions that keep context between attack turns, so the agent's state is exercised the way it will be in production.
Before you run these tests, decide what the agent must expose so that results can be graded. Promptfoo needs to see more than the final reply. Confirm with the promptfoo docs which outputs your provider can return, such as the messages exchanged, tool calls and their arguments, and any memory or session identifiers the agent writes. Work out with your engineers how each session is keyed, how a fresh session is started for the cross-session check, and how test identities map to the agent's user and session records. Without these, a grader can only judge the last message, and a poisoned memory write goes unnoticed.
Tie each session to two risk areas: memory poisoning and authorization. For memory, check whether an instruction planted in one session changes behavior in a new session under a different identity. For authorization, check whether state from one user's session, such as retrieved records or cached tool results, appears in another user's session. Confirm in the promptfoo documentation which red team plugins and strategies support multi-turn, stateful targets and which need a single-turn setup, since support varies by plugin. Record the session IDs and tool calls for every failing attempt so that the evidence can be reviewed by your security team.
Security and operational considerations for agent test runs
Running promptfoo against an OpenAI Agents SDK application moves prompts, tool outputs and traces between your machine, your application and model endpoints. The cards below cover where that data goes, which credentials and tool permissions a red team needs, how long results live, and how scans behave in pipelines.
Confirm where prompts and traces go
promptfoo runs evals on your machine and talks directly with the LLM, so the model endpoints your agent and your evaluator call are the places prompts, tool arguments and traces may land. List every endpoint the agent uses, including hosted tools and any tracing backend, and confirm which of them receive test payloads. Red team payloads are adversarial by design, so check that none of those endpoints falls outside the data terms your organization has approved.
promptfoo introductionScope test credentials to test identities
Agents usually authenticate to downstream APIs with service accounts or user tokens. Give the evaluation its own test identities with synthetic records, rather than reusing production credentials, so a successful injection cannot reach real customer data. Store those keys in your secrets manager, not in the promptfoo YAML, and rotate them after runs that used broad permissions.
Limit tool permissions during red teams
A red team is only useful if it can reach the tools an attacker would target, so the risk is that it reaches more than that. For each tool the agent exposes, decide whether it should run against a sandbox, a mock or a read-only copy. Sandboxed SandboxAgent workflows help contain file and shell actions, but confirm what the sandbox can write and which network paths it can reach before starting a scan.
Set retention for traces and results
Traces, prompts, model outputs and grading notes can contain sensitive content and test data that looks like production data. Decide where eval output files are written, who can read them, and how long they are kept, and apply the same rule to CI artifacts. The self-hosted server stores data in a local SQLite database, so plan its backups and deletion, and confirm those controls before sharing results across a team.
promptfoo self-hostingRun scans in CI with controlled secrets
Running evals and red team scans in a pipeline makes them repeatable, but pipeline logs and artifacts can expose keys, prompts and findings to more people than a local run. Pass model and tool credentials through protected pipeline variables, restrict which branches can trigger scans that use live endpoints, and review what the job uploads as an artifact. Keep the scan's probe volume in mind, because the Community edition includes 10k probes per month.
promptfoo pricingQuestions teams ask before testing openai-agents apps with promptfoo
Can our internal team test an openai-agents application with promptfoo on its own?
Yes, a team with Python and the agent's source code can wire promptfoo to an openai-agents application, and promptfoo is MIT licensed and runs locally on your machine. The harder part is usually not the tool but the judgment: deciding which agent behaviors matter, building test identities that match your authorization model, and interpreting trace evidence. Teams that have not written agent tests before often start with functional evals and bring in outside help for the red team design and for the authorization and sandbox checks. Ask whether your team has the time to maintain the suite as the agent's tools and prompts change.
What makes the effort for an openai-agents test suite grow?
Effort follows the size of the agent's surface area. The main drivers are:
- The number of tools and how many of them write data or call external systems
- The number of handoffs between agents and how much context each handoff passes
- Whether SandboxAgent workflows run code or file operations that need isolated test environments
- How much state the agent keeps across sessions, since stateful behavior needs multi-turn and memory tests
- How many user roles and data scopes the agent must respect
Each added tool, handoff or stateful path adds test cases, fixtures and trace assertions.
What do we need to provide before testing starts?
Plan to provide four things: an entry point the test harness can call, such as a Python function that runs the agent and returns its output and trace; test identities with the roles and data access your policy defines; model access for the agent and for promptfoo's graders, along with any API keys and rate limits; and a non-production environment with test data and sandbox resources. Access to the tool backends, logs or trace storage is also useful, so reviewers can confirm what the agent actually did. Confirm these items in the written scope before work begins.
How long will an openai-agents testing engagement take?
Duration depends on scope, so ask for a written plan rather than a generic estimate. The plan should list the agents, tools, handoffs, sandboxes and session behaviors in scope, the test identities and environments needed, the red team categories to run, and the deliverables, such as a runnable suite, CI integration and a findings report. Timing shifts with how quickly your team provides the entry point, identities and model access, and with how many findings need fixes and retests. Ask for milestones tied to those inputs.
Do we need promptfoo Community or Enterprise for agent testing?
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. Many teams testing an openai-agents application can start there. Enterprise adds team sharing, teams-based access control and SSO, custom roles, continuous monitoring, a centralized guardrail dashboard and priority support with SLAs, at custom pricing. Consider Enterprise if several teams need shared results, controlled access to test data or centralized reporting. Check the current promptfoo pricing page before deciding.
What does promptfoo not cover for openai-agents applications?
promptfoo tests behavior it can observe, so it does not prove that an agent is secure or compliant. It does not replace review of the tool backends, identity provider, secrets handling or network controls around the agent. Results depend on the test cases, plugins and grading you configure, so untested paths can still fail in production. Trace assertions show what the agent recorded, which is only as complete as the tracing you enable. Compliance frameworks require evidence and controls beyond test runs, and independent auditors and certification bodies make those determinations.
Does DeployOpen run openai-agents testing inside our own infrastructure?
DeployOpen plans and runs security testing for AI agents, including prompt injection, tool and file permissions, data exposure and credential handling, and it delivers a findings report with fixes and a retest. For openai-agents applications, the test harness can run in environments you control, so agent traces and test data stay within your own boundaries. Confirm in the written scope where the harness, traces and results are stored and which model endpoints receive test traffic.
How the test harness, agent and trust boundaries fit together
The run starts on the test machine, where the promptfoo CLI reads the promptfooconfig.yaml file and calls a Python provider. The provider starts the openai-agents run, which executes tools and any sandboxed workspace inside the agent environment, and sends model requests to an external model endpoint. Traces come back to the harness, which applies trace assertions and writes results to local storage. Check which side of each boundary holds the credentials, tool permissions and test data, and confirm what leaves the agent environment in each request.
Test harness, agent environment and external model boundaries in one evaluation run.
How DeployOpen scopes and delivers agent evaluation with promptfoo
DeployOpen approaches evaluating OpenAI Agents SDK applications with promptfoo as a fixed-scope engagement inside your own infrastructure. We agree what gets tested, which traces and sandboxed workflows are in view, and what evidence you receive before the work starts, then deliver the test suites, red team configuration and documentation your engineers can run and review.
How we scope
- We agree in writing which agents, tools, handoffs and sandboxed workflows are in the evaluation.
- We confirm where the promptfoo CLI runs and which model providers the agents call.
- We define the test identities, sessions and data the red team may use before any test runs.
How we build
- We wrap your Python openai-agents application as a promptfoo provider and configure tracing.
- We write functional tests plus trace assertions that check tool calls and handoffs in order.
- We configure agent red teams and stateful sessions, then review findings with your engineers.
How we hand over
- You receive the promptfoo configurations, test files, provider wrapper and CI run instructions.
- You receive a written record of each red team finding, its evidence and the suggested fix.
- We walk your engineers through running the suites and reading traces without our help.
How we support
- Engagements are fixed-scope, and any change to agents or tools is handled as a written scope change.
- Ongoing support, upgrades of promptfoo and continuous testing are available as a retainer.
- Ask for the retest plan and the support terms in the quote before the engagement begins.

