Evaluating LangGraph agents with promptfoo before they reach users
A LangGraph agent with tools and persistent state can be evaluated and red teamed with promptfoo by wrapping the graph as a Python provider, writing YAML tests for its expected behaviour, and running security scans against the same graph. The result is repeatable evidence of how the agent behaves and where it fails, gathered before users reach it. The setup, YAML test structure and security scan steps are covered in the promptfoo guide to evaluating and red teaming LangGraph agents, which is the first read for teams starting this work.
promptfoo is released under the MIT license and covers LLM evaluation, automated red teaming and code scanning. It can run as a command-line tool, as a library or inside a pipeline. Its documentation states that evals run on your machine and talk directly with the LLM, so the graph, its prompts, tool outputs and test data stay under your control while the tests call the model. Confirm which model provider your agent calls and whether that provider's terms cover the test prompts and payloads you plan to send, because red team probes are adversarial inputs that will reach that provider.
Teams need this when an agent can take actions with tools, reads from documents or other systems, or keeps state across turns. A single prompt review does not show whether a tool call can reach another user's records, or whether an injected instruction changes the agent's next step. Before release, decide who owns the test suite, which behaviours count as a pass, and how failures are triaged, because the scan output is only useful if someone is accountable for acting on it.
How a promptfoo run flows through a LangGraph agent
The run starts on the engineer's machine, where the promptfoo CLI reads the YAML config and calls the Python provider that wraps the LangGraph graph. The graph then calls the model and its tools, and the output comes back to promptfoo for assertions and red team grading. The trust boundary matters: evals run locally, but any hosted model the graph calls receives the prompts and tool outputs. Check which data leaves the machine before you point the suite at production-like data.
Request and result flow between the promptfoo CLI, the LangGraph agent and the model.
Configuration options and when each fits
This table compares three ways to run promptfoo against a LangGraph agent: local CLI evals, a red team config with plugins and strategies, and the self-hosted server or Enterprise for shared results. Read each row as a decision: what the option gives you, what it requires, and where it stops being enough. The main takeaway is that the self-hosted server is not recommended for production use, so team sharing at scale points toward Enterprise or On-Premise.
| Option | When it fits | What it requires | Limits to plan for |
|---|---|---|---|
| CLI eval against a local provider | Developers iterating on graph behavior and YAML tests before a change is merged | Node.js 22.22.0 or newer, the promptfoo package, and a Python provider that wraps the graph | Results stay on the machine running the eval, so sharing is manual |
| Red team config with plugins and strategies | Security checks on the graph's tools, memory and inputs before release or in a scheduled job | A red team section in the config, a chosen purpose statement, and the model credentials the scan uses | Scan size and probe counts shape run time and cost, so confirm limits for your edition |
| Self-hosted promptfoo server | A small team that wants a shared web UI for runs it controls | Docker, Docker Compose or Helm, plus a CLI connected to the server | Uses SQLite, which cannot be shared across replicas, and has no RBAC or SSO; not recommended for production |
| Enterprise (hosted or on-premise) | Teams that need shared results, access control, SSO and continuous monitoring at scale | A custom-priced agreement; On-Premise adds a dedicated deployment engineer and complete data isolation | Pricing is custom, so the scope and terms must be confirmed in writing before rollout |
| Community edition | Individuals and projects that need the full eval features and red teaming within the monthly probe allowance | A free install under the MIT license with community support | Support is community-based, and the monthly probe limit applies |
Setup sequence for a LangGraph agent in promptfoo
This sequence takes a LangGraph agent from a bare Python project to a set of behaviour tests and a security scan, with a check at each step so your team can confirm the harness is measuring the agent it should. The output is a working provider, a versioned YAML test suite and a red team report you can review and rerun.
Install promptfoo and confirm the runtime
Install the promptfoo CLI from npm, which requires Node.js 22.22.0 or newer, and confirm your Python environment can import the LangGraph agent package you plan to test. Your platform engineer or the developer who owns the agent typically does this on a workstation or CI runner. Verify by running the promptfoo version command and a trivial config that prints a result, so you know the CLI starts and the Node version is accepted before any agent code is involved.
Write the Python provider that wraps the graph
Create a Python file that exposes a call function promptfoo can invoke with the test prompt. The function should build the graph input, invoke the compiled LangGraph agent with a fixed thread or session identifier, and return a structured result containing the final message. Keep the tool-call trace available in the output so later assertions can inspect it. Verification: run the provider directly from the command line with one sample prompt and confirm it returns the final assistant message and a list of the tool calls the agent made. If tool calls are missing, the provider is not exposing the intermediate steps and tests on tool behaviour will not work.
Point the config at the provider
Reference the Python provider in the promptfoo configuration file, following the provider syntax in the promptfoo documentation for LangGraph. Set the prompt and the provider label so results are attributable to one agent version. Run a single test case through the full configuration. Verify that the output in the results viewer matches what you saw when calling the provider directly. A mismatch usually means the config passes the wrong input field or the provider path is resolved from a different working directory.
Define YAML tests for expected behaviour
Write test cases in YAML that describe what the agent should do on normal inputs: which tool it should call, what facts the answer must contain, and what it should refuse to do. Use assertions that check the final message and, where the provider exposes it, the tool-call trace. Cover at least one case per tool the agent can use and one case that should not trigger a tool. Run the suite and confirm that a deliberately wrong assertion fails, which proves the assertions are actually being evaluated before you trust a pass.
Add the red team section and run the scan
Add a redteam block to the configuration that names the purpose of the agent, the plugins that match its tools and data, and the strategies to apply. Run the red team scan against the same provider. Check that the generated attack prompts reach the graph and that the run completes without provider errors. Confirm the number of probes that ran and that results are grouped by plugin. A scan that reports only errors usually indicates a provider exception, not a secure agent.
Review results and rerun after fixes
Open the results for each failed probe, read the agent's final message and its tool-call trace, and decide whether the failure is in the graph, the tool permissions or the test itself. Your security or engineering lead signs off on which findings are fixed and which are accepted. After a change, rerun the same configuration and confirm the previously failing probes now pass and no earlier behaviour tests have regressed. Store the configuration and report output with the agent version so the evidence can be reproduced later.
Behaviour tests versus security scans for the graph
Functional tests answer one question: does the graph do what the team designed it to do? They run the agent against known inputs and assert on routing decisions, tool selection and answer quality. The promptfoo guide to evaluating LangGraph agents covers the setup and YAML test structure, so the team can write these tests alongside the graph rather than as a separate project. A failing functional test usually means a regression in a prompt, a conditional edge, a tool description or a node change, so the engineer should check the recent graph change first.
- Routing assertions: Check that a given request reaches the intended node or sub-agent. The engineer supplies a list of representative user intents and the expected path for each.
- Tool selection assertions: Check that the agent calls the right tool with the right arguments and does not call tools it should not need. The engineer supplies expected tool names and argument shapes.
- Answer quality assertions: Check that the final response contains required facts or follows the expected format. Graders such as LLM-as-a-judge need a rubric the team has agreed with the product owner.
- Fixture data: Tests need stable test records, such as sample accounts or order numbers, so results do not depend on live data.
Confirm with the team which outcomes are deterministic enough to assert exactly and which need a graded rubric.
Red team scans answer a different question: can someone make the graph do something it should refuse? Promptfoo generates adversarial inputs for selected risk categories, sends them to the graph through the provider, and grades the responses. A failed scan is a finding that needs triage: the agent produced an unsafe output or took an unsafe action. Scan results should be read against the categories the organization chose, not as a single overall score.
- Prompt injection: Attempts to override the agent's instructions through the user message or through content the agent reads. The engineer supplies the system purpose so the scan targets the right behaviour.
- Authorization failures: Attempts to reach records or functions above the user's role. This requires at least two test identities with known permissions, plus records owned by each identity.
- Tool misuse: Attempts to make the agent call tools with harmful arguments or outside its allowed scope. The engineer lists which tools exist, which are write operations and which need approval.
- Sample documents: If the graph uses retrieval, the engineer supplies representative documents so injected content is tested in realistic places.
Confirm with the security team which risk categories count as release blockers and who triages each finding.
The two test types produce different kinds of failure, and the response differs. A functional failure is usually a defect in the agent's design or prompts, so the fix belongs to the application team and the test should stay in the regression suite. A security failure may be a design gap, such as a tool that trusts model-supplied identifiers, so the fix may need changes outside the prompt, such as server-side checks in the tool itself. Treating a security finding as a prompt tweak often leaves the underlying gap in place.
- Functional failure: Usually fixed by changing a prompt, edge condition or tool description, then re-running the suite.
- Security failure: May require enforcing permissions in the tool or API the agent calls, which the model cannot override.
- Flaky results: Model output varies between runs, so the team should decide how many repetitions a test needs before a failure counts.
- Ownership: Name who triages each failure type before the first run, so findings do not wait in a shared report.
Check whether authorization decisions are enforced outside the model before accepting a passing scan as evidence.
Both test types depend on inputs that only the engineering and business teams can provide. Promptfoo can generate many adversarial prompts, but it cannot know which accounts exist, which tools are dangerous or what a correct answer looks like for the organization. Missing inputs usually show up as vague tests that pass for the wrong reasons. Gathering these inputs is often the largest share of the preparation effort, and it is a cost a partner or internal team must plan for.
- Test identities: Two or more users with different roles, plus the data each one legitimately owns.
- Tool inventory: The list of tools or APIs the graph can call, marked by read or write access and by approval requirements.
- Expected answers: Golden responses or rubric criteria for functional checks.
- Sample documents and records: Non-sensitive content that resembles production data, used for injection and retrieval tests.
- Data handling approval: Confirmation of which data may be sent to the model provider during tests.
Confirm that test data contains no production personal data before the first scan runs.
Security and operational risks when scanning an agent
A LangGraph agent often holds real tool access, live credentials and production data paths, and a red team scan sends it hostile input at volume. The cards below cover the risks that come from running promptfoo itself, from the provider config to the reports it leaves behind, so the scan does not create a new incident.
Tool permissions the scan can exercise
Red team payloads are designed to make the agent call its tools, so every tool the graph can reach is in scope for the scan. A tool that sends email, writes records or runs shell commands can act on a real system during a test. Before the first run, list each tool, decide which ones the test identity may call, and confirm that write and delete actions point at sandbox endpoints. Check this in the agent code, not only in the promptfoo config.
Red teaming docsCredentials in provider config
The provider block in promptfooconfig.yaml often references model keys, agent endpoints and tool tokens. If these are written into the file or the CLI environment, they can end up in commits, CI logs and exported results. Keep secrets in environment variables or your secrets manager, use a scan-only key with a spending limit, and confirm that the config file is excluded from shared reports before anyone copies it into a ticket.
Data sent to hosted models
Promptfoo runs locally and calls the model directly, but the agent's prompts, retrieved documents and tool outputs still reach whichever hosted model the graph uses during evals. Check which provider each node calls, whether that provider's terms allow the data class in your test set, and whether your test data contains real customer records. Synthetic data with the same shape is usually enough to test behavior.
Promptfoo introductionShared results on the self-hosted app
The self-hosted promptfoo app stores data in a local SQLite database that cannot be shared across replicas, has no RBAC, horizontal scaling, built-in authentication or SSO, and is not recommended for production use. If several reviewers need the same scan history, the app is a single shared store with no per-user access control. Decide whether results stay with the engineer who ran the scan, or whether an Enterprise deployment with access control is needed.
Self-hosting docsStoring reports with sensitive prompts
Red team reports record the attack prompts, the agent's replies and the tool calls the agent made, which can reveal internal instructions, tool names and sample data. Treat the output directory and any web UI results as sensitive. Set a retention period, restrict who can read the files, and do not attach full reports to tickets or chat threads. Summaries with the failing categories are usually enough for most reviewers.
Keeping the scan off production
Scans are noisy: they send many probes in a short period and can trigger rate limits, alerts and fraud controls on the systems the agent calls. Point the provider at a staging graph with staging tools, a non-production database and separate credentials, and confirm this in the config before every run. Ask your security team to approve the target and the time window, and agree who stops the scan if the environment behaves unexpectedly.
Questions teams ask before running promptfoo against a LangGraph agent
How much effort do the Python wrapper and YAML tests take?
Effort depends mostly on how the graph is built and how many behaviours you want to test. The wrapper is a Python provider that accepts the prompt from promptfoo, invokes the compiled graph and returns the final output, so a simple graph with one entry point is a small job. Effort rises with extra work: handling thread or session IDs, exposing tool calls and intermediate state for assertions, mocking external tools, and writing separate test cases for each routing path. Ask any partner to size the work from your graph's node count, tool count and state schema, and to say which tests are in scope before quoting.
Can an in-house engineer set this up without outside help?
Yes, if the engineer knows Python, the LangGraph agent's code and basic promptfoo configuration. promptfoo runs locally from the command line, and its documentation includes a guide to evaluating LangGraph agents covering setup, YAML tests and security scans, so the starting path is documented. The harder parts are judging which results matter, designing test identities and deciding what counts as a failed authorization check. Teams without someone who owns the agent's security posture often find those judgement calls take longer than the wiring.
What does the team need to provide for the work?
The work needs four things from your side:
- Read access to the graph code, including the state schema, node definitions, tool definitions and checkpointer configuration.
- Representative test data, such as sample user requests, expected answers and documents the agent retrieves.
- Test identities with the roles and permissions your production users hold, so authorization tests mean something.
- A non-production environment with stub or sandbox versions of the tools the agent calls, so scans do not change live systems.
Missing any of these usually shows up as tests that pass for the wrong reasons.
Is the Community edition enough to run security scans against a LangGraph agent?
For many teams, yes. The promptfoo Community edition is free, includes all LLM evaluation features and red teaming with 10k probes per month, and comes with community support, according to the promptfoo pricing page. Whether 10k probes covers your needs depends on how many plugins, strategies and test variants you run per scan, and how often you run them in CI. Count the probes your planned scan set will generate before deciding. Enterprise features such as SSO, team sharing and centralized dashboards are separate and are not needed to run scans locally.
Does running promptfoo against the agent send data to outside services?
It depends on the model and tools your agent uses. The promptfoo documentation states that the software runs locally, with evals on your machine talking directly to the LLM. The agent's own calls still go to whichever model provider it uses, and red team probes will reach that provider. Confirm which model endpoints, tool APIs and logging services receive test traffic, and whether any of them fall under data handling rules that apply to your organization.
When is it worth scoping outside help for this work?
Outside help is usually worth scoping when the agent has write access to business systems, when authorization rules are complex, or when you need evidence for a security review or a compliance assessment. DeployOpen runs security testing of AI systems and agents, delivers findings reports with fixes and a retest, and prepares evidence for compliance assessments, but it does not issue audit reports or certifications. Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts, so ask for a written scope that names the graph, tools and test categories covered.
What recurring work comes after the first set of tests?
Recurring work is the larger cost over time. Each change to the graph, its prompts, tools or model version can change behaviour, so tests and scans need rerunning, and new failing cases need triage. Plan for someone to own the test suite, review results after each release and update test identities as roles change. Ongoing support, upgrades and continuous testing are available as retainers from DeployOpen, and you can also keep this work in-house. Ask any provider what is one-time and what recurs before accepting a quote.
Phases from first provider to repeatable scan
The work starts by wrapping the compiled LangGraph graph as a promptfoo Python provider, so promptfoo can call the same entry point your users reach. Behaviour tests in YAML come next, because a red team scan is hard to interpret until normal functions pass. The scan then runs against the graph, and each finding is fixed and retested before the run moves into CI or a shared server. The handoff to check at each step is whether the provider still reproduces the production input and output path.
The phased path from a wrapped graph to a repeatable promptfoo scan.
How DeployOpen scopes and delivers LangGraph agent testing
DeployOpen agrees the scope of LangGraph agent testing in writing before any work starts. The written scope names the graph under test, the nodes and tools in scope, the identities and roles the test accounts will hold, the model providers the agent calls, and the environment where the agent runs. It also states which promptfoo features are in use. Community edition covers evaluations and red teaming with 10k probes per month, so the scope should say whether the expected probe volume fits that allowance or whether a paid tier is needed. Ask for the scope document to list each deliverable, the test assets handed over, and the retest conditions before the engagement begins.
The delivery work has three parts. First, DeployOpen reviews the agent: how the graph routes between nodes, which tools it can call, what state it persists, and where credentials and tool permissions are configured. Second, it runs the security testing against the agent and its tools, including authorization checks on the tool calls and injection through documents and tool outputs. Findings are documented with the reproducing YAML test, the trace or output that shows the failure, and a suggested fix. Your engineers then apply the fixes, since they own the agent code and the deployment. DeployOpen then retests the fixed behaviour and reports what now passes and what remains open. Teams that want the evidence to be reproducible should ask that every finding ship with a runnable test case.
DeployOpen does not issue audit reports, attestations or certifications. The testing and documentation it delivers can support a compliance assessment, but an independent auditor or certification body makes that determination. For the promptfoo features, configuration keys and red teaming options used in the work, the promptfoo documentation is the reference to check against your own setup, and your team should confirm the current plugin names and provider options in the version it installs.

