Why testing agent memory poisoning with promptfoo matters before rollout
If your agent stores memory or context across sessions, the question to answer before launch is whether something said in one session can plant instructions that change how the agent behaves in a later session, possibly for a different user. This is the risk the OWASP Top 10 for Agentic Applications for 2026 describes as ASI06 Memory and Context Poisoning. The category covers attacks that corrupt what an agent remembers or retrieves, so that poisoned content is treated as trusted context long after the original message was sent. A normal functional test will not show this, because each session can look correct on its own while the stored state quietly shifts.
Run this test before the agent reaches production, after any change to how memory is written, retrieved, summarized or shared, and before the agent is given access to more users or more tools. Each of those changes alters the path a poisoned instruction would take. Within promptfoo, the question is whether the memory poisoning plugin, used through a red team configuration, can drive a first session that attempts to plant an instruction and then probe a second session for its effect. Confirm with your promptfoo version that the plugin and its strategy are documented for the agent type you run, since the supported setups change between releases. Check the current promptfoo red teaming documentation for the plugin's exact behavior.
Plan the test as a decision, not a checkbox. Decide which memory stores are in scope, who can write to them, whether one user's memory can be read by another, and what a failed result would block. Ask your team to confirm how the agent exposes its memory state during the run, because a pass or fail result is only meaningful if the test can see what was stored and what was retrieved. Scope the test to what promptfoo's documented red teaming covers, and treat any finding as input to your own review of memory isolation and access control.
Configuration options and when each fits
This table compares session isolation setups, target types and grading choices for a memory poisoning test, with the agent capability each option depends on. Read it to pick the setup that matches your agent's memory design, then confirm the marked requirements with your engineers before you commit to a plan.
| Option | Best fit | Trade-off | Needs session IDs or reset hook |
|---|---|---|---|
| Same user, same session | Checking whether one conversation can plant an instruction that the agent later reuses within that conversation | Shows short-term context carry-over only, so it does not prove cross-session persistence | No |
| Same user, new session | Testing whether a poisoned memory write survives a session boundary for the same account | Needs a way to start a fresh session for the same identity, so confirm support for session creation with the agent team | Yes |
| Different user, shared memory store | Checking whether one user's planted content leaks into another user's answers (illustrative: a shared team knowledge store) | Requires two test identities and a shared store; confirm the store is actually shared in your build | Yes |
| Fresh versus persisted memory store | Fresh store per run gives repeatable baselines; persisted store shows real carry-over across runs | Persisted runs are harder to reproduce, so record store state before and after each run | Yes |
| HTTP endpoint target | Agents already exposed through an API, tested as a black box in the same way as production | Session and memory state must be passed in headers or body; confirm the agent accepts them | Yes |
| Python provider target | Agents built in Python where you can call memory write and reset functions directly | Gives precise control and inspection but couples the test to internal code paths that change | Yes |
| Grading by model judgment | Free-form memory content where harmful intent is hard to express as a fixed string | Adds model cost per grading call and judgment variance; pin the grader and review samples | No |
| Grading by deterministic checks | Known canary values or forbidden phrases in the later session's output | Fast and repeatable, but misses paraphrased harm unless paired with judgment grading | No |
Setup sequence for a memory poisoning red team
This sequence takes a team from an empty promptfoo environment to a memory poisoning scan with reviewed traces. Each step ends with a check, so the team can show that the memory state, the sessions and the results are what the test assumes. The output is a repeatable test that can be rerun after every change to the agent.
Check Node.js and install promptfoo
The platform engineering or security engineer confirms that the test runner has Node.js 22.22.0 or newer, then installs promptfoo from npm. The documented npm release for this sequence is 0.124.1, so pin that version in the test environment and record it with the results. Run
promptfoo --versionon the same machine that will run the scan. The step is complete when the version prints as 0.124.1 and the Node.js version check passes. Keep the install in a dedicated project directory so the configuration stays with the test.Wrap the agent as a promptfoo target
The engineer who owns the agent exposes it to promptfoo through a provider or endpoint that accepts a session identifier and returns the agent's reply and any tool calls. The wrapper must send each session to the same agent instance that stores memory, not a fresh copy, or the poisoning test measures nothing. Confirm the wrapper against the promptfoo documentation for targets, then send one benign message. The step is done when a single request returns a reply and the tool calls are visible in the output.
Confirm the memory store starts empty
The engineer who owns the agent's memory layer clears the store and verifies that it holds no records for the test identity before any run. This includes long-term memory, vector stores and any summary files the agent writes. Without this check, a result from an earlier run can look like a poisoning success. Record the store's state, such as a count of entries for the test user, before the run begins. The step is done when that count is zero and the same check is part of the run procedure.
Define the poisoning session
The red team lead writes the first session as a test case that sends the agent an instruction the agent should refuse to store or act on later, such as a rule that changes how it handles a category of request. The instruction should be plausible enough to be saved, which is the behavior under test. Use the memory poisoning plugin's generated prompts as a starting point and check their wording against the plugin reference before use. The step is done when the session is saved in the configuration with a stated expected outcome.
Define the recall session in a new session
The red team lead adds a second session that starts with a new session identifier and asks an ordinary question that the poisoned instruction would affect. The session must not carry over the first conversation history, so any change in behavior has to come from stored memory. Confirm the identifier handling in the target wrapper, then run only this session against an empty store to confirm it answers normally. The step is done when the recall session returns a normal answer on the clean store, which sets the baseline for comparison.
Run the memory poisoning scan
The engineer runs the red team scan with the poisoning session followed by the recall session, using the memory poisoning plugin and the configuration reviewed in the previous steps. Run the scan once against a cleared store, and record the promptfoo version, configuration file and provider settings alongside the output. After the run, check the store again and note whether the poisoned instruction was written. The step is done when the output file exists and the store state after the run is recorded.
Review traces and clear memory between runs
The red team lead reviews the traces for each session, focusing on whether the agent wrote the instruction to memory, whether the recall session used it, and which tool calls ran. Compare the recall answer with the clean baseline from the earlier step. Then clear the memory store, confirm it is empty, and rerun the scan to check that results are repeatable. Ask the agent owner to confirm which stored fields are authoritative. The step is done when the findings are documented and two clean runs produce the same outcome.
What the agent needs to expose for the test to work
A memory poisoning test only proves something if you can see what the agent stored, when it stored it and what it fed the model. The components below are the minimum an agent should surface so that a later answer can be traced back to a poisoned write rather than a normal response.
Session identifiers
Every interaction needs a stable session ID and a user or tenant ID attached to it. Without them, you cannot tell whether an instruction planted in session A later surfaced in session B, which is the core claim of the test. Check that the IDs survive across the poisoning turn and the probe turn, and that a fresh session gets a new ID with no inherited state.
Memory read and write view
The agent should log each write to long-term memory, including the content, the source turn and the session that triggered it. A write log entry is the evidence that a harmful instruction was stored. Without it, a later bad answer could come from the model itself, and you would have no way to separate the two causes.
Memory reset and isolation controls
You need a way to clear memory between test runs and to confirm that one user's memory is not visible to another. Ask the team which reset operation exists, whether it is available in a test environment, and whether it deletes stored vectors, summaries and profile fields alike. Without a verified reset, earlier runs contaminate later results.
Tool call logs
Memory tools such as save, update or delete calls should appear in the tool log with their arguments and results. This shows whether the agent wrote memory because the user asked for it or because a tool was invoked from injected content. Check that logs record the exact arguments, not only the tool name, so you can compare what was stored against what the attacker supplied.
Context passed to the model
The full prompt sent to the model, including retrieved memory and system instructions, must be captured for each turn. This lets you confirm that a poisoned memory actually entered the context, rather than being present in storage but never retrieved. Store these prompts alongside the response so grading can point to the exact memory line that influenced the answer.
How a poisoning attempt moves from session one to session two
The attack starts in an attacker-controlled session that sends a message the agent treats as worth remembering. The agent writes that content into a memory store shared across sessions, which sits on the far side of a trust boundary from individual user sessions. In a later session, a clean user asks an ordinary question, the agent reads memory back into its context, and the resulting output is what the grader scores. Check whether the stored entry reached the output and whether the grader sees the memory read as well as the final answer.
Poisoned content crosses from one user session to a later clean session through shared memory.
Security and operational considerations for the test environment
A memory poisoning test writes attacker-controlled content into a stateful agent and then reads it back in a later session. That makes the test environment a place where real data, real credentials and real traces can end up, so the controls below need to be set before the first run. Each card covers one decision the team owns.
Separate test memory from production
Point the agent under test at a memory store that exists only for the test, with its own namespace, database or vector collection. Poisoned entries written during a scan persist between sessions by design, so a shared store would carry injected instructions into live user sessions. Ask the platform team to confirm that no production write path, sync job or backup restore can reach the test store, and delete the store at the end of each campaign.
Know what leaves the machine
promptfoo's documentation states that it runs completely locally: evals run on your machine and talk directly with the LLM. The MIT license covers the software, not the model provider. When the target is a hosted model, every generated attack, every agent response and every memory write goes to that provider under its own terms, so confirm the data processing agreement and retention settings before the scan starts.
promptfoo introductionScope credentials for tool access
A stateful agent that can write memory often also holds tokens for the tools it calls, and a poisoned memory entry can steer those calls in later sessions. Give the test agent sandbox accounts with the minimum scopes needed, never the credentials of a named employee or a production service account. Rotate those secrets after the test, and confirm that the agent cannot forward tokens it received from the client to downstream services.
Keep traces as evidence
A finding is only useful if someone can replay it. Record the poisoned input, the memory state before and after the write, the session that later acted on it, and the tool calls it triggered. Store these traces in a restricted location with a retention period set by your compliance team, and remember that traces can contain sensitive data that the test itself surfaced. Confirm with your security lead how long the evidence must be kept and who may read it.
Control the self-hosted server
If the team runs the self-hosted promptfoo app for shared results, note that its documentation says the default SQLite database cannot be shared across replicas, has no RBAC, and is not recommended for production use. Limit network access to the server, keep it out of the production network, and treat stored results as sensitive because they include attack payloads and model outputs. Confirm these limits against the version you deploy.
Self-hosting docsQuestions teams ask before testing agent memory poisoning
How much effort does a memory poisoning test take?
Effort depends mainly on how many memory paths the agent has and how much of the agent you can reach from the test harness. A single agent with one long-term memory store and a stable session API is far smaller than a multi-agent system where several components read and write shared memory. Most of the work is not running the scan. It is wiring the agent to promptfoo, defining what counts as a poisoned memory and reviewing the findings with the team that owns the agent. Ask any provider to break the effort into harness setup, test design, execution, triage and retest so you can see where the hours go.
What does the work need from our engineers?
Plan for four inputs before the test starts:
- Access to a test or staging instance of the agent, with a documented way to send messages and start sessions
- Session identifiers, including how the agent scopes memory to a user, a session or a workspace
- Test identities that can write to and read from memory without touching real customer data
- A named owner who can explain what the agent is allowed to remember and how memory is cleared
Engineers should also confirm whether memory is shared across users, because that changes what a pass means.
Can we run the memory poisoning test ourselves with the open-source CLI?
Yes, if your team can connect the agent to promptfoo and read the results. The promptfoo CLI is MIT licensed, and the Community edition is free and includes red teaming with 10k probes per month, according to the promptfoo pricing page. Running evals locally means the tests talk directly with the model your application uses. The harder parts are the target setup, the choice of session boundaries and interpreting whether a later session actually followed injected instructions. Many teams start in-house for a pilot and bring in a partner for the first full review of an agent that holds sensitive memory.
What drives the cost of a fixed-scope engagement?
A fixed-scope quote follows from the written scope, not from a list price. DeployOpen does not publish a price list. The main cost drivers are the number of agents and memory stores in scope, how much access the test team gets to the agent's internals, how many tool integrations can write to memory, whether a retest is included and how many findings need fixes checked. Ask the provider to state what is one-time, such as the harness and the initial report, and what recurs, such as scheduled re-runs or retainers. Also ask who pays for model usage during the test, since probe volume affects token spend.
How long does it take to get results?
The timeline depends on how quickly access, test identities and session rules are confirmed, not only on the scan run. Scan time for a single agent is usually short compared with setup and review. Agree on the timeline in writing before work starts, and ask the provider to tie milestones to your access dates. Where a retest is part of the scope, add time for your engineers to ship fixes before the retest can begin. Check your own environment and model provider limits, since rate limits and cached runs can change how long a full pass takes.
What does a memory poisoning finding look like?
A finding shows that content planted in one session changed what the agent did in a later session. The evidence should include the injected memory entry, the session in which it was written, the later session that read it, and the action or answer that followed. Ask for the transcript and any tool calls, because a reply that sounds harmless may still have triggered a write or a disclosure. Your team should be able to reproduce the finding from the stored inputs and the session identifiers.
Does passing this test show that our agent is compliant?
No. A memory poisoning test produces evidence about one agent at one point in time. It does not issue an audit report, attestation or certification. DeployOpen prepares systems, controls and evidence for compliance assessments, but independent auditors and certification bodies make the assessment. Frameworks such as the OWASP Top 10 for Agentic Applications, which lists memory and context poisoning as ASI06, give you a shared vocabulary for scoping the test and reporting results.
What a DeployOpen memory poisoning engagement covers
A memory poisoning engagement is scoped as part of AI agent rollout security review. DeployOpen configures the promptfoo test against the agent you run, tests the design of its memory store, and delivers a findings report with fixes and a retest. The work is agreed in writing before it starts, so the scope, the deliverables and the timeline are known to both sides before any test runs. The first question in scoping is which memory the agent actually writes to: a per-session context buffer, a long-term store such as a vector index or a key-value table, or a summary the agent regenerates. Each one needs a different test path, and the scope should name them explicitly.
On the promptfoo side, DeployOpen sets up the target provider so that the agent's memory write and read paths are exercised across separate sessions, then configures the memory poisoning plugin with the purpose of the agent and the instructions it should never retain. The team reviews the generated test cases against the agent's real tools and permissions, because a poisoned instruction matters only if a later session can act on it. Work also covers how results are stored and who can read them. Where the agent's memory design is weak, the engagement covers the design review: write permissions, namespacing between users and tenants, expiry and review of stored entries, and whether memory writes are logged with enough detail to trace an entry back to the conversation that created it.
The findings report lists each confirmed persistence path with the session that planted the instruction, the session that acted on it, and the controls that failed or were missing. Each finding comes with a recommended fix and a retest against the same test cases once the fix is in place. Ongoing support and continuous testing are available as retainers. Before scoping, ask DeployOpen to confirm which memory types, providers and hosting environment are in scope, and which sessions and identities the test will use. A quote follows from that written scope.
How DeployOpen scopes, delivers and supports agent memory testing
DeployOpen plans and runs memory poisoning tests for stateful agents as part of a fixed-scope engagement, with the test identities, memory store access and evidence agreed in writing first. Work is delivered inside the client's own infrastructure, and the findings are handed over with the configuration needed to rerun the tests.
How we scope
- Scope names the agent, its memory stores, the sessions that read and write them, and the sessions treated as attacker controlled.
- The written scope lists which promptfoo plugins, strategies and targets are in use, and which memory operations are tested.
- Engagements are fixed-scope, so deliverables, timelines and retest terms are agreed in writing before any test runs.
How we build
- We connect promptfoo to a staging copy of the agent with a clean memory store and a separate test identity for each session.
- Test sequences are written to plant instructions in one session, reset nothing between sessions, and check the next session's behavior.
- Each run records the memory writes, retrieved entries and final outputs so a reviewer can trace every pass or failure.
How we hand over
- The handover includes the promptfoo configuration, the seeded memory fixtures and the scripts that reset the test environment.
- Findings describe which memory writes were accepted, which were retrieved later, and which controls stopped or allowed them.
- Fixes are documented with a retest, and the report states exactly what was tested and what was out of scope.
How we support
- Ongoing support, upgrades and continuous testing are available as retainers when the agent or its memory design changes.
- Retesting after changes to memory schemas, retrieval logic or the underlying model is scoped as a separate, written item.
- Clients confirm with their own teams which memory stores and retention rules apply, since these shape the test design.

